CPP: Add test cases.

This commit is contained in:
Geoffrey White
2019-04-02 16:58:23 +01:00
parent 02f4695a5b
commit b3fd7ab757
2 changed files with 39 additions and 0 deletions

View File

@@ -11,6 +11,12 @@
| printf1.h:45:18:45:20 | ull | This argument should be of type 'unsigned int' but is of type 'unsigned long long' |
| printf1.h:46:18:46:20 | ull | This argument should be of type 'unsigned int' but is of type 'unsigned long long' |
| printf1.h:47:19:47:21 | ull | This argument should be of type 'unsigned int' but is of type 'unsigned long long' |
| printf1.h:112:18:112:19 | ld | This argument should be of type 'double' but is of type 'long double' |
| printf1.h:113:17:113:17 | d | This argument should be of type 'long double' but is of type 'double' |
| printf1.h:122:17:122:19 | lli | This argument should be of type 'int' but is of type 'long long' |
| printf1.h:123:17:123:18 | li | This argument should be of type 'int' but is of type 'long' |
| printf1.h:132:17:132:20 | ulli | This argument should be of type 'unsigned int' but is of type 'unsigned long long' |
| printf1.h:133:17:133:19 | uli | This argument should be of type 'unsigned int' but is of type 'unsigned long' |
| real_world.h:61:21:61:22 | & ... | This argument should be of type 'int *' but is of type 'short *' |
| real_world.h:62:22:62:23 | & ... | This argument should be of type 'short *' but is of type 'int *' |
| real_world.h:63:22:63:24 | & ... | This argument should be of type 'short *' but is of type 'unsigned int *' |

View File

@@ -101,3 +101,36 @@ void fun1(unsigned char* a, unsigned char* b) {
printf("%td\n", pdt); // GOOD
printf("%td\n", a-b); // GOOD
}
void extensions()
{
{
long double ld;
double d;
printf("%Lg", ld); // GOOD
printf("%llg", ld); // GOOD (nonstandard equivalent to %Lg) [FALSE POSITIVE]
printf("%Lg", d); // BAD (should be %g)
printf("%llg", d); // BAD (should be %g) [NOT DETECTED]
}
{
long long int lli;
long int li;
printf("%lld", lli); // GOOD
printf("%Ld", lli); // GOOD (nonstandard equivalent to %lld) [FALSE POSITIVE]
printf("%Ld", li); // BAD (should be %ld)
printf("%lld", li); // BAD (should be %ld) [NOT DETECTED]
}
{
unsigned long long int ulli;
unsigned long int uli;
printf("%llu", ulli); // GOOD
printf("%Lu", ulli); // GOOD (nonstandard equivalent to %llu) [FALSE POSITIVE]
printf("%Lu", uli); // BAD (should be %lu)
printf("%llu", uli); // BAD (should be %lu) [NOT DETECTED]
}
}