aboutsummaryrefslogtreecommitdiff
path: root/test/identifier.c
diff options
context:
space:
mode:
authornodist <kevin.comas.git@gmail.com>2026-10-26 09:22:29 -0400
committernodist <kevin.comas.git@gmail.com>2026-10-26 09:22:29 -0400
commitfcc5294b919856ff04fef859760d48d0da136396 (patch)
tree3f7c08bfbe52b47131b6c1c26795dce796e9cf0e /test/identifier.c
parent19eb183b38511998322d99c33515c079d89785e3 (diff)
shfit unsigned long number
Diffstat (limited to 'test/identifier.c')
-rw-r--r--test/identifier.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/test/identifier.c b/test/identifier.c
index 94c57bb..bd50795 100644
--- a/test/identifier.c
+++ b/test/identifier.c
@@ -2,10 +2,22 @@
#include "kpl_test.h"
KPL_TEST(c_string_to_identifier) {
- const char *string = "aA0_t4_12w0Z";
+ const char *string = "aA0_t4_12w0abcdefghijklmnop456789Z";
kpl_identifier identifier;
KPL_ASSERT(kpl_identifier_encode(&identifier, string, strlen(string)), "should encode");
char buffer[100] = {};
- kpl_identifier_decode(&identifier, buffer);
- KPL_ASSERT(strcmp(string, buffer) == 0, "should decode to same string");
+ const int32_t offset = 10;
+ kpl_identifier_decode(&identifier, buffer + offset);
+ KPL_ASSERT(strcmp(string, buffer + offset) == 0, "should decode to same string");
+}
+
+KPL_TEST(identifier_compare) {
+ const char *string_a = "abc123456789", *string_b = "abc123456789", *string_c = "abd123456789";
+ kpl_identifier identifier_a, identifier_b, identifier_c;
+ KPL_ASSERT(kpl_identifier_encode(&identifier_a, string_a, strlen(string_a)), "should encode");
+ KPL_ASSERT(kpl_identifier_encode(&identifier_b, string_b, strlen(string_b)), "should encode");
+ KPL_ASSERT(kpl_identifier_encode(&identifier_c, string_c, strlen(string_c)), "should encode");
+ KPL_ASSERT(kpl_identifier_compare(&identifier_a, &identifier_b) == 0, "should be 0");
+ int32_t compare_value = strcmp(string_b, string_c);
+ KPL_ASSERT(kpl_identifier_compare(&identifier_b, &identifier_c) == compare_value, "should equal strcmp");
}