Whatever I had before renaming.

This commit is contained in:
Peter Goodman
2017-11-01 12:14:22 -04:00
parent a46e06b03b
commit f7f029965b
2 changed files with 12 additions and 3 deletions
+10 -2
View File
@@ -16,16 +16,24 @@
#include <mctest/McUnit.hpp>
MCTEST_NOINLINE int ident1(int x) {
return x;
}
MCTEST_NOINLINE int ident2(int x) {
return x;
}
TEST(BoundsCheck, YIsAlwaysPositive) {
int x = McTest_IntInRange(-10, 10);
int y = x * x;
int y = ident1(x) * ident2(x);
ASSERT_GE(y, 0)
<< "Found y=" << y << " was not always positive.";
}
TEST(BoundsCheck, YIsAlwaysPositive_CanFail) {
int x = McTest_Int();
int y = x * x; // Can overflow!
int y = ident1(x) * ident2(x); // Can overflow!
ASSERT_GE(y, 0)
<< "Found y=" << y << " was not always positive.";
}