aboutsummaryrefslogtreecommitdiffstats
path: root/sorting.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--sorting.c28
1 files changed, 27 insertions, 1 deletions
diff --git a/sorting.c b/sorting.c
index e4bfdaf..2738081 100644
--- a/sorting.c
+++ b/sorting.c
@@ -18,7 +18,33 @@ doublepcmp(const void *avp, const void *bvp)
int
main(void)
{
- return 0; /* TODO add test */
+ double a, b;
+
+ a = 1.0, b = 1.0;
+ ASSERT(doublepcmp(&a, &b) == 0);
+ ASSERT(doublepcmp(&b, &a) == -doublepcmp(&a, &b));
+
+ a = -1.0, b = 1.0;
+ ASSERT(doublepcmp(&a, &b) == -1);
+ ASSERT(doublepcmp(&b, &a) == -doublepcmp(&a, &b));
+
+ a = 1.0, b = -1.0;
+ ASSERT(doublepcmp(&a, &b) == +1);
+ ASSERT(doublepcmp(&b, &a) == -doublepcmp(&a, &b));
+
+ a = 0.0, b = 0.0;
+ ASSERT(doublepcmp(&a, &b) == 0);
+ ASSERT(doublepcmp(&b, &a) == -doublepcmp(&a, &b));
+
+ a = -1.0, b = 2.5;
+ ASSERT(doublepcmp(&a, &b) == -1);
+ ASSERT(doublepcmp(&b, &a) == -doublepcmp(&a, &b));
+
+ a = 1.0, b = -2.5;
+ ASSERT(doublepcmp(&a, &b) == +1);
+ ASSERT(doublepcmp(&b, &a) == -doublepcmp(&a, &b));
+
+ return 0;
}