summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorEuAndreh <eu@euandre.org>2024-06-14 14:07:05 -0300
committerEuAndreh <eu@euandre.org>2024-06-14 14:07:05 -0300
commitf28724811ceea6b95b471774665845c916626d68 (patch)
treec7f4fa1d88a0216e84bbbfaee20d3c6008619c61 /tests
parentsrc/trace.h: Init tracing functions (diff)
downloadpindaiba-f28724811ceea6b95b471774665845c916626d68.tar.gz
pindaiba-f28724811ceea6b95b471774665845c916626d68.tar.xz
src/cmp.{c,h}: Add minimal implementation of cmp_size()
Diffstat (limited to 'tests')
-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;
+}