aboutsummaryrefslogtreecommitdiffstats
path: root/sorting.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2023-02-05 12:11:30 +0100
committerMattias Andrée <maandree@kth.se>2023-02-05 12:16:17 +0100
commit4df563948b0c4086c7be5cb0ef453570d2ec40a0 (patch)
tree4e41e547491d6de7d4be530d45347267358d3d2e /sorting.c
parentAdd draw_linear_bezier_reference (diff)
downloadlibrifunktionsteckensnittsglyfrasteriseringsprogrambiblioteket-4df563948b0c4086c7be5cb0ef453570d2ec40a0.tar.gz
librifunktionsteckensnittsglyfrasteriseringsprogrambiblioteket-4df563948b0c4086c7be5cb0ef453570d2ec40a0.tar.bz2
librifunktionsteckensnittsglyfrasteriseringsprogrambiblioteket-4df563948b0c4086c7be5cb0ef453570d2ec40a0.tar.xz
Add tests and documentation
Signed-off-by: Mattias Andrée <maandree@kth.se>
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;
}