/* Test non-NaN-resulting library calls. */ int test_defined(void) { int errs = 0; /* * Attempt to prevent constant folding and optimization of library * function bodies (when statically linked). */ volatile double x; volatile double y; volatile double z; printf("Checking lib calls that take NaN, etc, but return non-NaN.\n"); x = 0.0; y = 1.0; errs += CHECK_EQ_DOUBLE(pow(x, x), y); z = NAN; errs += CHECK_EQ_DOUBLE(pow(z, x), y); z = INFINITY; errs += CHECK_EQ_DOUBLE(pow(z, x), y); errs += CHECK_INF(sqrt(z)); x = -0.0; errs += CHECK_EQ_DOUBLE(sqrt(x), x); x = INFINITY; y = 2.0; errs += CHECK_INF(pow(x, y)); x = 0.0; y = -INFINITY; errs += ASSERT_TRUE(log(x) == y); return errs; }
int test_constants() { int errs = 0; errs += CHECK_NAN(NAN); printf("Print out of NaN: %f\n", NAN); errs += CHECK_INF(INFINITY); printf("Print out of Infinity: %f\n", INFINITY); errs += CHECK_INF(1.0/0.0); return errs; }
int test_constants(void) { int errs = 0; /* Attempt to prevent constant folding */ volatile double x = 1.0; volatile double y = 0.0; errs += CHECK_NAN(NAN); printf("Print out of NaN: %f\n", NAN); errs += CHECK_INF(INFINITY); printf("Print out of Infinity: %f\n", INFINITY); errs += CHECK_INF(x/y); return errs; }
int test_compares(void) { int errs = 0; /* Attempt to prevent constant folding */ volatile double x; volatile double y; printf("Comparing float constants\n"); x = NAN; errs += ASSERT_TRUE(x != x); errs += ASSERT_TRUE(isunordered(x, x)); errs += CHECK_NAN(x + 3.0f); errs += CHECK_NAN(x + x); errs += CHECK_NAN(x - x); errs += CHECK_NAN(x / x); errs += CHECK_NAN(0.0 / x); errs += CHECK_NAN(0.0 * x); errs += ASSERT_FALSE(x == x); x = INFINITY; errs += ASSERT_TRUE(x == x); errs += ASSERT_FALSE(x == -x); errs += ASSERT_TRUE(-x == -x); errs += ASSERT_TRUE(x + 100.0 == x); errs += ASSERT_TRUE(x - 100.0 == x); errs += ASSERT_TRUE(-x - 100.0 == -x); errs += ASSERT_TRUE(-x + 100.0 == -x); errs += ASSERT_TRUE(-x < x); errs += ASSERT_FALSE(-x > x); y = 0.0; errs += CHECK_NAN(y * x); errs += CHECK_NAN(y / y); errs += CHECK_NAN(x / x); errs += CHECK_NAN(x - x); y = NAN; errs += CHECK_NAN(x * y); x = INFINITY; errs += CHECK_INF(x + x); x = 1.0; y = 0.0; errs += CHECK_INF(x / y); x = INFINITY; errs += ASSERT_FALSE(isfinite(x)); x = NAN; errs += ASSERT_FALSE(isfinite(x)); return errs; }
/* Test non-NaN-resulting library calls. */ int test_defined() { int errs = 0; printf("Checking lib calls that take NaN, etc, but return non-NaN.\n"); errs += CHECK_EQ_DOUBLE(pow(0.0, 0.0), 1.0); errs += CHECK_EQ_DOUBLE(pow(NAN, 0.0), 1.0); errs += CHECK_EQ_DOUBLE(pow(INFINITY, 0.0), 1.0); errs += CHECK_INF(sqrt(INFINITY)); errs += CHECK_EQ_DOUBLE(sqrt(-0.0), -0.0); errs += CHECK_INF(pow(INFINITY, 2.0)); errs += ASSERT_TRUE(log(0) == -INFINITY); return errs; }
int test_compares() { int errs = 0; printf("Comparing float constants\n"); errs += ASSERT_TRUE(NAN != NAN); errs += ASSERT_TRUE(isunordered(NAN, NAN)); errs += CHECK_NAN(NAN + 3.0f); errs += CHECK_NAN(NAN + NAN); errs += CHECK_NAN(NAN - NAN); errs += CHECK_NAN(NAN / NAN); errs += CHECK_NAN(0.0 / NAN); errs += CHECK_NAN(0.0 * NAN); errs += ASSERT_FALSE(NAN == NAN); errs += ASSERT_TRUE(INFINITY == INFINITY); errs += ASSERT_FALSE(INFINITY == -INFINITY); errs += ASSERT_TRUE(-INFINITY == -INFINITY); errs += ASSERT_TRUE(INFINITY + 100.0 == INFINITY); errs += ASSERT_TRUE(INFINITY - 100.0 == INFINITY); errs += ASSERT_TRUE(-INFINITY - 100.0 == -INFINITY); errs += ASSERT_TRUE(-INFINITY + 100.0 == -INFINITY); errs += ASSERT_TRUE(-INFINITY < INFINITY); errs += ASSERT_FALSE(-INFINITY > INFINITY); errs += CHECK_NAN(0.0 * INFINITY); errs += CHECK_NAN(0.0 / 0.0); errs += CHECK_NAN(INFINITY / INFINITY); errs += CHECK_NAN(INFINITY - INFINITY); errs += CHECK_NAN(INFINITY * NAN); errs += CHECK_INF(INFINITY + INFINITY); errs += CHECK_INF(1.0 / 0.0); errs += ASSERT_FALSE(isfinite(INFINITY)); errs += ASSERT_FALSE(isfinite(NAN)); return errs; }