CPP: Test wrapped rounding functions more thoroughly.

This commit is contained in:
Geoffrey White
2019-01-10 14:27:30 +00:00
parent 4f002291c5
commit 207c4d365a
2 changed files with 15 additions and 2 deletions

View File

@@ -7,3 +7,4 @@
| 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:130:10:130:17 | call to myRound3 | Return value of type double is implicitly converted to int here. |

View File

@@ -106,14 +106,26 @@ int test2(double v, double w, int n)
};
}
double myRound(double v)
double myRound1(double v)
{
return round(v);
}
double myRound2(double v)
{
double result = round(v);
return result;
}
double myRound3(double v)
{
return (v > 0) ? round(v) : 0;
}
void test3()
{
int i = myRound(1.5); // GOOD
int i = myRound1(1.5); // GOOD
int j = myRound2(2.5); // GOOD
int k = myRound3(3.5); // GOOD [FALSE POSITIVE]
}