Improved test coverage: Ensure that passing multiple <id> to --enable works. Check settings.isEnabled("warning").

This commit is contained in:
PKEuS 2013-04-01 04:15:05 -07:00
parent fbe997ca80
commit 7596282cba
1 changed files with 19 additions and 0 deletions

View File

@ -70,6 +70,7 @@ private:
#ifndef NDEBUG
TEST_CASE(enabledInternal);
#endif
TEST_CASE(enabledMultiple);
TEST_CASE(errorExitcode);
TEST_CASE(errorExitcodeMissing);
TEST_CASE(errorExitcodeStr);
@ -477,6 +478,7 @@ private:
CmdLineParser parser(&settings);
ASSERT(parser.ParseFromArgs(3, argv));
ASSERT(settings.isEnabled("style"));
ASSERT(settings.isEnabled("warning"));
ASSERT(settings.isEnabled("unusedFunction"));
ASSERT(settings.isEnabled("missingInclude"));
ASSERT(!settings.isEnabled("internal"));
@ -489,6 +491,7 @@ private:
CmdLineParser parser(&settings);
ASSERT(parser.ParseFromArgs(3, argv));
ASSERT(settings.isEnabled("style"));
ASSERT(settings.isEnabled("warning"));
ASSERT(settings.isEnabled("performance"));
ASSERT(settings.isEnabled("portability"));
ASSERT(!settings.isEnabled("unusedFunction"));
@ -502,6 +505,7 @@ private:
CmdLineParser parser(&settings);
ASSERT(parser.ParseFromArgs(3, argv));
ASSERT(!settings.isEnabled("style"));
ASSERT(!settings.isEnabled("warning"));
ASSERT(settings.isEnabled("performance"));
ASSERT(!settings.isEnabled("portability"));
ASSERT(!settings.isEnabled("unusedFunction"));
@ -515,6 +519,7 @@ private:
CmdLineParser parser(&settings);
ASSERT(parser.ParseFromArgs(3, argv));
ASSERT(!settings.isEnabled("style"));
ASSERT(!settings.isEnabled("warning"));
ASSERT(!settings.isEnabled("performance"));
ASSERT(settings.isEnabled("portability"));
ASSERT(!settings.isEnabled("unusedFunction"));
@ -550,6 +555,20 @@ private:
}
#endif
void enabledMultiple() {
REDIRECT;
const char *argv[] = {"cppcheck", "--enable=missingInclude,portability,warning", "file.cpp"};
settings = Settings();
CmdLineParser parser(&settings);
ASSERT(parser.ParseFromArgs(3, argv));
ASSERT(!settings.isEnabled("style"));
ASSERT(settings.isEnabled("warning"));
ASSERT(!settings.isEnabled("performance"));
ASSERT(settings.isEnabled("portability"));
ASSERT(!settings.isEnabled("unusedFunction"));
ASSERT(settings.isEnabled("missingInclude"));
}
void errorExitcode() {
REDIRECT;
const char *argv[] = {"cppcheck", "--error-exitcode=5", "file.cpp"};