Added some unit tests to improve test coverage in cmdlineparser

This commit is contained in:
PKEuS 2013-08-15 11:09:40 +02:00
parent f95b29db06
commit dc439f65f8
1 changed files with 36 additions and 0 deletions

View File

@ -20,6 +20,7 @@
#include "cmdlineparser.h"
#include "settings.h"
#include "redirect.h"
#include "timer.h"
class TestCmdlineParser : public TestFixture {
public:
@ -74,6 +75,7 @@ private:
TEST_CASE(enabledInternal);
#endif
TEST_CASE(enabledMultiple);
TEST_CASE(inconclusive);
TEST_CASE(errorExitcode);
TEST_CASE(errorExitcodeMissing);
TEST_CASE(errorExitcodeStr);
@ -94,6 +96,7 @@ private:
TEST_CASE(stdposix);
TEST_CASE(stdc99);
TEST_CASE(stdcpp11);
TEST_CASE(platform);
TEST_CASE(suppressionsOld); // TODO: Create and test real suppression file
TEST_CASE(suppressions);
TEST_CASE(suppressionsNoFile);
@ -112,6 +115,8 @@ private:
TEST_CASE(xmlver2both2);
TEST_CASE(xmlverunknown);
TEST_CASE(xmlverinvalid);
TEST_CASE(doc);
TEST_CASE(showtime);
TEST_CASE(errorlist1);
TEST_CASE(errorlistverbose1);
TEST_CASE(errorlistverbose2);
@ -534,6 +539,14 @@ private:
ASSERT(settings.isEnabled("missingInclude"));
}
void inconclusive() {
REDIRECT;
const char *argv[] = {"cppcheck", "--inconclusive"};
settings.inconclusive = false;
ASSERT(defParser.ParseFromArgs(2, argv));
ASSERT_EQUALS(true, settings.inconclusive);
}
void errorExitcode() {
REDIRECT;
const char *argv[] = {"cppcheck", "--error-exitcode=5", "file.cpp"};
@ -690,6 +703,14 @@ private:
ASSERT(settings.standards.cpp == Standards::CPP11);
}
void platform() {
REDIRECT;
const char *argv[] = {"cppcheck", "--platform=win64", "file.cpp"};
settings.platform(Settings::Unspecified);
ASSERT(defParser.ParseFromArgs(3, argv));
ASSERT(settings.platformType == Settings::Win64);
}
void suppressionsOld() {
// TODO: Fails because there is no suppr.txt file!
REDIRECT;
@ -858,6 +879,21 @@ private:
ASSERT_EQUALS(false, defParser.ParseFromArgs(4, argv));
}
void doc() {
REDIRECT;
const char *argv[] = {"cppcheck", "--doc"};
ASSERT(defParser.ParseFromArgs(2, argv));
ASSERT(defParser.ExitAfterPrinting());
}
void showtime() {
REDIRECT;
const char *argv[] = {"cppcheck", "--showtime=summary"};
settings._showtime = SHOWTIME_NONE;
ASSERT(defParser.ParseFromArgs(2, argv));
ASSERT(settings._showtime == SHOWTIME_SUMMARY);
}
void errorlist1() {
REDIRECT;
const char *argv[] = {"cppcheck", "--errorlist"};