summaryrefslogtreecommitdiff
path: root/test/pkstr.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/pkstr.c')
-rw-r--r--test/pkstr.c29
1 files changed, 29 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;
}