diff options
author | Mattias Andrée <maandree@kth.se> | 2023-02-05 12:11:30 +0100 |
---|---|---|
committer | Mattias Andrée <maandree@kth.se> | 2023-02-05 12:16:17 +0100 |
commit | 4df563948b0c4086c7be5cb0ef453570d2ec40a0 (patch) | |
tree | 4e41e547491d6de7d4be530d45347267358d3d2e /sorting.c | |
parent | Add draw_linear_bezier_reference (diff) | |
download | librifunktionsteckensnittsglyfrasteriseringsprogrambiblioteket-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.c | 28 |
1 files changed, 27 insertions, 1 deletions
@@ -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; } |