summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakob Kaivo <jkk@ung.org>2019-03-01 20:01:29 -0500
committerJakob Kaivo <jkk@ung.org>2019-03-01 20:01:29 -0500
commit2f08f7cc4b9c7ad2f0a33b5367c2f3fd4ae4ed7e (patch)
treec72dac1efe963cacd53a2ceb893cead697fd2e59
parent47fbd9c2bd6c59b46fcf4c93851192cbb9240ebb (diff)
initial tests for <complex.h>
-rw-r--r--Makefile1
-rw-r--r--complex.c29
-rw-r--r--main.c2
3 files changed, 31 insertions, 1 deletions
diff --git a/Makefile b/Makefile
index 13f953f..d84925d 100644
--- a/Makefile
+++ b/Makefile
@@ -7,6 +7,7 @@ LDFLAGS=-L$(LIBDIR) $(LIBS)
TESTOBJS=main.o \
assert.o \
+ complex.o \
ctype.o \
errno.o \
float.o \
diff --git a/complex.c b/complex.c
new file mode 100644
index 0000000..c7bccd5
--- /dev/null
+++ b/complex.c
@@ -0,0 +1,29 @@
+#if defined __STDC_VERSION__ && \
+ (__STDC_VERSION__ == 199901L || \
+ (20112L <= __STDC_VERSION__ && ! defined __STDC_NO_COMPLEX__))
+#include <complex.h>
+#include "test.h"
+
+void test_complex_h(void)
+{
+ complex double cd;
+ testing_header("complex.h");
+
+ test_true(creal(I) == 0);
+ test_true(cimag(I) == 1);
+ test_true(creal(_Complex_I) == 0);
+ test_true(cimag(_Complex_I) == 1);
+
+ #ifdef _Imaginary_I
+ test_true(creal(_Imaginary_I) == 0);
+ test_true(cimag(_Imaginary_I) == 1);
+ #endif
+
+ testing_end();
+}
+
+#else
+void test_complex_h(void)
+{
+}
+#endif
diff --git a/main.c b/main.c
index 1fda841..fdcad73 100644
--- a/main.c
+++ b/main.c
@@ -40,7 +40,7 @@ int main(int argc, char *argv[])
}
}
- /* test_complex_h(); */
+ test_complex_h();
test_ctype_h();
test_errno_h();
/* test_fenv_h(); */