summaryrefslogtreecommitdiff
path: root/tools/test.h
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2012-01-23 20:56:12 +0100
committerBent Bisballe Nyeng <deva@aasimon.org>2012-01-23 20:56:12 +0100
commitb18c052a811b56a4974f50ac6ad4817d7c98fed4 (patch)
tree7c38e9b529a736a00b46b5ed241339ad38d5c3b0 /tools/test.h
parente4f67b8acb4674a6aa3652ae4255bbc34fff3b37 (diff)
More verbose float comparison.
Diffstat (limited to 'tools/test.h')
-rw-r--r--tools/test.h34
1 files changed, 29 insertions, 5 deletions
diff --git a/tools/test.h b/tools/test.h
index f470162..c6ad38e 100644
--- a/tools/test.h
+++ b/tools/test.h
@@ -157,12 +157,36 @@
} \
}
+#define TEST_EQUAL_PTR(x, y, fmt...) { \
+ TEST_BASE(fmt); \
+ void *i1 = x; \
+ void *i2 = y; \
+ fprintf(stderr, "Comparing: \"%p\" == \"%p\"\n", i1, i2); \
+ if(i1 == i2) { \
+ TEST_OK(#x" and "#y" are equal."); \
+ } else { \
+ TEST_FAIL(#x" and "#y" are not equal."); \
+ } \
+ }
+
+#define TEST_NOTEQUAL_PTR(x, y, fmt...) { \
+ TEST_BASE(fmt); \
+ void *i1 = x; \
+ void *i2 = y; \
+ fprintf(stderr, "Comparing: \"%p\" != \"%p\"\n", i1, i2); \
+ if(i1 != i2) { \
+ TEST_OK(#x" and "#y" are not equal."); \
+ } else { \
+ TEST_FAIL(#x" and "#y" are equal."); \
+ } \
+ }
+
#define TEST_EQUAL_FLOAT(x, y, fmt...) { \
TEST_BASE(fmt); \
double d1 = x; \
double d2 = y; \
- fprintf(stderr, "Comparing: \"%f\" == \"%f\"\n", d1, d2); \
- if(d1 == d2) { \
+ fprintf(stderr, "Comparing: \"%.64f\" == \"%.64f\"\n", d1, d2); \
+ if(d1 >= d2 && d1 <= d2) { \
TEST_OK(#x" and "#y" are equal."); \
} else { \
TEST_FAIL(#x" and "#y" are not equal."); \
@@ -173,7 +197,7 @@
TEST_BASE(fmt); \
double d1 = x; \
double d2 = y; \
- fprintf(stderr, "Comparing: \"%f\" != \"%f\"\n", d1, d2); \
+ fprintf(stderr, "Comparing: \"%.64f\" != \"%.64f\"\n", d1, d2); \
if(d1 != d2) { \
TEST_OK(#x" and "#y" are not equal."); \
} else { \
@@ -209,7 +233,7 @@
TEST_BASE(fmt); \
double d1 = x; \
double d2 = y; \
- fprintf(stderr, "Comparing: \"%f\" > \"%f\"\n", d1, d2); \
+ fprintf(stderr, "Comparing: \"%.64f\" > \"%.64f\"\n", d1, d2); \
if(d1 > d2) { \
TEST_OK(#x" are greater than "#y"."); \
} else { \
@@ -221,7 +245,7 @@
TEST_BASE(fmt); \
double d1 = x; \
double d2 = y; \
- fprintf(stderr, "Comparing: \"%f\" < \"%f\"\n", d1, d2); \
+ fprintf(stderr, "Comparing: \"%.64f\" < \"%.64f\"\n", d1, d2); \
if(d1 < d2) { \
TEST_OK(#x" are less than "#y"."); \
} else { \