C++: Add test cases.

This commit is contained in:
Geoffrey White
2020-05-06 16:39:44 +01:00
parent b2f1008a00
commit c8524522c8
2 changed files with 23 additions and 1 deletions

View File

@@ -363,4 +363,22 @@ int callCommand(void)
if (tmp == 1) // tmp could have been modified by the call.
return 1;
return 0;
}
}
int shifts(void)
{
unsigned int x = 3;
if (x >> 1 >= 1) {} // always true [BAD MESSAGE]
if (x >> 1 >= 2) {} // always false [BAD MESSAGE]
if (x >> 1 == 1) {} // always true [INCORRECT MESSAGE]
}
int bitwise_ands()
{
unsigned int x = 0xFF;
if ((x & 2) >= 1) {}
if ((x & 2) >= 2) {}
if ((x & 2) >= 3) {} // always false
}

View File

@@ -38,5 +38,9 @@
| PointlessComparison.c:303:9:303:14 | ... >= ... | Comparison is always false because c <= 0. |
| PointlessComparison.c:312:9:312:14 | ... >= ... | Comparison is always false because c <= 0. |
| PointlessComparison.c:337:14:337:21 | ... >= ... | Comparison is always true because x >= 0. |
| PointlessComparison.c:372:6:372:16 | ... >= ... | Comparison is always true because ... >> ... >= 1.5. |
| PointlessComparison.c:373:6:373:16 | ... >= ... | Comparison is always false because ... >> ... <= 1.5. |
| PointlessComparison.c:374:6:374:16 | ... == ... | Comparison is always false because ... >> ... >= 1.5. |
| PointlessComparison.c:383:6:383:17 | ... >= ... | Comparison is always false because ... & ... <= 2. |
| RegressionTests.cpp:57:7:57:22 | ... <= ... | Comparison is always true because * ... <= 4294967295. |
| Templates.cpp:9:10:9:24 | ... <= ... | Comparison is always true because local <= 32767. |