Skip to content

Commit

Permalink
[TEST] Split version_check - option_off test.
Browse files Browse the repository at this point in the history
  • Loading branch information
smehringer committed Dec 17, 2021
1 parent c7ca854 commit 652e7dc
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions test/unit/detail/version_check_test.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -342,9 +342,12 @@ TEST_F(version_check, option_off)
EXPECT_FALSE(std::filesystem::exists(app_timestamp_filename())) << app_timestamp_filename();

EXPECT_TRUE(remove_files_from_path()); // clear files again
}

TEST_F(version_check, option_off_with_help_page)
{
// Version check option always needs to be parsed, even if special formats get selected
const char * argv2[4] = {app_name.c_str(), "-h", OPTION_VERSION_CHECK, OPTION_OFF};
const char * argv[4] = {app_name.c_str(), "-h", OPTION_VERSION_CHECK, OPTION_OFF};

std::string previous_value{};
if (char * env = std::getenv("SHARG_NO_VERSION_CHECK"))
Expand All @@ -353,7 +356,7 @@ TEST_F(version_check, option_off)
unsetenv("SHARG_NO_VERSION_CHECK");
}

sharg::argument_parser parser{app_name, 4, argv2};
sharg::argument_parser parser{app_name, 4, argv};
parser.info.version = "2.3.4";

EXPECT_EXIT(parser.parse(), ::testing::ExitedWithCode(EXIT_SUCCESS), "");
Expand Down

0 comments on commit 652e7dc

Please sign in to comment.