summaryrefslogtreecommitdiff
path: root/test/pkstr.cpp
blob: 04a61da65af7d784cdfcfa58474f0c220fd027ff (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60

#define PK_IMPL_MEM
#define PK_IMPL_STR

#include "../pkstr.h"

#include "../pkmacros.h"

#include <cstdio>
#include <string>

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((char *)"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((char *)"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;
}