diff options
Diffstat (limited to 'test')
| -rw-r--r-- | test/identifier.c | 18 |
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"); } |
