summaryrefslogtreecommitdiff
path: root/tests/cmp.c
diff options
context:
space:
mode:
Diffstat (limited to 'tests/cmp.c')
-rw-r--r--tests/cmp.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/tests/cmp.c b/tests/cmp.c
new file mode 100644
index 0000000..943402f
--- /dev/null
+++ b/tests/cmp.c
@@ -0,0 +1,47 @@
+#include "../src/cmp.c"
+
+#include <assert.h>
+#include <stdint.h>
+
+#include "../src/testing.h"
+
+
+
+static void
+test_cmp_size(void) {
+ test_start("cmp_size()");
+
+ {
+ testing("equal values");
+
+ assert(cmp_size(0U, 0U) == Comparison_EQUAL);
+ assert(cmp_size(SIZE_MAX, SIZE_MAX) == Comparison_EQUAL);
+ assert(cmp_size(123U, 122U + 1U) == Comparison_EQUAL);
+
+ test_ok();
+ }
+ {
+ testing("greater values");
+
+ assert(cmp_size(1U, 0U) == Comparison_GREATER);
+ assert(cmp_size(1234U, 1222U) == Comparison_GREATER);
+ assert(cmp_size(SIZE_MAX, SIZE_MAX - 1U) == Comparison_GREATER);
+
+ test_ok();
+ }
+ {
+ testing("lesser values");
+
+ assert(cmp_size(0U, 1U) == Comparison_LESSER);
+ assert(cmp_size(12U, 34U) == Comparison_LESSER);
+ assert(cmp_size(0U, SIZE_MAX) == Comparison_LESSER);
+
+ test_ok();
+ }
+}
+
+int
+main(void) {
+ test_cmp_size();
+ return 0;
+}