mirror of
https://github.com/github/codeql.git
synced 2026-05-03 04:39:29 +02:00
CPP: Add a few more test cases.
This commit is contained in:
@@ -4,3 +4,9 @@
|
||||
| test.cpp:40:13:40:21 | call to getDouble | Return value of type double is implicitly converted to int here. |
|
||||
| test.cpp:43:6:43:12 | call to getMyLD | Return value of type long double is implicitly converted to bool here. |
|
||||
| test.cpp:45:13:45:19 | call to getMyLD | Return value of type long double is implicitly converted to int here. |
|
||||
| test.cpp:97:10:97:12 | call to pow | Return value of type double is implicitly converted to int here. |
|
||||
| test.cpp:99:10:99:12 | call to pow | Return value of type double is implicitly converted to int here. |
|
||||
| test.cpp:101:10:101:12 | call to pow | Return value of type double is implicitly converted to int here. |
|
||||
| test.cpp:103:10:103:12 | call to pow | Return value of type double is implicitly converted to int here. |
|
||||
| test.cpp:105:10:105:12 | call to pow | Return value of type double is implicitly converted to int here. |
|
||||
| test.cpp:118:10:118:16 | call to myRound | Return value of type double is implicitly converted to int here. |
|
||||
|
||||
@@ -86,3 +86,34 @@ void test1()
|
||||
setPosFloat(round(getDouble()));
|
||||
}
|
||||
}
|
||||
|
||||
double pow(double x, double y);
|
||||
|
||||
int test2(double v, double w, int n)
|
||||
{
|
||||
switch (n)
|
||||
{
|
||||
case 1:
|
||||
return pow(2, v); // GOOD [FALSE POSITIVE]
|
||||
case 2:
|
||||
return pow(10, v); // GOOD [FALSE POSITIVE]
|
||||
case 3:
|
||||
return pow(2.5, v); // BAD
|
||||
case 4:
|
||||
return pow(v, 2); // BAD
|
||||
case 5:
|
||||
return pow(v, w); // BAD
|
||||
};
|
||||
}
|
||||
|
||||
double myRound(double v)
|
||||
{
|
||||
double result = round(v);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void test3()
|
||||
{
|
||||
int i = myRound(1.5); // GOOD [FALSE POSITIVE]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user