Skip to content

Commit

Permalink
Add UT
Browse files Browse the repository at this point in the history
  • Loading branch information
samopolacek committed Jul 28, 2023
1 parent 50d1c87 commit efa8e0f
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions test/testcmdlineparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,9 @@ class TestCmdlineParser : public TestFixture {
TEST_CASE(undefs_noarg3);
TEST_CASE(undefs);
TEST_CASE(undefs2);

TEST_CASE(cppcheckBuildDirExistent);
TEST_CASE(cppcheckBuildDirNonExistent);
}


Expand Down Expand Up @@ -1947,6 +1950,22 @@ class TestCmdlineParser : public TestFixture {
ASSERT_EQUALS(false, defParser.parseFromArgs(4, argv));
ASSERT_EQUALS("cppcheck: error: argument to '-U' is missing.\n", GET_REDIRECT_OUTPUT);
}

void cppcheckBuildDirExistent() {
REDIRECT;
const char * const argv[] = {"cppcheck", "--cppcheck-build-dir=/tmp"};
ASSERT_EQUALS(true, defParser.parseFromArgs(2, argv));
ASSERT_EQUALS("", GET_REDIRECT_OUTPUT);
ASSERT_EQUALS("", GET_REDIRECT_ERROUT);
}

void cppcheckBuildDirNonExistent() {
REDIRECT;
const char * const argv[] = {"cppcheck", "--cppcheck-build-dir=/non-existent-path"};
ASSERT_EQUALS(false, defParser.parseFromArgs(2, argv));
ASSERT_EQUALS("cppcheck: error: Directory '/non-existent-path' specified by --cppcheck-build-dir argument has to be existent.\n", GET_REDIRECT_OUTPUT);
ASSERT_EQUALS("", GET_REDIRECT_ERROUT);
}
};

REGISTER_TEST(TestCmdlineParser)

0 comments on commit efa8e0f

Please sign in to comment.