CPP: Add test case.

This commit is contained in:
Geoffrey White
2018-11-05 14:19:16 +00:00
parent dc3c5a684c
commit b4adfec2ef
2 changed files with 22 additions and 0 deletions

View File

@@ -3,3 +3,4 @@
| test.cpp:83:10:83:15 | ... == ... | Self comparison. |
| test.cpp:90:10:90:15 | ... == ... | Self comparison. |
| test.cpp:118:7:118:32 | ... != ... | Self comparison. |
| test.cpp:145:2:145:30 | ... == ... | Self comparison. |

View File

@@ -123,3 +123,24 @@ int isSmallEnough(unsigned long long x) {
// get compiled away on others.
return x == (size_t)x && x == (u64)x; // GOOD
}
#define markRange(str, x, y) \
if ((x) == (y)) { \
str[x] = '^'; \
} else { \
int i; \
str[x] = '<'; \
for (i = x + 1; i < y; i++) { \
str[i] = '-'; \
} \
str[y] = '>'; \
}
void useMarkRange(int offs) {
char buffer[100];
markRange(buffer, 10, 20);
markRange(buffer, 30, 30);
markRange(buffer, offs, offs + 10);
markRange(buffer, offs, offs); // GOOD (comparison is in the macro) [FALSE POSITIVE]
}