You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
However, one of the test cases fails and I'm wondering if it might in fact be an erroneous test case?
/** Comparisons of numbers on opposite sides of 0 */
@Test
public void opposite() {
assertFalse(nearlyEqual(1.000000001f, -1.0f));
assertFalse(nearlyEqual(-1.0f, 1.000000001f));
assertFalse(nearlyEqual(-1.000000001f, 1.0f));
assertFalse(nearlyEqual(1.0f, -1.000000001f));
assertTrue(nearlyEqual(10 * Float.MIN_VALUE, 10 * -Float.MIN_VALUE)); //<-- inverted assert?
assertFalse(nearlyEqual(10000 * Float.MIN_VALUE, 10000 * -Float.MIN_VALUE));
}
The second to last test; nearlyEqual(10 * MIN_VALUE, 10 * -MIN_VALUE) , evaluates to false for me. Is there something weird going on in my end, or should that test actually be assertFalse?
My Google Test case for reference:
TEST(NearlyEqual, opposite) {
static constexpr auto MIN = std::numeric_limits<float>::min();
EXPECT_FALSE(nearly_equal(1.000000001f, -1.0f));
EXPECT_FALSE(nearly_equal(-1.0f, 1.000000001f));
EXPECT_FALSE(nearly_equal(-1.000000001f, 1.0f));
EXPECT_FALSE(nearly_equal(1.0f, -1.000000001f));
EXPECT_TRUE(nearly_equal(10.0f * MIN, 10.0f * -MIN)); //this fails for me
EXPECT_FALSE(nearly_equal(10000.0f * MIN, 10000.0f * -MIN));
}
I am using the same epsilon (0.00001f) as you, and I'm not compiling with the fast floating point flag.
The text was updated successfully, but these errors were encountered:
Hi!
I'm currently porting your nearlyEqual-implementation and test cases to C++. Hoping to send you the results in a day or two.
However, one of the test cases fails and I'm wondering if it might in fact be an erroneous test case?
The second to last test;
nearlyEqual(10 * MIN_VALUE, 10 * -MIN_VALUE)
, evaluates tofalse
for me. Is there something weird going on in my end, or should that test actually beassertFalse
?My Google Test case for reference:
I am using the same epsilon (
0.00001f
) as you, and I'm not compiling with the fast floating point flag.The text was updated successfully, but these errors were encountered: