Skip to content

Commit

Permalink
Format codes (#798)
Browse files Browse the repository at this point in the history
  • Loading branch information
ken-matsui authored Dec 8, 2023
1 parent 5d21120 commit b411917
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 29 deletions.
3 changes: 2 additions & 1 deletion tests/unit/core/builder/syntax.cc
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,8 @@ auto main() -> int {
{"out"}, "cc",
builder::syntax::BuildSet{
.inputs = Vec{"in"s},
.variables = HashMap<String, String>{{"name", "value"}}}
.variables = HashMap<String, String>{{"name", "value"}}
}
);

expect(
Expand Down
38 changes: 24 additions & 14 deletions tests/unit/core/resolver/sat.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,28 @@ auto main() -> int {

it("test2") = [] {
const std::vector<std::vector<int>> clauses{
{-1, -2, -3}, {-2, -3, -4}, {-2, -2, 3}, {2, 2, 2}};
{-1, -2, -3}, {-2, -3, -4}, {-2, -2, 3}, {2, 2, 2}
};
const auto result = solve(clauses, 4);

expect(result.is_ok());
expect(eq(result.unwrap(), std::vector<int>({-1, 2, 3, -4})));
};

it("test3") = [] {
const std::vector<std::vector<int>> clauses{
{1}, {-2, 4, 5}, {-2, 6}, {-3, 5}, {2}, {3}, {4, 5}, {-4, -5}, {6}};
const std::vector<std::vector<int>> clauses{{1}, {-2, 4, 5}, {-2, 6},
{-3, 5}, {2}, {3},
{4, 5}, {-4, -5}, {6}};
const auto result = solve(clauses, 6);

expect(result.is_ok());
expect(eq(result.unwrap(), std::vector<int>({1, 2, 3, -4, 5, 6})));
};

it("test4") = [] {
const std::vector<std::vector<int>> clauses{
{1, 2}, {-2, 3}, {-2, 4}, {-4, 5}, {1}, {2}, {3}, {4}, {5}};
const std::vector<std::vector<int>> clauses{{1, 2}, {-2, 3}, {-2, 4},
{-4, 5}, {1}, {2},
{3}, {4}, {5}};
const auto result = solve(clauses, 5);

expect(result.is_ok());
Expand All @@ -45,7 +48,8 @@ auto main() -> int {

it("test5") = [] {
const std::vector<std::vector<int>> clauses{
{1, 2}, {-3, 2}, {-3, 4}, {3}, {4}};
{1, 2}, {-3, 2}, {-3, 4}, {3}, {4}
};
const auto result = solve(clauses, 4);

expect(result.is_ok());
Expand All @@ -57,16 +61,18 @@ auto main() -> int {
const std::vector<std::vector<int>> clauses{
{1}, {-2, 6, 5, 4}, {-3, 6, 4}, {2},
{3}, {4, 5, 6}, {-4, -5, 6}, {-4, 5, -6},
{4, -5, -6}, {-4, -5, -6}, {-4, 6}};
{4, -5, -6}, {-4, -5, -6}, {-4, 6}
};
const auto result = solve(clauses, 6);

expect(result.is_ok());
expect(eq(result.unwrap(), std::vector<int>({1, 2, 3, -4, -5, 6})));
};

it("test7") = [] {
const std::vector<std::vector<int>> clauses{
{1}, {-2, 4, 5}, {-2, 6}, {-3, 5}, {2}, {3}, {4, 5}, {-4, -5}, {6}};
const std::vector<std::vector<int>> clauses{{1}, {-2, 4, 5}, {-2, 6},
{-3, 5}, {2}, {3},
{4, 5}, {-4, -5}, {6}};
const auto result = solve(clauses, 6);

expect(result.is_ok());
Expand All @@ -75,7 +81,8 @@ auto main() -> int {

it("test8") = [] {
const std::vector<std::vector<int>> clauses{
{1}, {2}, {3}, {-2, 4, 5, 6}, {-3, 5}, {4, 5}, {-4, -5}, {6}};
{1}, {2}, {3}, {-2, 4, 5, 6}, {-3, 5}, {4, 5}, {-4, -5}, {6}
};
const auto result = solve(clauses, 6);

expect(result.is_ok());
Expand All @@ -85,8 +92,9 @@ auto main() -> int {

describe("test solve => UNSAT") = [] {
it("test1") = [] {
const std::vector<std::vector<int>> clauses{
{1}, {-2, 4}, {-3, 5}, {4, 5}, {-4, -5}, {2}, {3}};
const std::vector<std::vector<int>> clauses{{1}, {-2, 4}, {-3, 5},
{4, 5}, {-4, -5}, {2},
{3}};
const auto result = solve(clauses, 5);

expect(result.is_err());
Expand All @@ -95,7 +103,8 @@ auto main() -> int {
// FIXME: Maybe the SAT solver has a bug
skip / it("test2") = [] {
const std::vector<std::vector<int>> clauses{
{-1, -2, -3}, {-2, -3, -4}, {-2, -2, 3}, {2, 2, 2}, {1, -2, 4}};
{-1, -2, -3}, {-2, -3, -4}, {-2, -2, 3}, {2, 2, 2}, {1, -2, 4}
};
const auto result = solve(clauses, 4);

expect(result.is_err());
Expand Down Expand Up @@ -153,7 +162,8 @@ auto main() -> int {
{36, 86, -96}, {-2, 36, 75}, {-59, -71, 89}, {36, -67, 91},
{36, -60, 63}, {-63, 91, -93}, {25, 87, 92}, {-21, 49, -71},
{-2, 10, 22}, {6, -18, 41}, {6, 71, -92}, {-53, -69, -71},
{-2, -53, -58}, {43, -45, -96}, {34, -45, -69}, {63, -86, -98}};
{-2, -53, -58}, {43, -45, -96}, {34, -45, -69}, {63, -86, -98}
};
const auto result = solve(clauses, 100);

expect(result.is_err());
Expand Down
3 changes: 2 additions & 1 deletion tests/unit/util/misc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ auto main() -> int {

std::vector<std::string> excepted{
"Lorem ipsum dolor sit amet", " consectetur adipiscing elit",
" sed do eiusmod ..."};
" sed do eiusmod ..."
};
expect(eq(split(test_case, ","), excepted));

excepted = {"Lorem ", "psum dolor s", "t amet, consectetur ad",
Expand Down
3 changes: 2 additions & 1 deletion tests/unit/util/pretty.cc
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ auto main() -> int {
eq(textwrap(test_case, 15),
std::vector{
"This function"s, "does not break"s, "long words and"s,
"break on"s, "hyphens."s})
"break on"s, "hyphens."s
})
);
};
}
36 changes: 24 additions & 12 deletions tests/unit/util/semver/parser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,17 @@ auto main() -> int {
Parser parser("1.2.3-pre");
const auto parsed = parser.version();
const std::vector<Identifier> expected_pre = {
Identifier(Identifier::AlphaNumeric, "pre")};
Identifier(Identifier::AlphaNumeric, "pre")
};
expect(expected_pre == parsed.pre);
};

"test parser prerelease alphanumeric"_test = [] {
Parser parser("1.2.3-alpha1");
const auto parsed = parser.version();
const std::vector<Identifier> expected_pre = {
Identifier(Identifier::AlphaNumeric, "alpha1")};
Identifier(Identifier::AlphaNumeric, "alpha1")
};
expect(expected_pre == parsed.pre);
};

Expand All @@ -88,23 +90,26 @@ auto main() -> int {
const auto parsed = parser.version();
const std::vector<Identifier> expected_pre = {
Identifier(Identifier::AlphaNumeric, "pre"),
Identifier(Identifier::Numeric, 0)};
Identifier(Identifier::Numeric, 0)
};
expect(expected_pre == parsed.pre);
};

"test parser basic build"_test = [] {
Parser parser("1.2.3+build");
const auto parsed = parser.version();
const std::vector<Identifier> expected_build = {
Identifier(Identifier::AlphaNumeric, "build")};
Identifier(Identifier::AlphaNumeric, "build")
};
expect(expected_build == parsed.build);
};

