summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--complex.c1
-rw-r--r--main.c11
-rw-r--r--math.c16
-rw-r--r--stddef.c4
-rw-r--r--stdlib.c2
5 files changed, 31 insertions, 3 deletions
diff --git a/complex.c b/complex.c
index c7bccd5..09ea4f1 100644
--- a/complex.c
+++ b/complex.c
@@ -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);
diff --git a/main.c b/main.c
index bca639f..9dd5b35 100644
--- a/main.c
+++ b/main.c
@@ -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[])
diff --git a/math.c b/math.c
index 5120b93..3cf65e6 100644
--- a/math.c
+++ b/math.c
@@ -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();
}
diff --git a/stddef.c b/stddef.c
index e031867..73f0dfd 100644
--- a/stddef.c
+++ b/stddef.c
@@ -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();
}
diff --git a/stdlib.c b/stdlib.c
index 525a416..c66aa92 100644
--- a/stdlib.c
+++ b/stdlib.c
@@ -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();
}