Skip to content

Commit fc5171a

Browse files
author
Jesse
committed
Update tests.cpp
1 parent c668d91 commit fc5171a

1 file changed

Lines changed: 28 additions & 24 deletions

File tree

tests.cpp

Lines changed: 28 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,14 @@ struct result {
2626
code return {true, 0, "", "", ""}; \
2727
}
2828

29+
TEST(no_args, {
30+
try {
31+
parser.parse(argc, argv);
32+
} catch (const ArgumentParser::ArgumentNotFound& ex) {
33+
TASSERT(false, ex.what())
34+
}
35+
}, )
36+
2937
TEST(short_optional_flag_exists,
3038
{
3139
parser.add_argument("-f", "a flag", false);
@@ -38,17 +46,15 @@ TEST(short_optional_flag_exists,
3846
},
3947
"-f")
4048

41-
TEST(short_optional_flag_does_not_exist,
42-
{
43-
parser.add_argument("-f", "a flag", false);
44-
try {
45-
parser.parse(argc, argv);
46-
} catch (const ArgumentParser::ArgumentNotFound& ex) {
47-
TASSERT(false, ex.what())
48-
}
49-
TASSERT(!parser.exists("f"), "flag found")
50-
},
51-
"")
49+
TEST(short_optional_flag_does_not_exist, {
50+
parser.add_argument("-f", "a flag", false);
51+
try {
52+
parser.parse(argc, argv);
53+
} catch (const ArgumentParser::ArgumentNotFound& ex) {
54+
TASSERT(false, ex.what())
55+
}
56+
TASSERT(!parser.exists("f"), "flag found")
57+
}, )
5258

5359
TEST(short_required_flag_exists,
5460
{
@@ -62,18 +68,16 @@ TEST(short_required_flag_exists,
6268
},
6369
"-f")
6470

65-
TEST(short_required_flag_does_not_exist,
66-
{
67-
parser.add_argument("-f", "a flag", true);
68-
bool failed = false;
69-
try {
70-
parser.parse(argc, argv);
71-
} catch (const ArgumentParser::ArgumentNotFound& ex) {
72-
failed = true;
73-
}
74-
TASSERT(failed, "required flag found")
75-
},
76-
"")
71+
TEST(short_required_flag_does_not_exist, {
72+
parser.add_argument("-f", "a flag", true);
73+
bool failed = false;
74+
try {
75+
parser.parse(argc, argv);
76+
} catch (const ArgumentParser::ArgumentNotFound&) {
77+
failed = true;
78+
}
79+
TASSERT(failed, "required flag found")
80+
}, )
7781

7882
#define TT(name) \
7983
{ #name, name }
@@ -113,5 +117,5 @@ int main(int argc, const char* argv[]) {
113117
}
114118
}
115119
std::cout << "Passed: " << passed << "/" << results.size() << std::endl;
116-
return 0;
120+
return static_cast<int>(results.size() - passed);
117121
}

0 commit comments

Comments
 (0)