From a5ccd9f918b077e4bf45ed4fc238552c990c17f3 Mon Sep 17 00:00:00 2001 From: tharun571 Date: Thu, 14 Mar 2024 20:16:15 +0530 Subject: [PATCH 1/2] Add test cases for xutils --- test/test_interpreter.cpp | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/test/test_interpreter.cpp b/test/test_interpreter.cpp index 392b58d9..4045e1e2 100644 --- a/test/test_interpreter.cpp +++ b/test/test_interpreter.cpp @@ -45,6 +45,31 @@ TEST_SUITE("extract_filename") std::string result = xcpp::extract_filename(argc, const_cast(arguments)); REQUIRE(result == "filename.txt"); - REQUIRE(argc == 2); + REQUIRE(argc == 3); } } + +TEST_SUITE("should_print_version") +{ + /* Checks when the right argument is passed*/ + TEST_CASE("should_print_version_with_version_arg") + { + + const char* arguments[] = {"argument1", "--version"}; + int argc = sizeof(arguments) / sizeof(arguments[0]);; + + bool result = xcpp::should_print_version(argc, const_cast(arguments)); + REQUIRE(result); + } + + /* Checks when the wrong argument is passed*/ + TEST_CASE("should_print_version_without_version_arg") + { + const char* arguments[] = {"argument1", "argument2"}; + int argc = sizeof(arguments) / sizeof(arguments[0]);; + + bool result = xcpp::should_print_version(argc, const_cast(arguments)); + + REQUIRE(!result); + } +} \ No newline at end of file From ad18588e37c2bf49e0e5a7321c9874e7663cfa24 Mon Sep 17 00:00:00 2001 From: tharun571 Date: Thu, 14 Mar 2024 20:20:44 +0530 Subject: [PATCH 2/2] Fix test case for xutils --- test/test_interpreter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_interpreter.cpp b/test/test_interpreter.cpp index 4045e1e2..8ea110b1 100644 --- a/test/test_interpreter.cpp +++ b/test/test_interpreter.cpp @@ -45,7 +45,7 @@ TEST_SUITE("extract_filename") std::string result = xcpp::extract_filename(argc, const_cast(arguments)); REQUIRE(result == "filename.txt"); - REQUIRE(argc == 3); + REQUIRE(argc == 2); } }