summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJonathan Bradley <jcb@pikum.xyz>2025-10-22 14:59:18 -0400
committerJonathan Bradley <jcb@pikum.xyz>2025-10-29 16:00:24 -0400
commitcb3e77586ac835c156cb4700b324dafbbb110adf (patch)
treeb8f005a9b244f0235b65a6ca61bfbb06daa15552 /test
parent9371874907c042b587b5b9598b82946138d3bf75 (diff)
pkstr: clone functions if PK_IMPL_MEM defined
Diffstat (limited to 'test')
-rw-r--r--test/pkstr.c29
-rw-r--r--test/pkstr.cpp1
2 files changed, 30 insertions, 0 deletions
diff --git a/test/pkstr.c b/test/pkstr.c
index f477e6a..8e7193b 100644
--- a/test/pkstr.c
+++ b/test/pkstr.c
@@ -1,4 +1,5 @@
+#define PK_IMPL_MEM
#define PK_IMPL_STR
#include "../pkstr.h"
@@ -18,6 +19,9 @@ int main(int argc, char *argv[])
struct pk_str os;
struct pk_cstr ocs;
+ struct pk_membucket *bkt = pk_mem_bucket_create("test-pkstr", PK_MEM_DEFAULT_BUCKET_SIZE, PK_MEMBUCKET_FLAG_NONE);
+ pk_mem_bucket_set_client_mem_bucket(bkt);
+
// cstring_to_pk_str
{
s = cstring_to_pk_str("this is a test");
@@ -54,5 +58,30 @@ int main(int argc, char *argv[])
PK_LOGV_INF("pk_compare_cstr, ('%s' cmp '%s') = '%i'\n", ocs.val, cs.val, pk_compare_cstr(&ocs, &cs));
}
+ // pk_clone_pk_str
+ {
+ s = cstring_to_pk_str("this is a clone test");
+ os = pk_str_clone(&s, nullptr);
+ if (s.length != os.length) return 1;
+ if (os.reserved == 0) return 1;
+ if (s.val == os.val) return 1;
+ if (os.val == nullptr) return 1;
+ PK_LOGV_INF("pk_clone_pk_str, ('%s' to '%s')\n", s.val, os.val);
+ }
+
+ // pk_clone_pk_cstr
+ {
+ cs = cstring_to_pk_cstr("this is a const clone test");
+ ocs = pk_cstr_clone(&cs, nullptr);
+ if (cs.length != ocs.length) return 1;
+ if (ocs.reserved == 0) return 1;
+ if (cs.val == ocs.val) return 1;
+ if (ocs.val == nullptr) return 1;
+ PK_LOGV_INF("pk_clone_pk_cstr, ('%s' to '%s')\n", cs.val, ocs.val);
+ }
+
+ pk_mem_bucket_destroy(bkt);
+ bkt = nullptr;
+
return 0;
}
diff --git a/test/pkstr.cpp b/test/pkstr.cpp
index c7b55bc..04a61da 100644
--- a/test/pkstr.cpp
+++ b/test/pkstr.cpp
@@ -1,4 +1,5 @@
+#define PK_IMPL_MEM
#define PK_IMPL_STR
#include "../pkstr.h"