Skip to content
This repository has been archived by the owner on Dec 4, 2023. It is now read-only.

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
aakropotkin committed Aug 23, 2023
1 parent cf34947 commit 3b7b41d
Showing 1 changed file with 20 additions and 19 deletions.
39 changes: 20 additions & 19 deletions tests/read.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,29 +29,30 @@ using namespace flox;
test_distanceFromMatch()
{
std::tuple<char const*, char const*, size_t> cases[] = {
{ "match", "match", 0 },
{ "match", "partial match", 0 },
{ "match", "miss", 0 },
{ "partial match", "match", 1 },
{ "partial match", "partial match", 1 },
{ "partial match", "miss", 2 },
{ "miss", "match", 3 },
{ "miss", "partial match", 3 },
{ "miss", "miss", 4 },
{ "match", "match", 0 }
, { "match", "partial match", 0 }
, { "match", "miss", 0 }
, { "partial match", "match", 1 }
, { "partial match", "partial match", 1 }
, { "partial match", "miss", 2 }
, { "miss", "match", 3 }
, { "miss", "partial match", 3 }
, { "miss", "miss", 4 }
};

RawPackage pkg;
for (auto [pname, description, distance] : cases) {
pkg = RawPackage(nlohmann::json {
{ "name", "name" },
{ "pname", pname },
{ "description", description },
});
EXPECT_EQ(*pkgdb::distanceFromMatch(pkg, "match"), distance);
}
for ( auto [pname, description, distance] : cases )
{
pkg = RawPackage( nlohmann::json {
{ "name", "name" }
, { "pname", pname }
, { "description", description }
} );
EXPECT_EQ( * pkgdb::distanceFromMatch( pkg, "match"), distance );
}

// Should return std::nullopt for empty match string.
EXPECT(pkgdb::distanceFromMatch(pkg, "") == std::nullopt);
/* Should return std::nullopt for empty match string. */
EXPECT( pkgdb::distanceFromMatch( pkg, "" ) == std::nullopt );
return true;
}

Expand Down

0 comments on commit 3b7b41d

Please sign in to comment.