summaryrefslogtreecommitdiff
path: root/test/pkstr.c
diff options
context:
space:
mode:
authorJonathan Bradley <jcb@pikum.xyz>2024-10-11 22:37:13 -0400
committerJonathan Bradley <jcb@pikum.xyz>2024-10-11 22:37:13 -0400
commit7889de050105a9fba827c46eaae767490c75177c (patch)
treebd05d8ec6779e947e45c25887ef31890525b7f51 /test/pkstr.c
parentb70fe8a9a945b9822d437c09f157a3fd81781617 (diff)
pkstr: add
Diffstat (limited to 'test/pkstr.c')
-rw-r--r--test/pkstr.c56
1 files changed, 56 insertions, 0 deletions
diff --git a/test/pkstr.c b/test/pkstr.c
new file mode 100644
index 0000000..7b91fe7
--- /dev/null
+++ b/test/pkstr.c
@@ -0,0 +1,56 @@
+
+#include "../pkstr.h"
+
+#include "../pkmacros.h"
+
+#include <stdio.h>
+
+int main(int argc, char *argv[])
+{
+ (void)argc;
+ (void)argv;
+ (void)stdout;
+
+ struct pk_str s;
+ struct pk_cstr cs;
+ struct pk_str os;
+ struct pk_cstr ocs;
+
+ // cstring_to_pk_str
+ {
+ s = cstring_to_pk_str("this is a test");
+ PK_LOGV_INF("cstring_to_pk_str: '%s' '%i' '%i'\n", s.val, s.length, s.reserved);
+ }
+
+ // cstring_to_pk_cstr
+ {
+ cs = cstring_to_pk_cstr("this is a const test");
+ PK_LOGV_INF("cstring_to_pk_cstr: '%s' '%i' '%i'\n", cs.val, cs.length, cs.reserved);
+ }
+
+ // pk_cstr_to_pk_str
+ {
+ os = pk_cstr_to_pk_str(&cs);
+ PK_LOGV_INF("pk_cstr_to_pk_str: '%s' '%i' '%i'\n", os.val, os.length, os.reserved);
+ }
+
+ // pk_str_to_pk_cstr
+ {
+ ocs = pk_str_to_pk_cstr(&s);
+ PK_LOGV_INF("pk_str_to_pk_cstr: '%s' '%i' '%i'\n", ocs.val, ocs.length, ocs.reserved);
+ }
+
+ // pk_compare_str
+ {
+ os = cstring_to_pk_str("this is a different test");
+ PK_LOGV_INF("pk_compare_str, ('%s' cmp '%s') = '%i'\n", s.val, os.val, pk_compare_str(&s, &os));
+ }
+
+ // pk_compare_cstr
+ {
+ ocs = cstring_to_pk_cstr("this is a different const test");
+ PK_LOGV_INF("pk_compare_cstr, ('%s' cmp '%s') = '%i'\n", ocs.val, cs.val, pk_compare_cstr(&ocs, &cs));
+ }
+
+ return 0;
+}