Skip to content

Commit 93e62c9

Browse files
mizdebskmkoncek
authored andcommitted
Eliminate use of assert_that in favor of assert_eq
Replace all uses of assert_that with assert_eq for consistency and clearer test failure messages. assert_eq is already used elsewhere and provides better diagnostics by showing expected vs. actual values.
1 parent 89a8dc8 commit 93e62c9

1 file changed

Lines changed: 21 additions & 23 deletions

File tree

src/jurand_test.cpp

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@
55

66
using namespace java_symbols;
77

8+
template <typename T1, typename T2>
9+
static std::ostream &operator<<(std::ostream &os, const std::tuple<T1, T2> &t)
10+
{
11+
return os << "(" << std::get<0>(t) << ", " << std::get<1>(t) << ")";
12+
}
13+
814
static void assert_eq(const auto& expected, const auto& actual)
915
{
1016
if (expected != actual)
@@ -15,14 +21,6 @@ static void assert_eq(const auto& expected, const auto& actual)
1521
}
1622
}
1723

18-
static void assert_that(bool value)
19-
{
20-
if (not value)
21-
{
22-
throw std::runtime_error("Test failed");
23-
}
24-
}
25-
2624
int main()
2725
{
2826
std::cout << "Running tests..." << "\n";
@@ -96,28 +94,28 @@ int main()
9694
assert_eq(0, find_token("import/", "import", 0, true));
9795
assert_eq(0, find_token("import+", "import", 0, true));
9896

99-
assert_that(next_annotation_t("@A", "A") == next_annotation("@A"));
100-
assert_that(next_annotation_t("@A", "A") == next_annotation("@A\n"));
101-
assert_that(next_annotation_t("@A()", "A") == next_annotation("@A()"));
97+
assert_eq(next_annotation_t("@A", "A"), next_annotation("@A"));
98+
assert_eq(next_annotation_t("@A", "A"), next_annotation("@A\n"));
99+
assert_eq(next_annotation_t("@A()", "A"), next_annotation("@A()"));
102100

103-
assert_that(next_annotation_t("@A", "A") == next_annotation("@A class B {}"));
101+
assert_eq(next_annotation_t("@A", "A"), next_annotation("@A class B {}"));
104102

105-
assert_that(next_annotation_t("@A(a = ')')", "A") == next_annotation("@A(a = ')')"));
106-
assert_that(next_annotation_t("@A(a = ')')", "A") == next_annotation("@A(a = ')') class B {}"));
103+
assert_eq(next_annotation_t("@A(a = ')')", "A"), next_annotation("@A(a = ')')"));
104+
assert_eq(next_annotation_t("@A(a = ')')", "A"), next_annotation("@A(a = ')') class B {}"));
107105

108-
assert_that(next_annotation_t("@A(a = \")\")", "A") == next_annotation("@A(a = \")\")"));
109-
assert_that(next_annotation_t("@A(a = \")))\" /*)))*/)", "A") == next_annotation("@A(a = \")))\" /*)))*/) class B {}"));
110-
assert_that(next_annotation_t("@A(/* ) */)", "A") == next_annotation("@A(/* ) */)"));
111-
assert_that(next_annotation_t("@A", "A") == next_annotation("method(@A Object o)"));
106+
assert_eq(next_annotation_t("@A(a = \")\")", "A"), next_annotation("@A(a = \")\")"));
107+
assert_eq(next_annotation_t("@A(a = \")))\" /*)))*/)", "A"), next_annotation("@A(a = \")))\" /*)))*/) class B {}"));
108+
assert_eq(next_annotation_t("@A(/* ) */)", "A"), next_annotation("@A(/* ) */)"));
109+
assert_eq(next_annotation_t("@A", "A"), next_annotation("method(@A Object o)"));
112110

113-
assert_that(next_annotation_t("@A(\nvalue = \")\" /* ) */\n// )\n)", "A") == next_annotation("@A(\nvalue = \")\" /* ) */\n// )\n)\n"));
111+
assert_eq(next_annotation_t("@A(\nvalue = \")\" /* ) */\n// )\n)", "A"), next_annotation("@A(\nvalue = \")\" /* ) */\n// )\n)\n"));
114112

115-
assert_that(next_annotation_t("@D", "D") == next_annotation(" // @A\n/* @B */\nvalue = \"@C\";\n@D"));
113+
assert_eq(next_annotation_t("@D", "D"), next_annotation(" // @A\n/* @B */\nvalue = \"@C\";\n@D"));
116114

117-
assert_that(next_annotation_t("@a.b.C", "a.b.C") == next_annotation("@a.b.C"));
118-
assert_that(next_annotation_t("@a/**/.B", "a.B") == next_annotation("@a/**/.B"));
115+
assert_eq(next_annotation_t("@a.b.C", "a.b.C"), next_annotation("@a.b.C"));
116+
assert_eq(next_annotation_t("@a/**/.B", "a.B"), next_annotation("@a/**/.B"));
119117

120-
assert_that(next_annotation_t("@A(value = /* ) */ \")\")", "A") == next_annotation("@A(value = /* ) */ \")\")//)"));
118+
assert_eq(next_annotation_t("@A(value = /* ) */ \")\")", "A"), next_annotation("@A(value = /* ) */ \")\")//)"));
121119

122120
{
123121
constexpr std::string_view original_content = R"(

0 commit comments

Comments
 (0)