"test parser build alphanumeric"_test = [] {
Parser parser("1.2.3+build5");
const auto parsed = parser.version();
const std::vector<Identifier> expected_build = {
Identifier(Identifier::AlphaNumeric, "build5")};
Identifier(Identifier::AlphaNumeric, "build5")
};
expect(expected_build == parsed.build);
};

Expand All @@ -113,11 +118,13 @@ auto main() -> int {
const auto parsed = parser.version();

const std::vector<Identifier> expected_pre = {
Identifier(Identifier::AlphaNumeric, "alpha1")};
Identifier(Identifier::AlphaNumeric, "alpha1")
};
expect(expected_pre == parsed.pre);

const std::vector<Identifier> expected_build = {
Identifier(Identifier::AlphaNumeric, "build5")};
Identifier(Identifier::AlphaNumeric, "build5")
};
expect(expected_build == parsed.build);
};

Expand All @@ -128,13 +135,15 @@ auto main() -> int {
const std::vector<Identifier> expected_pre = {
Identifier(Identifier::Numeric, 1),
Identifier(Identifier::AlphaNumeric, "alpha1"),
Identifier(Identifier::Numeric, 9)};
Identifier(Identifier::Numeric, 9)
};
expect(expected_pre == parsed.pre);

const std::vector<Identifier> expected_build = {
Identifier(Identifier::AlphaNumeric, "build5"),
Identifier(Identifier::Numeric, 7),
Identifier(Identifier::AlphaNumeric, "3aedf")};
Identifier(Identifier::AlphaNumeric, "3aedf")
};
expect(expected_build == parsed.build);
};

Expand All @@ -144,11 +153,13 @@ auto main() -> int {

const std::vector<Identifier> expected_pre = {
Identifier(Identifier::AlphaNumeric, "beta"),
Identifier(Identifier::Numeric, 1)};
Identifier(Identifier::Numeric, 1)
};
expect(expected_pre == parsed.pre);

const std::vector<Identifier> expected_build = {
Identifier(Identifier::AlphaNumeric, "0851523")};
Identifier(Identifier::AlphaNumeric, "0851523")
};
expect(expected_build == parsed.build);
};

Expand All @@ -161,7 +172,8 @@ auto main() -> int {
expect(parsed.patch == 0_i);

const std::vector<Identifier> expected_pre = {
Identifier(Identifier::AlphaNumeric, "WIP")};
Identifier(Identifier::AlphaNumeric, "WIP")
};
expect(expected_pre == parsed.pre);
};
}

0 comments on commit b411917

Please sign in to comment.