Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions cli/cmdlineparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1151,6 +1151,11 @@ CmdLineParser::Result CmdLineParser::parseFromArgs(int argc, const char* const a
mLogger.printError("invalid --premium option '" + (p2.empty() ? p : p2) + "'.");
return Result::Fail;
}
if (p2 == "cert-c-int-precision") {
int tmp;
if (!parseNumberArg(argv[i], 31, tmp, true))
return Result::Fail;
}
mSettings.premiumArgs += "--" + p;
if (isCodingStandard) {
// All checkers related to the coding standard should be enabled. The coding standards
Expand Down
8 changes: 8 additions & 0 deletions test/testcmdlineparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1621,6 +1621,14 @@ class TestCmdlineParser : public TestFixture {
ASSERT_EQUALS("--cert-c-int-precision=12", settings->premiumArgs);
}

void premiumOptionsCertCIntPrecisionInvalid() {
REDIRECT;
asPremium();
const char * const argv[] = {"cppcheck", "--premium-cert-c-int-precision=abc", "file.c"};
ASSERT_EQUALS_ENUM(CmdLineParser::Result::Fail, parseFromArgs(argv));
ASSERT_EQUALS("cppcheck: error: argument to '--premium-cert-c-int-precision=' is not valid - not an integer (invalid_argument).\n", logger->str());
}

void premiumOptionsLicenseFile() {
REDIRECT;
asPremium();
Expand Down
Loading