diff options
-rw-r--r-- | complex.c | 1 | ||||
-rw-r--r-- | main.c | 11 | ||||
-rw-r--r-- | math.c | 16 | ||||
-rw-r--r-- | stddef.c | 4 | ||||
-rw-r--r-- | stdlib.c | 2 |
5 files changed, 31 insertions, 3 deletions
@@ -13,6 +13,7 @@ void test_complex_h(void) test_true(cimag(I) == 1); test_true(creal(_Complex_I) == 0); test_true(cimag(_Complex_I) == 1); + test_double(I * I, -1); #ifdef _Imaginary_I test_true(creal(_Imaginary_I) == 0); @@ -68,9 +68,20 @@ static struct { { "wctype", test_wctype_h, 1 }, }; +void show_tests(void) +{ + size_t i; + printf("Valid tests: %s", tests[0].name); + for (i = 1; i < sizeof(tests) / sizeof(tests[0]); i++) { + printf(", %s", tests[i].name); + } + printf("\n"); +} + void usage(const char *argv0) { printf("Usage: %s [-v] [test...]\n", argv0); + show_tests(); } int main(int argc, char *argv[]) @@ -6,6 +6,13 @@ void test_math_h(void) int iexp = 1; double iptr = 0; + long double ldm1 = -1.0; + double dm1 = -1.0; + float fm1 = -1.0; + long double ld1 = 1.0; + double d1 = 1.0; + float f1 = 1.0; + testing_header("math.h"); test_defined(HUGE_VAL); @@ -33,5 +40,14 @@ void test_math_h(void) test_double(floor(0.9), 0); test_double(fmod(1, 1), 0); + #if defined __STDC_VERSION__ && 19901 <= __STDC_VERSION__ + test_int_equals(signbit(ldm1), 1); + test_int_equals(signbit(dm1), 1); + test_int_equals(signbit(fm1), 1); + test_int_equals(signbit(ld1), 0); + test_int_equals(signbit(d1), 0); + test_int_equals(signbit(f1), 0); + #endif + testing_end(); } @@ -16,9 +16,7 @@ void test_stddef_h(void) test_true(NULL == 0); - /* - test_int_eq(offsetof(struct s, b), 1); - */ + test_int_equals(offsetof(struct s, b), 1); testing_end(); } @@ -30,5 +30,7 @@ void test_stdlib_h(void) test_long_equals(strtol("zzzzzzzzzzzzzzzzzzzz", NULL, 36), LONG_MAX); test_long_equals(strtol("-zzzzzzzzzzzzzzzzzzzz", NULL, 36), LONG_MIN); + test_double(strtod("1.5", NULL), 1.5); + testing_end(); } |