Skip to content

Commit a5ccd9f

Browse files
committed
Add test cases for xutils
1 parent f80ca79 commit a5ccd9f

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

test/test_interpreter.cpp

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,31 @@ TEST_SUITE("extract_filename")
4545

4646
std::string result = xcpp::extract_filename(argc, const_cast<char**>(arguments));
4747
REQUIRE(result == "filename.txt");
48-
REQUIRE(argc == 2);
48+
REQUIRE(argc == 3);
4949
}
5050
}
51+
52+
TEST_SUITE("should_print_version")
53+
{
54+
/* Checks when the right argument is passed*/
55+
TEST_CASE("should_print_version_with_version_arg")
56+
{
57+
58+
const char* arguments[] = {"argument1", "--version"};
59+
int argc = sizeof(arguments) / sizeof(arguments[0]);;
60+
61+
bool result = xcpp::should_print_version(argc, const_cast<char**>(arguments));
62+
REQUIRE(result);
63+
}
64+
65+
/* Checks when the wrong argument is passed*/
66+
TEST_CASE("should_print_version_without_version_arg")
67+
{
68+
const char* arguments[] = {"argument1", "argument2"};
69+
int argc = sizeof(arguments) / sizeof(arguments[0]);;
70+
71+
bool result = xcpp::should_print_version(argc, const_cast<char**>(arguments));
72+
73+
REQUIRE(!result);
74+
}
75+
}

0 commit comments

Comments
 (0)