tests/test_string.c

Mon, 01 Jan 2024 16:42:37 +0100

author
Mike Becker <universe@uap-core.de>
date
Mon, 01 Jan 2024 16:42:37 +0100
changeset 789
9b2f5661bebd
parent 777
e5b29e6f0615
child 806
e06249e09f99
permissions
-rw-r--r--

begin migration of buffer tests - relates to #342

777
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
1 /*
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
3 *
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
4 * Copyright 2023 Mike Becker, Olaf Wintermann All rights reserved.
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
5 *
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
6 * Redistribution and use in source and binary forms, with or without
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
7 * modification, are permitted provided that the following conditions are met:
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
8 *
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
9 * 1. Redistributions of source code must retain the above copyright
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
10 * notice, this list of conditions and the following disclaimer.
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
11 *
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
12 * 2. Redistributions in binary form must reproduce the above copyright
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
13 * notice, this list of conditions and the following disclaimer in the
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
14 * documentation and/or other materials provided with the distribution.
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
15 *
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
26 * POSSIBILITY OF SUCH DAMAGE.
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
27 */
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
28
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
29 #include "cx/test.h"
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
30 #include "util_allocator.h"
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
31
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
32 #include "cx/string.h"
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
33
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
34 #define ASSERT_ZERO_TERMINATED(str) CX_TEST_ASSERTM((str).ptr[(str).length] == '\0', \
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
35 #str " is not zero terminated")
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
36
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
37 CX_TEST(test_string_construct) {
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
38 cxstring s1 = CX_STR("1234");
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
39 cxstring s2 = cx_strn("abcd", 2);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
40 cxmutstr s3 = cx_mutstr((char *) "1234");
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
41 cxmutstr s4 = cx_mutstrn((char *) "abcd", 2);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
42 CX_TEST_DO {
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
43 CX_TEST_ASSERT(s1.length == 4);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
44 CX_TEST_ASSERT(strncmp(s1.ptr, "1234", 4) == 0);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
45 CX_TEST_ASSERT(s2.length == 2);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
46 CX_TEST_ASSERT(strncmp(s2.ptr, "ab", 2) == 0);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
47 CX_TEST_ASSERT(s3.length == 4);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
48 CX_TEST_ASSERT(strncmp(s3.ptr, "1234", 4) == 0);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
49 CX_TEST_ASSERT(s4.length == 2);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
50 CX_TEST_ASSERT(strncmp(s4.ptr, "ab", 2) == 0);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
51 }
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
52 }
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
53
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
54 CX_TEST(test_strfree) {
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
55 CxTestingAllocator talloc;
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
56 cx_testing_allocator_init(&talloc);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
57 CxAllocator *alloc = &talloc.base;
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
58 CX_TEST_DO {
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
59 char *test = cxMalloc(alloc, 16);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
60 cxmutstr str = cx_mutstrn(test, 16);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
61 CX_TEST_ASSERT(str.ptr == test);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
62 CX_TEST_ASSERT(str.length == 16);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
63 cx_strfree_a(alloc, &str);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
64 CX_TEST_ASSERT(str.ptr == NULL);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
65 CX_TEST_ASSERT(str.length == 0);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
66 CX_TEST_ASSERT(cx_testing_allocator_verify(&talloc));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
67 }
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
68 cx_testing_allocator_destroy(&talloc);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
69 }
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
70
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
71 CX_TEST(test_strdup) {
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
72 cxstring str = CX_STR("test");
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
73 cxmutstr dup = cx_strdup(str);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
74 CX_TEST_DO {
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
75 CX_TEST_ASSERT(dup.length == str.length);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
76 CX_TEST_ASSERT(0 == strcmp(dup.ptr, str.ptr));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
77 ASSERT_ZERO_TERMINATED(dup);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
78 }
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
79 cx_strfree(&dup);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
80 }
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
81
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
82 CX_TEST(test_strdup_shortened) {
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
83 cxstring str = CX_STR("test");
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
84 str.length = 2;
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
85 cxmutstr dup = cx_strdup(str);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
86 CX_TEST_DO {
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
87 CX_TEST_ASSERT(dup.length == str.length);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
88 CX_TEST_ASSERT(0 == strcmp(dup.ptr, "te"));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
89 ASSERT_ZERO_TERMINATED(dup);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
90 }
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
91 cx_strfree(&dup);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
92 }
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
93
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
94 CX_TEST(test_strlen) {
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
95 cxstring s1 = CX_STR("1234");
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
96 cxstring s2 = CX_STR(".:.:.");
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
97 cxstring s3 = CX_STR("X");
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
98 CX_TEST_DO {
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
99 size_t len0 = cx_strlen(0);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
100 size_t len1 = cx_strlen(1, s1);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
101 size_t len2 = cx_strlen(2, s1, s2);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
102 size_t len3 = cx_strlen(3, s1, s2, s3);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
103
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
104 CX_TEST_ASSERT(len0 == 0);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
105 CX_TEST_ASSERT(len1 == 4);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
106 CX_TEST_ASSERT(len2 == 9);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
107 CX_TEST_ASSERT(len3 == 10);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
108 }
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
109 }
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
110
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
111 CX_TEST(test_strsubs) {
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
112 cxstring str = CX_STR("A test string");
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
113
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
114 CX_TEST_DO {
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
115 cxstring sub = cx_strsubs(str, 0);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
116 CX_TEST_ASSERT(0 == cx_strcmp(sub, str));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
117
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
118 sub = cx_strsubs(str, 2);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
119 CX_TEST_ASSERT(0 == cx_strcmp(sub, CX_STR("test string")));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
120
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
121 sub = cx_strsubs(str, 7);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
122 CX_TEST_ASSERT(0 == cx_strcmp(sub, CX_STR("string")));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
123
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
124 sub = cx_strsubs(str, 15);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
125 CX_TEST_ASSERT(0 == cx_strcmp(sub, CX_STR("")));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
126
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
127 sub = cx_strsubsl(str, 2, 4);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
128 CX_TEST_ASSERT(0 == cx_strcmp(sub, CX_STR("test")));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
129
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
130 sub = cx_strsubsl(str, 7, 3);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
131 CX_TEST_ASSERT(0 == cx_strcmp(sub, CX_STR("str")));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
132
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
133 sub = cx_strsubsl(str, 7, 20);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
134 CX_TEST_ASSERT(0 == cx_strcmp(sub, CX_STR("string")));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
135
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
136 // just for coverage, call the _m variant
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
137 cxmutstr m = cx_strsubs_m(cx_mutstrn(NULL, 0), 0);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
138 CX_TEST_ASSERT(0 == cx_strcmp(cx_strcast(m), CX_STR("")));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
139 }
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
140 }
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
141
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
142 CX_TEST(test_strchr) {
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
143 cxstring str = CX_STR("I will find you - and I will kill you");
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
144
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
145 CX_TEST_DO {
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
146 cxstring notfound = cx_strchr(str, 'x');
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
147 CX_TEST_ASSERT(notfound.length == 0);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
148
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
149 cxstring result = cx_strchr(str, 'w');
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
150 CX_TEST_ASSERT(result.length == 35);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
151 CX_TEST_ASSERT(0 == strcmp(result.ptr, "will find you - and I will kill you"));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
152
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
153 // just for coverage, call the _m variant
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
154 cxmutstr m = cx_strchr_m(cx_mutstrn(NULL, 0), 'a');
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
155 CX_TEST_ASSERT(0 == cx_strcmp(cx_strcast(m), CX_STR("")));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
156 }
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
157 }
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
158
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
159 CX_TEST(test_strrchr) {
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
160 cxstring str = CX_STR("I will find you - and I will kill you");
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
161
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
162 CX_TEST_DO {
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
163 cxstring notfound = cx_strrchr(str, 'x');
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
164 CX_TEST_ASSERT(notfound.length == 0);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
165
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
166 cxstring result = cx_strrchr(str, 'w');
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
167 CX_TEST_ASSERT(result.length == 13);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
168 CX_TEST_ASSERT(0 == strcmp(result.ptr, "will kill you"));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
169
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
170 // just for coverage, call the _m variant
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
171 cxmutstr m = cx_strrchr_m(cx_mutstrn(NULL, 0), 'a');
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
172 CX_TEST_ASSERT(0 == cx_strcmp(cx_strcast(m), CX_STR("")));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
173 }
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
174 }
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
175
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
176 CX_TEST(test_strstr) {
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
177 cxstring str = CX_STR("find the match in this string");
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
178 cxstring longstr = CX_STR(
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
179 "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijkl"
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
180 "mnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwx"
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
181 "yzabcdeababababnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghij"
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
182 "klmnopqrstuvwxyzaababababababababrstuvwxyzabcdefghijklmnopqrstuv"
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
183 "abababababababababababababababababababababababababababababababab"
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
184 "abababababababababababababababababababababababababababababababab"
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
185 "abababababababababababababababababababababababababababababababab"
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
186 "abababababababababababababababababababababababababababababababab"
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
187 "abababababababababababababababababababababababababababababababab"
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
188 "abababababababababababababababababababababababababababababababab"
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
189 "wxyz1234567890");
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
190 cxstring longstrpattern = CX_STR(
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
191 "abababababababababababababababababababababababababababababababab"
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
192 "abababababababababababababababababababababababababababababababab"
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
193 "abababababababababababababababababababababababababababababababab"
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
194 "abababababababababababababababababababababababababababababababab"
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
195 "abababababababababababababababababababababababababababababababab"
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
196 );
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
197 cxstring longstrresult = CX_STR(
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
198 "abababababababababababababababababababababababababababababababab"
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
199 "abababababababababababababababababababababababababababababababab"
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
200 "abababababababababababababababababababababababababababababababab"
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
201 "abababababababababababababababababababababababababababababababab"
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
202 "abababababababababababababababababababababababababababababababab"
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
203 "abababababababababababababababababababababababababababababababab"
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
204 "wxyz1234567890"
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
205 );
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
206
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
207 CX_TEST_DO {
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
208 cxstring notfound = cx_strstr(str, CX_STR("no match"));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
209 CX_TEST_ASSERT(notfound.length == 0);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
210
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
211 cxstring result = cx_strstr(str, CX_STR("match"));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
212 CX_TEST_ASSERT(result.length == 20);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
213 CX_TEST_ASSERT(0 == strcmp(result.ptr, "match in this string"));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
214
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
215 result = cx_strstr(str, CX_STR(""));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
216 CX_TEST_ASSERT(result.length == str.length);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
217 CX_TEST_ASSERT(0 == strcmp(result.ptr, str.ptr));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
218
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
219 result = cx_strstr(longstr, longstrpattern);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
220 CX_TEST_ASSERT(result.length == longstrresult.length);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
221 CX_TEST_ASSERT(0 == strcmp(result.ptr, longstrresult.ptr));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
222
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
223 // just for coverage, call the _m variant
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
224 cxmutstr mstr = cx_strdup(longstr);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
225 cxmutstr m = cx_strstr_m(mstr, longstrpattern);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
226 CX_TEST_ASSERT(m.length == longstrresult.length);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
227 CX_TEST_ASSERT(0 == strcmp(m.ptr, longstrresult.ptr));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
228 cx_strfree(&mstr);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
229 }
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
230 }
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
231
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
232 CX_TEST(test_strcmp) {
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
233 cxstring str = CX_STR("compare this");
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
234 CX_TEST_DO {
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
235 CX_TEST_ASSERT(0 == cx_strcmp(CX_STR(""), CX_STR("")));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
236 CX_TEST_ASSERT(0 < cx_strcmp(str, CX_STR("")));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
237 CX_TEST_ASSERT(0 == cx_strcmp(str, CX_STR("compare this")));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
238 CX_TEST_ASSERT(0 != cx_strcmp(str, CX_STR("Compare This")));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
239 CX_TEST_ASSERT(0 > cx_strcmp(str, CX_STR("compare tool")));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
240 CX_TEST_ASSERT(0 < cx_strcmp(str, CX_STR("compare shit")));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
241 CX_TEST_ASSERT(0 > cx_strcmp(str, CX_STR("compare this not")));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
242 CX_TEST_ASSERT(0 < cx_strcmp(str, CX_STR("compare")));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
243
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
244 cxstring str2 = CX_STR("Compare This");
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
245 CX_TEST_ASSERT(0 != cx_strcmp_p(&str, &str2));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
246 str2 = CX_STR("compare this");
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
247 CX_TEST_ASSERT(0 == cx_strcmp_p(&str, &str2));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
248 }
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
249 }
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
250
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
251 CX_TEST(test_strcasecmp) {
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
252 cxstring str = CX_STR("compare this");
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
253 CX_TEST_DO {
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
254 CX_TEST_ASSERT(0 == cx_strcasecmp(CX_STR(""), CX_STR("")));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
255 CX_TEST_ASSERT(0 < cx_strcasecmp(str, CX_STR("")));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
256 CX_TEST_ASSERT(0 == cx_strcasecmp(str, CX_STR("compare this")));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
257 CX_TEST_ASSERT(0 == cx_strcasecmp(str, CX_STR("Compare This")));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
258 CX_TEST_ASSERT(0 > cx_strcasecmp(str, CX_STR("compare tool")));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
259 CX_TEST_ASSERT(0 < cx_strcasecmp(str, CX_STR("compare shit")));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
260 CX_TEST_ASSERT(0 > cx_strcasecmp(str, CX_STR("compare this not")));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
261 CX_TEST_ASSERT(0 < cx_strcasecmp(str, CX_STR("compare")));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
262
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
263 cxstring str2 = CX_STR("Compare This");
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
264 CX_TEST_ASSERT(0 == cx_strcasecmp_p(&str, &str2));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
265 str2 = CX_STR("Compare Tool");
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
266 CX_TEST_ASSERT(0 > cx_strcasecmp_p(&str, &str2));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
267 }
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
268 }
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
269
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
270 CX_TEST(test_strcat) {
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
271 cxstring s1 = CX_STR("12");
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
272 cxstring s2 = CX_STR("34");
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
273 cxstring s3 = CX_STR("56");
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
274 cxstring sn = {NULL, 0};
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
275
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
276 CxTestingAllocator talloc;
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
277 cx_testing_allocator_init(&talloc);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
278 CxAllocator *alloc = &talloc.base;
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
279
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
280 CX_TEST_DO {
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
281 cxmutstr t1 = cx_strcat_a(alloc, 2, s1, s2);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
282 CX_TEST_ASSERT(0 == cx_strcmp(cx_strcast(t1), CX_STR("1234")));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
283 ASSERT_ZERO_TERMINATED(t1);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
284 cx_strfree_a(alloc, &t1);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
285
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
286 cxmutstr t2 = cx_strcat_a(alloc, 3, s1, s2, s3);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
287 CX_TEST_ASSERT(0 == cx_strcmp(cx_strcast(t2), CX_STR("123456")));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
288 ASSERT_ZERO_TERMINATED(t2);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
289 cx_strfree_a(alloc, &t2);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
290
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
291 cxmutstr t3 = cx_strcat_a(alloc, 6, s1, sn, s2, sn, s3, sn);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
292 CX_TEST_ASSERT(0 == cx_strcmp(cx_strcast(t3), CX_STR("123456")));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
293 ASSERT_ZERO_TERMINATED(t3);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
294 cx_strfree_a(alloc, &t3);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
295
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
296 cxmutstr t4 = cx_strcat_a(alloc, 2, sn, sn);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
297 CX_TEST_ASSERT(0 == cx_strcmp(cx_strcast(t4), CX_STR("")));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
298 ASSERT_ZERO_TERMINATED(t4);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
299 cx_strfree_a(alloc, &t4);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
300
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
301 CX_TEST_ASSERT(cx_testing_allocator_verify(&talloc));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
302
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
303 // use the macro
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
304 cxmutstr t5 = cx_strcat(3, s3, s1, s2);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
305 CX_TEST_ASSERT(0 == cx_strcmp(cx_strcast(t5), CX_STR("561234")));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
306 ASSERT_ZERO_TERMINATED(t5);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
307 cx_strfree(&t5);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
308
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
309 // use an initial string
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
310 cxmutstr t6 = cx_strdup(CX_STR("Hello"));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
311 t6 = cx_strcat_m(t6, 2, CX_STR(", "), CX_STR("World!"));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
312 CX_TEST_ASSERT(0 == cx_strcmp(cx_strcast(t6), CX_STR("Hello, World!")));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
313 ASSERT_ZERO_TERMINATED(t6);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
314 cx_strfree(&t6);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
315 }
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
316 cx_testing_allocator_destroy(&talloc);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
317 }
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
318
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
319 CX_TEST(test_strsplit) {
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
320 cxstring test = CX_STR("this,is,a,csv,string");
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
321 size_t capa = 8;
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
322 cxstring list[8];
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
323 size_t n;
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
324 CX_TEST_DO {
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
325 // special case: empty string
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
326 n = cx_strsplit(test, CX_STR(""), capa, list);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
327 CX_TEST_ASSERT(n == 1);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
328 CX_TEST_ASSERT(0 == cx_strcmp(list[0], test));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
329
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
330 // no delimiter occurrence
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
331 n = cx_strsplit(test, CX_STR("z"), capa, list);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
332 CX_TEST_ASSERT(n == 1);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
333 CX_TEST_ASSERT(0 == cx_strcmp(list[0], test));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
334
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
335 // partially matching delimiter
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
336 n = cx_strsplit(test, CX_STR("is,not"), capa, list);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
337 CX_TEST_ASSERT(n == 1);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
338 CX_TEST_ASSERT(0 == cx_strcmp(list[0], test));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
339
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
340 // matching single-char delimiter
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
341 n = cx_strsplit(test, CX_STR(","), capa, list);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
342 CX_TEST_ASSERT(n == 5);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
343 CX_TEST_ASSERT(0 == cx_strcmp(list[0], CX_STR("this")));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
344 CX_TEST_ASSERT(0 == cx_strcmp(list[1], CX_STR("is")));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
345 CX_TEST_ASSERT(0 == cx_strcmp(list[2], CX_STR("a")));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
346 CX_TEST_ASSERT(0 == cx_strcmp(list[3], CX_STR("csv")));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
347 CX_TEST_ASSERT(0 == cx_strcmp(list[4], CX_STR("string")));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
348
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
349 // matching multi-char delimiter
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
350 n = cx_strsplit(test, CX_STR("is"), capa, list);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
351 CX_TEST_ASSERT(n == 3);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
352 CX_TEST_ASSERT(0 == cx_strcmp(list[0], CX_STR("th")));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
353 CX_TEST_ASSERT(0 == cx_strcmp(list[1], CX_STR(",")));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
354 CX_TEST_ASSERT(0 == cx_strcmp(list[2], CX_STR(",a,csv,string")));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
355
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
356 // bounded list using single-char delimiter
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
357 n = cx_strsplit(test, CX_STR(","), 3, list);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
358 CX_TEST_ASSERT(n == 3);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
359 CX_TEST_ASSERT(0 == cx_strcmp(list[0], CX_STR("this")));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
360 CX_TEST_ASSERT(0 == cx_strcmp(list[1], CX_STR("is")));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
361 CX_TEST_ASSERT(0 == cx_strcmp(list[2], CX_STR("a,csv,string")));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
362
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
363 // bounded list using multi-char delimiter
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
364 n = cx_strsplit(test, CX_STR("is"), 2, list);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
365 CX_TEST_ASSERT(n == 2);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
366 CX_TEST_ASSERT(0 == cx_strcmp(list[0], CX_STR("th")));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
367 CX_TEST_ASSERT(0 == cx_strcmp(list[1], CX_STR(",is,a,csv,string")));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
368
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
369 // start with delimiter
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
370 n = cx_strsplit(test, CX_STR("this"), capa, list);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
371 CX_TEST_ASSERT(n == 2);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
372 CX_TEST_ASSERT(0 == cx_strcmp(list[0], CX_STR("")));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
373 CX_TEST_ASSERT(0 == cx_strcmp(list[1], CX_STR(",is,a,csv,string")));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
374
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
375 // end with delimiter
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
376 n = cx_strsplit(test, CX_STR("string"), capa, list);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
377 CX_TEST_ASSERT(n == 2);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
378 CX_TEST_ASSERT(0 == cx_strcmp(list[0], CX_STR("this,is,a,csv,")));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
379 CX_TEST_ASSERT(0 == cx_strcmp(list[1], CX_STR("")));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
380
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
381
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
382 // end with delimiter exceed bound
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
383 n = cx_strsplit(CX_STR("a,b,c,"), CX_STR(","), 3, list);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
384 CX_TEST_ASSERT(n == 3);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
385 CX_TEST_ASSERT(0 == cx_strcmp(list[0], CX_STR("a")));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
386 CX_TEST_ASSERT(0 == cx_strcmp(list[1], CX_STR("b")));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
387 CX_TEST_ASSERT(0 == cx_strcmp(list[2], CX_STR("c,")));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
388
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
389 // exact match
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
390 n = cx_strsplit(test, CX_STR("this,is,a,csv,string"), capa, list);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
391 CX_TEST_ASSERT(n == 2);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
392 CX_TEST_ASSERT(0 == cx_strcmp(list[0], CX_STR("")));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
393 CX_TEST_ASSERT(0 == cx_strcmp(list[1], CX_STR("")));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
394
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
395 // string to be split is only substring
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
396 n = cx_strsplit(test, CX_STR("this,is,a,csv,string,with,extension"), capa, list);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
397 CX_TEST_ASSERT(n == 1);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
398 CX_TEST_ASSERT(0 == cx_strcmp(list[0], test));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
399
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
400 // subsequent encounter of delimiter (the string between is empty)
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
401 n = cx_strsplit(test, CX_STR("is,"), capa, list);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
402 CX_TEST_ASSERT(n == 3);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
403 CX_TEST_ASSERT(0 == cx_strcmp(list[0], CX_STR("th")));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
404 CX_TEST_ASSERT(0 == cx_strcmp(list[1], CX_STR("")));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
405 CX_TEST_ASSERT(0 == cx_strcmp(list[2], CX_STR("a,csv,string")));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
406
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
407 // call the _m variant just for coverage
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
408 cxmutstr mtest = cx_strdup(test);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
409 cxmutstr mlist[4];
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
410 n = cx_strsplit_m(mtest, CX_STR("is,"), 4, mlist);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
411 CX_TEST_ASSERT(n == 3);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
412 CX_TEST_ASSERT(0 == cx_strcmp(cx_strcast(mlist[0]), CX_STR("th")));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
413 CX_TEST_ASSERT(0 == cx_strcmp(cx_strcast(mlist[1]), CX_STR("")));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
414 CX_TEST_ASSERT(0 == cx_strcmp(cx_strcast(mlist[2]), CX_STR("a,csv,string")));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
415 cx_strfree(&mtest);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
416 }
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
417 }
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
418
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
419 CX_TEST(test_strsplit_a) {
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
420 CxTestingAllocator talloc;
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
421 cx_testing_allocator_init(&talloc);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
422 CxAllocator *alloc = &talloc.base;
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
423
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
424 cxstring test = CX_STR("this,is,a,csv,string");
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
425 size_t capa = 8;
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
426 cxstring *list;
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
427 size_t n;
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
428 CX_TEST_DO {
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
429 // special case: empty string
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
430 n = cx_strsplit_a(alloc, test, CX_STR(""), capa, &list);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
431 CX_TEST_ASSERT(n == 1);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
432 CX_TEST_ASSERT(0 == cx_strcmp(list[0], test));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
433 cxFree(alloc, list);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
434
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
435 // no delimiter occurrence
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
436 n = cx_strsplit_a(alloc, test, CX_STR("z"), capa, &list);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
437 CX_TEST_ASSERT(n == 1);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
438 CX_TEST_ASSERT(0 == cx_strcmp(list[0], test));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
439 cxFree(alloc, list);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
440
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
441 // partially matching delimiter
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
442 n = cx_strsplit_a(alloc, test, CX_STR("is,not"), capa, &list);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
443 CX_TEST_ASSERT(n == 1);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
444 CX_TEST_ASSERT(0 == cx_strcmp(list[0], test));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
445 cxFree(alloc, list);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
446
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
447 // matching single-char delimiter
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
448 n = cx_strsplit_a(alloc, test, CX_STR(","), capa, &list);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
449 CX_TEST_ASSERT(n == 5);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
450 CX_TEST_ASSERT(0 == cx_strcmp(list[0], CX_STR("this")));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
451 CX_TEST_ASSERT(0 == cx_strcmp(list[1], CX_STR("is")));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
452 CX_TEST_ASSERT(0 == cx_strcmp(list[2], CX_STR("a")));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
453 CX_TEST_ASSERT(0 == cx_strcmp(list[3], CX_STR("csv")));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
454 CX_TEST_ASSERT(0 == cx_strcmp(list[4], CX_STR("string")));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
455 cxFree(alloc, list);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
456
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
457 // matching multi-char delimiter
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
458 n = cx_strsplit_a(alloc, test, CX_STR("is"), capa, &list);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
459 CX_TEST_ASSERT(n == 3);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
460 CX_TEST_ASSERT(0 == cx_strcmp(list[0], CX_STR("th")));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
461 CX_TEST_ASSERT(0 == cx_strcmp(list[1], CX_STR(",")));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
462 CX_TEST_ASSERT(0 == cx_strcmp(list[2], CX_STR(",a,csv,string")));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
463 cxFree(alloc, list);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
464
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
465 // bounded list using single-char delimiter
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
466 n = cx_strsplit_a(alloc, test, CX_STR(","), 3, &list);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
467 CX_TEST_ASSERT(n == 3);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
468 CX_TEST_ASSERT(0 == cx_strcmp(list[0], CX_STR("this")));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
469 CX_TEST_ASSERT(0 == cx_strcmp(list[1], CX_STR("is")));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
470 CX_TEST_ASSERT(0 == cx_strcmp(list[2], CX_STR("a,csv,string")));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
471 cxFree(alloc, list);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
472
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
473 // bounded list using multi-char delimiter
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
474 n = cx_strsplit_a(alloc, test, CX_STR("is"), 2, &list);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
475 CX_TEST_ASSERT(n == 2);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
476 CX_TEST_ASSERT(0 == cx_strcmp(list[0], CX_STR("th")));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
477 CX_TEST_ASSERT(0 == cx_strcmp(list[1], CX_STR(",is,a,csv,string")));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
478 cxFree(alloc, list);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
479
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
480 // start with delimiter
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
481 n = cx_strsplit_a(alloc, test, CX_STR("this"), capa, &list);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
482 CX_TEST_ASSERT(n == 2);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
483 CX_TEST_ASSERT(0 == cx_strcmp(list[0], CX_STR("")));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
484 CX_TEST_ASSERT(0 == cx_strcmp(list[1], CX_STR(",is,a,csv,string")));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
485 cxFree(alloc, list);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
486
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
487 // end with delimiter
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
488 n = cx_strsplit_a(alloc, test, CX_STR("string"), capa, &list);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
489 CX_TEST_ASSERT(n == 2);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
490 CX_TEST_ASSERT(0 == cx_strcmp(list[0], CX_STR("this,is,a,csv,")));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
491 CX_TEST_ASSERT(0 == cx_strcmp(list[1], CX_STR("")));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
492 cxFree(alloc, list);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
493
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
494 // end with delimiter exceed bound
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
495 n = cx_strsplit_a(alloc, CX_STR("a,b,c,"), CX_STR(","), 3, &list);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
496 CX_TEST_ASSERT(n == 3);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
497 CX_TEST_ASSERT(0 == cx_strcmp(list[0], CX_STR("a")));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
498 CX_TEST_ASSERT(0 == cx_strcmp(list[1], CX_STR("b")));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
499 CX_TEST_ASSERT(0 == cx_strcmp(list[2], CX_STR("c,")));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
500 cxFree(alloc, list);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
501
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
502 // exact match
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
503 n = cx_strsplit_a(alloc, test, CX_STR("this,is,a,csv,string"), capa, &list);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
504 CX_TEST_ASSERT(n == 2);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
505 CX_TEST_ASSERT(0 == cx_strcmp(list[0], CX_STR("")));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
506 CX_TEST_ASSERT(0 == cx_strcmp(list[1], CX_STR("")));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
507 cxFree(alloc, list);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
508
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
509 // string to be split is only substring
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
510 n = cx_strsplit_a(alloc, test, CX_STR("this,is,a,csv,string,with,extension"), capa, &list);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
511 CX_TEST_ASSERT(n == 1);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
512 CX_TEST_ASSERT(0 == cx_strcmp(list[0], test));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
513 cxFree(alloc, list);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
514
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
515 // subsequent encounter of delimiter (the string between is empty)
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
516 n = cx_strsplit_a(alloc, test, CX_STR("is,"), capa, &list);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
517 CX_TEST_ASSERT(n == 3);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
518 CX_TEST_ASSERT(0 == cx_strcmp(list[0], CX_STR("th")));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
519 CX_TEST_ASSERT(0 == cx_strcmp(list[1], CX_STR("")));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
520 CX_TEST_ASSERT(0 == cx_strcmp(list[2], CX_STR("a,csv,string")));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
521 cxFree(alloc, list);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
522
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
523 // call the _m variant just for coverage
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
524 cxmutstr mtest = cx_strdup(test);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
525 cxmutstr *mlist;
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
526 n = cx_strsplit_ma(alloc, mtest, CX_STR("is,"), 4, &mlist);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
527 CX_TEST_ASSERT(n == 3);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
528 CX_TEST_ASSERT(0 == cx_strcmp(cx_strcast(mlist[0]), CX_STR("th")));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
529 CX_TEST_ASSERT(0 == cx_strcmp(cx_strcast(mlist[1]), CX_STR("")));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
530 CX_TEST_ASSERT(0 == cx_strcmp(cx_strcast(mlist[2]), CX_STR("a,csv,string")));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
531 cxFree(alloc, mlist);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
532 cx_strfree(&mtest);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
533
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
534 CX_TEST_ASSERT(cx_testing_allocator_verify(&talloc));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
535 }
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
536 cx_testing_allocator_destroy(&talloc);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
537 }
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
538
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
539 CX_TEST(test_strtrim) {
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
540 cxstring t1 = cx_strtrim(CX_STR(" ein test \t "));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
541 cxstring t2 = cx_strtrim(CX_STR("abc"));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
542 cxstring t3 = cx_strtrim(CX_STR(" 123"));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
543 cxstring t4 = cx_strtrim(CX_STR("xyz "));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
544 cxstring t5 = cx_strtrim(CX_STR(" "));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
545 cxstring empty = cx_strtrim(CX_STR(""));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
546
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
547 CX_TEST_DO {
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
548 CX_TEST_ASSERT(0 == cx_strcmp(t1, CX_STR("ein test")));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
549 CX_TEST_ASSERT(0 == cx_strcmp(t2, CX_STR("abc")));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
550 CX_TEST_ASSERT(0 == cx_strcmp(t3, CX_STR("123")));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
551 CX_TEST_ASSERT(0 == cx_strcmp(t4, CX_STR("xyz")));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
552 CX_TEST_ASSERT(0 == cx_strcmp(t5, CX_STR("")));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
553 CX_TEST_ASSERT(0 == cx_strcmp(empty, CX_STR("")));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
554
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
555 // call the _m variant just for coverage
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
556 cxmutstr m1 = cx_strtrim_m(cx_mutstr((char *) " ein test \t "));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
557 CX_TEST_ASSERT(0 == cx_strcmp(cx_strcast(m1), CX_STR("ein test")));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
558 }
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
559 }
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
560
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
561 CX_TEST(test_strprefix) {
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
562 cxstring str = CX_STR("test my prefix and my suffix");
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
563 cxstring empty = CX_STR("");
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
564 CX_TEST_DO {
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
565 CX_TEST_ASSERT(!cx_strprefix(empty, CX_STR("pref")));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
566 CX_TEST_ASSERT(cx_strprefix(str, empty));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
567 CX_TEST_ASSERT(cx_strprefix(empty, empty));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
568 CX_TEST_ASSERT(cx_strprefix(str, CX_STR("test ")));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
569 CX_TEST_ASSERT(!cx_strprefix(str, CX_STR("8-) fsck ")));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
570 }
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
571 }
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
572
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
573 CX_TEST(test_strsuffix) {
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
574 cxstring str = CX_STR("test my prefix and my suffix");
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
575 cxstring empty = CX_STR("");
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
576 CX_TEST_DO {
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
577 CX_TEST_ASSERT(!cx_strsuffix(empty, CX_STR("suf")));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
578 CX_TEST_ASSERT(cx_strsuffix(str, empty));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
579 CX_TEST_ASSERT(cx_strsuffix(empty, empty));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
580 CX_TEST_ASSERT(cx_strsuffix(str, CX_STR("fix")));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
581 CX_TEST_ASSERT(!cx_strsuffix(str, CX_STR("fox")));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
582 }
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
583 }
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
584
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
585 CX_TEST(test_strcaseprefix) {
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
586 cxstring str = CX_STR("test my prefix and my suffix");
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
587 cxstring empty = CX_STR("");
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
588 CX_TEST_DO {
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
589 CX_TEST_ASSERT(!cx_strcaseprefix(empty, CX_STR("pREf")));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
590 CX_TEST_ASSERT(cx_strcaseprefix(str, empty));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
591 CX_TEST_ASSERT(cx_strcaseprefix(empty, empty));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
592 CX_TEST_ASSERT(cx_strcaseprefix(str, CX_STR("TEST ")));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
593 CX_TEST_ASSERT(!cx_strcaseprefix(str, CX_STR("8-) fsck ")));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
594 }
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
595 }
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
596
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
597 CX_TEST(test_strcasesuffix) {
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
598 cxstring str = CX_STR("test my prefix and my suffix");
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
599 cxstring empty = CX_STR("");
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
600 CX_TEST_DO {
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
601 CX_TEST_ASSERT(!cx_strcasesuffix(empty, CX_STR("sUf")));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
602 CX_TEST_ASSERT(cx_strcasesuffix(str, empty));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
603 CX_TEST_ASSERT(cx_strcasesuffix(empty, empty));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
604 CX_TEST_ASSERT(cx_strcasesuffix(str, CX_STR("FIX")));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
605 CX_TEST_ASSERT(!cx_strcasesuffix(str, CX_STR("fox")));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
606 }
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
607 }
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
608
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
609 CX_TEST(test_strreplace) {
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
610 CxTestingAllocator talloc;
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
611 cx_testing_allocator_init(&talloc);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
612 CxAllocator *alloc = &talloc.base;
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
613
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
614 cxstring str = CX_STR("test ababab string aba");
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
615 cxstring longstr = CX_STR(
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
616 "xyaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaacd");
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
617 cxstring notrail = CX_STR("test abab");
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
618 cxstring empty = CX_STR("");
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
619 cxstring astr = CX_STR("aaaaaaaaaa");
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
620 cxstring csstr = CX_STR("test AB ab TEST xyz");
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
621
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
622 cxmutstr repl = cx_strreplace(str, CX_STR("abab"), CX_STR("muchlonger"));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
623 char const *expected = "test muchlongerab string aba";
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
624
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
625 cxmutstr repln = cx_strreplacen(str, CX_STR("ab"), CX_STR("c"), 2);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
626 char const *expectedn = "test ccab string aba";
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
627
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
628 cxmutstr longrepl = cx_strreplace(longstr, CX_STR("a"), CX_STR("z"));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
629 char const *longexpect = "xyzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzcd";
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
630
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
631 cxmutstr replnotrail = cx_strreplace(notrail, CX_STR("ab"), CX_STR("z"));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
632 char const *notrailexpect = "test zz";
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
633
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
634 cxmutstr repleq = cx_strreplace(str, str, CX_STR("hello"));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
635 char const *eqexpect = "hello";
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
636
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
637 cxmutstr replempty1 = cx_strreplace(empty, CX_STR("ab"), CX_STR("c")); // expect: empty
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
638 cxmutstr replempty2 = cx_strreplace(str, CX_STR("abab"), empty);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
639 char const *emptyexpect2 = "test ab string aba";
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
640
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
641 cxmutstr replpre = cx_strreplace(str, CX_STR("test "), CX_STR("TEST "));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
642 char const *preexpected = "TEST ababab string aba";
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
643
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
644 cxmutstr replan1 = cx_strreplacen(astr, CX_STR("a"), CX_STR("x"), 1);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
645 char const *an1expected = "xaaaaaaaaa";
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
646
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
647 cxmutstr replan4 = cx_strreplacen(astr, CX_STR("a"), CX_STR("x"), 4);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
648 char const *an4expected = "xxxxaaaaaa";
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
649
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
650 cxmutstr replan9 = cx_strreplacen(astr, CX_STR("a"), CX_STR("x"), 9);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
651 char const *an9expected = "xxxxxxxxxa";
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
652
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
653 cxmutstr replan10 = cx_strreplacen(astr, CX_STR("a"), CX_STR("x"), 10);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
654 char const *an10expected = "xxxxxxxxxx";
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
655
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
656 CX_TEST_DO {
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
657 cxmutstr repl1_a = cx_strreplace_a(alloc, csstr, CX_STR("AB"), CX_STR("*"));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
658 char const *expeced1_a = "test * ab TEST xyz";
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
659
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
660 cxmutstr repl2_a = cx_strreplace_a(alloc, csstr, CX_STR("test"), CX_STR("TEST"));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
661 char const *expected2_a = "TEST AB ab TEST xyz";
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
662
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
663 CX_TEST_ASSERT(repl.ptr != str.ptr);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
664 ASSERT_ZERO_TERMINATED(repl);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
665 CX_TEST_ASSERT(0 == strcmp(repl.ptr, expected));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
666 ASSERT_ZERO_TERMINATED(repln);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
667 CX_TEST_ASSERT(0 == strcmp(repln.ptr, expectedn));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
668 ASSERT_ZERO_TERMINATED(longrepl);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
669 CX_TEST_ASSERT(0 == strcmp(longrepl.ptr, longexpect));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
670 ASSERT_ZERO_TERMINATED(replnotrail);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
671 CX_TEST_ASSERT(0 == strcmp(replnotrail.ptr, notrailexpect));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
672 ASSERT_ZERO_TERMINATED(repleq);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
673 CX_TEST_ASSERT(0 == strcmp(repleq.ptr, eqexpect));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
674 ASSERT_ZERO_TERMINATED(replempty1);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
675 CX_TEST_ASSERT(0 == strcmp(replempty1.ptr, ""));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
676 ASSERT_ZERO_TERMINATED(replempty2);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
677 CX_TEST_ASSERT(0 == strcmp(replempty2.ptr, emptyexpect2));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
678 ASSERT_ZERO_TERMINATED(replpre);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
679 CX_TEST_ASSERT(0 == strcmp(replpre.ptr, preexpected));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
680 ASSERT_ZERO_TERMINATED(replan1);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
681 CX_TEST_ASSERT(0 == strcmp(replan1.ptr, an1expected));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
682 ASSERT_ZERO_TERMINATED(replan4);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
683 CX_TEST_ASSERT(0 == strcmp(replan4.ptr, an4expected));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
684 ASSERT_ZERO_TERMINATED(replan9);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
685 CX_TEST_ASSERT(0 == strcmp(replan9.ptr, an9expected));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
686 ASSERT_ZERO_TERMINATED(replan10);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
687 CX_TEST_ASSERT(0 == strcmp(replan10.ptr, an10expected));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
688 ASSERT_ZERO_TERMINATED(repl1_a);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
689 CX_TEST_ASSERT(0 == strcmp(repl1_a.ptr, expeced1_a));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
690 ASSERT_ZERO_TERMINATED(repl2_a);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
691 CX_TEST_ASSERT(0 == strcmp(repl2_a.ptr, expected2_a));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
692
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
693 cx_strfree_a(alloc, &repl1_a);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
694 cx_strfree_a(alloc, &repl2_a);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
695 CX_TEST_ASSERT(cx_testing_allocator_verify(&talloc));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
696 }
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
697
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
698 cx_strfree(&repl);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
699 cx_strfree(&repln);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
700 cx_strfree(&longrepl);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
701 cx_strfree(&replnotrail);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
702 cx_strfree(&repleq);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
703 cx_strfree(&replempty1);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
704 cx_strfree(&replempty2);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
705 cx_strfree(&replpre);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
706 cx_strfree(&replan1);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
707 cx_strfree(&replan4);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
708 cx_strfree(&replan9);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
709 cx_strfree(&replan10);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
710 cx_testing_allocator_destroy(&talloc);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
711 }
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
712
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
713 CX_TEST(test_strupper) {
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
714 cxmutstr str = cx_strdup(CX_STR("thIs 1s @ Te$t"));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
715 CX_TEST_DO {
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
716 cx_strupper(str);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
717 CX_TEST_ASSERT(0 == strcmp(str.ptr, "THIS 1S @ TE$T"));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
718 }
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
719 cx_strfree(&str);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
720 }
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
721
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
722 CX_TEST(test_strlower) {
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
723 cxmutstr str = cx_strdup(CX_STR("thIs 1s @ Te$t"));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
724 CX_TEST_DO {
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
725 cx_strlower(str);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
726 CX_TEST_ASSERT(0 == strcmp(str.ptr, "this 1s @ te$t"));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
727 }
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
728 cx_strfree(&str);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
729 }
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
730
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
731 CX_TEST(test_strtok) {
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
732 cxstring str = CX_STR("a,comma,separated,string");
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
733 cxstring delim = CX_STR(",");
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
734 CX_TEST_DO {
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
735 CxStrtokCtx ctx = cx_strtok(str, delim, 3);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
736 CX_TEST_ASSERT(ctx.str.ptr == str.ptr);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
737 CX_TEST_ASSERT(ctx.str.length == str.length);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
738 CX_TEST_ASSERT(ctx.delim.ptr == delim.ptr);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
739 CX_TEST_ASSERT(ctx.delim.length == delim.length);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
740 CX_TEST_ASSERT(ctx.limit == 3);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
741 CX_TEST_ASSERT(ctx.found == 0);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
742 CX_TEST_ASSERT(ctx.pos == 0);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
743 CX_TEST_ASSERT(ctx.next_pos == 0);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
744 CX_TEST_ASSERT(ctx.delim_more == NULL);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
745 CX_TEST_ASSERT(ctx.delim_more_count == 0);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
746 }
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
747 }
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
748
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
749 CX_TEST(test_strtok_m) {
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
750 cxmutstr str = cx_strdup(CX_STR("a,comma,separated,string"));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
751 cxstring delim = CX_STR(",");
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
752 CX_TEST_DO {
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
753 CxStrtokCtx ctx = cx_strtok_m(str, delim, 3);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
754 CX_TEST_ASSERT(ctx.str.ptr == str.ptr);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
755 CX_TEST_ASSERT(ctx.str.length == str.length);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
756 CX_TEST_ASSERT(ctx.delim.ptr == delim.ptr);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
757 CX_TEST_ASSERT(ctx.delim.length == delim.length);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
758 CX_TEST_ASSERT(ctx.limit == 3);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
759 CX_TEST_ASSERT(ctx.found == 0);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
760 CX_TEST_ASSERT(ctx.pos == 0);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
761 CX_TEST_ASSERT(ctx.next_pos == 0);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
762 CX_TEST_ASSERT(ctx.delim_more == NULL);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
763 CX_TEST_ASSERT(ctx.delim_more_count == 0);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
764 }
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
765 cx_strfree(&str);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
766 }
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
767
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
768 CX_TEST(test_strtok_delim) {
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
769 cxstring str = CX_STR("an,arbitrarily|separated;string");
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
770 cxstring delim = CX_STR(",");
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
771 cxstring delim_more[2] = {CX_STR("|"), CX_STR(";")};
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
772 CX_TEST_DO {
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
773 CxStrtokCtx ctx = cx_strtok(str, delim, 3);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
774 cx_strtok_delim(&ctx, delim_more, 2);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
775 CX_TEST_ASSERT(ctx.str.ptr == str.ptr);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
776 CX_TEST_ASSERT(ctx.str.length == str.length);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
777 CX_TEST_ASSERT(ctx.delim.ptr == delim.ptr);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
778 CX_TEST_ASSERT(ctx.delim.length == delim.length);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
779 CX_TEST_ASSERT(ctx.limit == 3);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
780 CX_TEST_ASSERT(ctx.found == 0);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
781 CX_TEST_ASSERT(ctx.pos == 0);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
782 CX_TEST_ASSERT(ctx.next_pos == 0);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
783 CX_TEST_ASSERT(ctx.delim_more == delim_more);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
784 CX_TEST_ASSERT(ctx.delim_more_count == 2);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
785 }
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
786 }
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
787
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
788 CX_TEST(test_strtok_next_easy) {
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
789 cxstring str = CX_STR("a,comma,separated,string");
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
790 cxstring delim = CX_STR(",");
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
791 CX_TEST_DO {
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
792 CxStrtokCtx ctx = cx_strtok(str, delim, 3);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
793 bool ret;
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
794 cxstring tok;
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
795
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
796 ret = cx_strtok_next(&ctx, &tok);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
797 CX_TEST_ASSERT(ret);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
798 CX_TEST_ASSERT(0 == cx_strcmp(tok, CX_STR("a")));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
799 CX_TEST_ASSERT(ctx.pos == 0);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
800 CX_TEST_ASSERT(ctx.next_pos == 2);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
801 CX_TEST_ASSERT(ctx.delim_pos == 1);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
802 CX_TEST_ASSERT(ctx.found == 1);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
803
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
804 ret = cx_strtok_next(&ctx, &tok);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
805 CX_TEST_ASSERT(ret);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
806 CX_TEST_ASSERT(0 == cx_strcmp(tok, CX_STR("comma")));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
807 CX_TEST_ASSERT(ctx.pos == 2);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
808 CX_TEST_ASSERT(ctx.next_pos == 8);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
809 CX_TEST_ASSERT(ctx.delim_pos == 7);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
810 CX_TEST_ASSERT(ctx.found == 2);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
811
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
812 ret = cx_strtok_next(&ctx, &tok);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
813 CX_TEST_ASSERT(ret);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
814 CX_TEST_ASSERT(0 == cx_strcmp(tok, CX_STR("separated")));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
815 CX_TEST_ASSERT(ctx.pos == 8);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
816 CX_TEST_ASSERT(ctx.next_pos == 18);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
817 CX_TEST_ASSERT(ctx.delim_pos == 17);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
818 CX_TEST_ASSERT(ctx.found == 3);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
819
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
820 ret = cx_strtok_next(&ctx, &tok);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
821 CX_TEST_ASSERT(!ret);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
822 CX_TEST_ASSERT(ctx.pos == 8);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
823 CX_TEST_ASSERT(ctx.next_pos == 18);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
824 CX_TEST_ASSERT(ctx.delim_pos == 17);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
825 CX_TEST_ASSERT(ctx.found == 3);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
826 }
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
827 }
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
828
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
829 CX_TEST(test_strtok_next_unlimited) {
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
830 cxstring str = CX_STR("some;-;otherwise;-;separated;-;string;-;");
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
831 cxstring delim = CX_STR(";-;");
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
832 CX_TEST_DO {
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
833 CxStrtokCtx ctx = cx_strtok(str, delim, SIZE_MAX);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
834 bool ret;
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
835 cxstring tok;
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
836
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
837 ret = cx_strtok_next(&ctx, &tok);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
838 CX_TEST_ASSERT(ret);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
839 CX_TEST_ASSERT(0 == cx_strcmp(tok, CX_STR("some")));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
840 CX_TEST_ASSERT(ctx.pos == 0);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
841 CX_TEST_ASSERT(ctx.next_pos == 7);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
842 CX_TEST_ASSERT(ctx.delim_pos == 4);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
843 CX_TEST_ASSERT(ctx.found == 1);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
844
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
845 ret = cx_strtok_next(&ctx, &tok);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
846 CX_TEST_ASSERT(ret);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
847 CX_TEST_ASSERT(0 == cx_strcmp(tok, CX_STR("otherwise")));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
848 CX_TEST_ASSERT(ctx.pos == 7);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
849 CX_TEST_ASSERT(ctx.next_pos == 19);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
850 CX_TEST_ASSERT(ctx.delim_pos == 16);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
851 CX_TEST_ASSERT(ctx.found == 2);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
852
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
853 ret = cx_strtok_next(&ctx, &tok);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
854 CX_TEST_ASSERT(ret);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
855 CX_TEST_ASSERT(0 == cx_strcmp(tok, CX_STR("separated")));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
856 CX_TEST_ASSERT(ctx.pos == 19);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
857 CX_TEST_ASSERT(ctx.next_pos == 31);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
858 CX_TEST_ASSERT(ctx.delim_pos == 28);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
859 CX_TEST_ASSERT(ctx.found == 3);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
860
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
861 ret = cx_strtok_next(&ctx, &tok);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
862 CX_TEST_ASSERT(ret);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
863 CX_TEST_ASSERT(0 == cx_strcmp(tok, CX_STR("string")));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
864 CX_TEST_ASSERT(ctx.pos == 31);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
865 CX_TEST_ASSERT(ctx.next_pos == 40);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
866 CX_TEST_ASSERT(ctx.delim_pos == 37);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
867 CX_TEST_ASSERT(ctx.found == 4);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
868
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
869 ret = cx_strtok_next(&ctx, &tok);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
870 CX_TEST_ASSERT(ret);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
871 CX_TEST_ASSERT(0 == cx_strcmp(tok, CX_STR("")));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
872 CX_TEST_ASSERT(ctx.pos == 40);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
873 CX_TEST_ASSERT(ctx.next_pos == 40);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
874 CX_TEST_ASSERT(ctx.delim_pos == 40);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
875 CX_TEST_ASSERT(ctx.found == 5);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
876
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
877 ret = cx_strtok_next(&ctx, &tok);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
878 CX_TEST_ASSERT(!ret);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
879 CX_TEST_ASSERT(ctx.pos == 40);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
880 CX_TEST_ASSERT(ctx.delim_pos == 40);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
881 CX_TEST_ASSERT(ctx.found == 5);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
882 }
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
883 }
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
884
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
885 CX_TEST(test_strtok_next_advanced) {
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
886 cxmutstr str = cx_strdup(CX_STR("an,arbitrarily;||separated;string"));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
887 cxstring delim = CX_STR(",");
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
888 cxstring delim_more[2] = {CX_STR("||"), CX_STR(";")};
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
889 CX_TEST_DO {
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
890 CxStrtokCtx ctx = cx_strtok_m(str, delim, 10);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
891 cx_strtok_delim(&ctx, delim_more, 2);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
892 bool ret;
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
893 cxmutstr tok;
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
894
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
895 ret = cx_strtok_next_m(&ctx, &tok);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
896 CX_TEST_ASSERT(ret);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
897 CX_TEST_ASSERT(0 == cx_strcmp(cx_strcast(tok), CX_STR("an")));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
898 CX_TEST_ASSERT(ctx.pos == 0);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
899 CX_TEST_ASSERT(ctx.next_pos == 3);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
900 CX_TEST_ASSERT(ctx.delim_pos == 2);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
901 CX_TEST_ASSERT(ctx.found == 1);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
902 cx_strupper(tok);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
903
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
904 ret = cx_strtok_next_m(&ctx, &tok);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
905 CX_TEST_ASSERT(ret);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
906 CX_TEST_ASSERT(0 == cx_strcmp(cx_strcast(tok), CX_STR("arbitrarily")));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
907 CX_TEST_ASSERT(ctx.pos == 3);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
908 CX_TEST_ASSERT(ctx.next_pos == 15);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
909 CX_TEST_ASSERT(ctx.delim_pos == 14);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
910 CX_TEST_ASSERT(ctx.found == 2);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
911 cx_strupper(tok);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
912
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
913 ret = cx_strtok_next_m(&ctx, &tok);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
914 CX_TEST_ASSERT(ret);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
915 CX_TEST_ASSERT(0 == cx_strcmp(cx_strcast(tok), CX_STR("")));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
916 CX_TEST_ASSERT(ctx.pos == 15);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
917 CX_TEST_ASSERT(ctx.next_pos == 17);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
918 CX_TEST_ASSERT(ctx.delim_pos == 15);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
919 CX_TEST_ASSERT(ctx.found == 3);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
920 cx_strupper(tok);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
921
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
922 ret = cx_strtok_next_m(&ctx, &tok);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
923 CX_TEST_ASSERT(ret);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
924 CX_TEST_ASSERT(0 == cx_strcmp(cx_strcast(tok), CX_STR("separated")));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
925 CX_TEST_ASSERT(ctx.pos == 17);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
926 CX_TEST_ASSERT(ctx.next_pos == 27);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
927 CX_TEST_ASSERT(ctx.delim_pos == 26);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
928 CX_TEST_ASSERT(ctx.found == 4);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
929 cx_strupper(tok);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
930
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
931 ret = cx_strtok_next_m(&ctx, &tok);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
932 CX_TEST_ASSERT(ret);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
933 CX_TEST_ASSERT(0 == cx_strcmp(cx_strcast(tok), CX_STR("string")));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
934 CX_TEST_ASSERT(ctx.pos == 27);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
935 CX_TEST_ASSERT(ctx.next_pos == 33);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
936 CX_TEST_ASSERT(ctx.delim_pos == 33);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
937 CX_TEST_ASSERT(ctx.found == 5);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
938 cx_strupper(tok);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
939
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
940 ret = cx_strtok_next_m(&ctx, &tok);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
941 CX_TEST_ASSERT(!ret);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
942 CX_TEST_ASSERT(ctx.pos == 27);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
943 CX_TEST_ASSERT(ctx.next_pos == 33);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
944 CX_TEST_ASSERT(ctx.delim_pos == 33);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
945 CX_TEST_ASSERT(ctx.found == 5);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
946
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
947 CX_TEST_ASSERT(0 == cx_strcmp(cx_strcast(str), CX_STR("AN,ARBITRARILY;||SEPARATED;STRING")));
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
948 }
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
949 cx_strfree(&str);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
950 }
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
951
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
952
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
953 CxTestSuite *cx_test_suite_string(void) {
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
954 CxTestSuite *suite = cx_test_suite_new("string");
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
955
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
956 cx_test_register(suite, test_string_construct);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
957 cx_test_register(suite, test_strfree);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
958 cx_test_register(suite, test_strdup);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
959 cx_test_register(suite, test_strdup_shortened);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
960 cx_test_register(suite, test_strlen);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
961 cx_test_register(suite, test_strsubs);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
962 cx_test_register(suite, test_strchr);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
963 cx_test_register(suite, test_strrchr);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
964 cx_test_register(suite, test_strstr);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
965 cx_test_register(suite, test_strcmp);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
966 cx_test_register(suite, test_strcasecmp);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
967 cx_test_register(suite, test_strcat);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
968 cx_test_register(suite, test_strsplit);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
969 cx_test_register(suite, test_strsplit_a);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
970 cx_test_register(suite, test_strtrim);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
971 cx_test_register(suite, test_strprefix);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
972 cx_test_register(suite, test_strsuffix);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
973 cx_test_register(suite, test_strcaseprefix);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
974 cx_test_register(suite, test_strcasesuffix);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
975 cx_test_register(suite, test_strreplace);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
976 cx_test_register(suite, test_strupper);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
977 cx_test_register(suite, test_strlower);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
978 cx_test_register(suite, test_strtok);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
979 cx_test_register(suite, test_strtok_m);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
980 cx_test_register(suite, test_strtok_delim);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
981 cx_test_register(suite, test_strtok_next_easy);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
982 cx_test_register(suite, test_strtok_next_unlimited);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
983 cx_test_register(suite, test_strtok_next_advanced);
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
984
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
985 return suite;
e5b29e6f0615 migrate string tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
986 }

mercurial