C++: Add FP tests.

This commit is contained in:
Mathias Vorreiter Pedersen
2024-11-14 16:12:17 +00:00
parent 4ca6c80eb5
commit a40c1d50b8
2 changed files with 36 additions and 0 deletions

View File

@@ -553,3 +553,27 @@ void switch_cases(const char *data) {
break;
}
}
void test_scanf_compared_right_away() {
int i;
bool success = scanf("%d", &i) == 1;
if(success) {
use(i); // GOOD [FALSE POSITIVE]
}
}
void test_scanf_compared_in_conjunct_right(bool b) {
int i;
bool success = b && scanf("%d", &i) == 1;
if(success) {
use(i); // GOOD [FALSE POSITIVE]
}
}
void test_scanf_compared_in_conjunct_left(bool b) {
int i;
bool success = scanf("%d", &i) == 1 && b;
if(success) {
use(i); // GOOD [FALSE POSITIVE]
}
}