CPP: Add a few more test cases.

This commit is contained in:
Geoffrey White
2019-01-09 14:55:04 +00:00
parent 82e54568a5
commit 11013b0ec6
2 changed files with 37 additions and 0 deletions

View File

@@ -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. |

View File

@@ -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]
}