test that abs,isdigit,strlen are calculated properly

This commit is contained in:
Daniel Marjamäki 2016-10-17 14:16:08 +02:00
parent fae4a4dacf
commit 57c5e0be3a
1 changed files with 23 additions and 0 deletions

View File

@ -3684,3 +3684,26 @@ void invalidPrintfArgType_printf(void)
// cppcheck-suppress invalidPrintfArgType_uint // cppcheck-suppress invalidPrintfArgType_uint
printf("%"PRIi16"\n", n); printf("%"PRIi16"\n", n);
} }
#define AssertAlwaysTrue(C) if (C) {}
void valueFlow(void)
{
const char abc[] = "abc";
int three = 3, minusThree = -3;
int c0='0', ca='a';
// When adding functions below, please sort alphabetically.
// cppcheck-suppress knownConditionTrueFalse
AssertAlwaysTrue(strlen(abc) == 3);
// cppcheck-suppress knownConditionTrueFalse
AssertAlwaysTrue(abs(three) == 3);
// cppcheck-suppress knownConditionTrueFalse
AssertAlwaysTrue(abs(minusThree) == 3);
// cppcheck-suppress knownConditionTrueFalse
AssertAlwaysTrue(isdigit(c0) == 1);
// cppcheck-suppress knownConditionTrueFalse
AssertAlwaysTrue(isdigit(ca) == 0);
}