test/test_string.cpp

changeset 628
1e2be40f0cb5
parent 598
70b7456b5b12
child 645
ec50abb285ad
--- a/test/test_string.cpp	Sun Nov 20 17:48:42 2022 +0100
+++ b/test/test_string.cpp	Sun Nov 20 21:08:36 2022 +0100
@@ -272,22 +272,22 @@
     cxstring list[8];
     size_t n;
 
-    /* special case: empty string */
+    // special case: empty string
     n = cx_strsplit(test, cx_str(""), capa, list);
     ASSERT_EQ(n, 1);
     EXPECT_EQ(cx_strcmp(list[0], test), 0);
 
-    /* no delimiter occurrence */
+    // no delimiter occurrence
     n = cx_strsplit(test, cx_str("z"), capa, list);
     ASSERT_EQ(n, 1);
     EXPECT_EQ(cx_strcmp(list[0], test), 0);
 
-    /* partially matching delimiter */
+    // partially matching delimiter
     n = cx_strsplit(test, cx_str("is,not"), capa, list);
     ASSERT_EQ(n, 1);
     EXPECT_EQ(cx_strcmp(list[0], test), 0);
 
-    /* matching single-char delimiter */
+    // matching single-char delimiter
     n = cx_strsplit(test, cx_str(","), capa, list);
     ASSERT_EQ(n, 5);
     EXPECT_EQ(cx_strcmp(list[0], cx_str("this")), 0);
@@ -296,65 +296,65 @@
     EXPECT_EQ(cx_strcmp(list[3], cx_str("csv")), 0);
     EXPECT_EQ(cx_strcmp(list[4], cx_str("string")), 0);
 
-    /* matching multi-char delimiter */
+    // matching multi-char delimiter
     n = cx_strsplit(test, cx_str("is"), capa, list);
     ASSERT_EQ(n, 3);
     EXPECT_EQ(cx_strcmp(list[0], cx_str("th")), 0);
     EXPECT_EQ(cx_strcmp(list[1], cx_str(",")), 0);
     EXPECT_EQ(cx_strcmp(list[2], cx_str(",a,csv,string")), 0);
 
-    /* bounded list using single-char delimiter */
+    // bounded list using single-char delimiter
     n = cx_strsplit(test, cx_str(","), 3, list);
     ASSERT_EQ(n, 3);
     EXPECT_EQ(cx_strcmp(list[0], cx_str("this")), 0);
     EXPECT_EQ(cx_strcmp(list[1], cx_str("is")), 0);
     EXPECT_EQ(cx_strcmp(list[2], cx_str("a,csv,string")), 0);
 
-    /* bounded list using multi-char delimiter */
+    // bounded list using multi-char delimiter
     n = cx_strsplit(test, cx_str("is"), 2, list);
     ASSERT_EQ(n, 2);
     EXPECT_EQ(cx_strcmp(list[0], cx_str("th")), 0);
     EXPECT_EQ(cx_strcmp(list[1], cx_str(",is,a,csv,string")), 0);
 
-    /* start with delimiter */
+    // start with delimiter
     n = cx_strsplit(test, cx_str("this"), capa, list);
     ASSERT_EQ(n, 2);
     EXPECT_EQ(cx_strcmp(list[0], cx_str("")), 0);
     EXPECT_EQ(cx_strcmp(list[1], cx_str(",is,a,csv,string")), 0);
 
-    /* end with delimiter */
+    // end with delimiter
     n = cx_strsplit(test, cx_str("string"), capa, list);
     ASSERT_EQ(n, 2);
     EXPECT_EQ(cx_strcmp(list[0], cx_str("this,is,a,csv,")), 0);
     EXPECT_EQ(cx_strcmp(list[1], cx_str("")), 0);
 
 
-    /* end with delimiter exceed bound */
+    // end with delimiter exceed bound
     n = cx_strsplit(cx_str("a,b,c,"), cx_str(","), 3, list);
     ASSERT_EQ(n, 3);
     EXPECT_EQ(cx_strcmp(list[0], cx_str("a")), 0);
     EXPECT_EQ(cx_strcmp(list[1], cx_str("b")), 0);
     EXPECT_EQ(cx_strcmp(list[2], cx_str("c,")), 0);
 
-    /* exact match */
+    // exact match
     n = cx_strsplit(test, cx_str("this,is,a,csv,string"), capa, list);
     ASSERT_EQ(n, 2);
     EXPECT_EQ(cx_strcmp(list[0], cx_str("")), 0);
     EXPECT_EQ(cx_strcmp(list[1], cx_str("")), 0);
 
-    /* string to be split is only substring */
+    // string to be split is only substring
     n = cx_strsplit(test, cx_str("this,is,a,csv,string,with,extension"), capa, list);
     ASSERT_EQ(n, 1);
     EXPECT_EQ(cx_strcmp(list[0], test), 0);
 
-    /* subsequent encounter of delimiter (the string between is empty) */
+    // subsequent encounter of delimiter (the string between is empty)
     n = cx_strsplit(test, cx_str("is,"), capa, list);
     ASSERT_EQ(n, 3);
     EXPECT_EQ(cx_strcmp(list[0], cx_str("th")), 0);
     EXPECT_EQ(cx_strcmp(list[1], cx_str("")), 0);
     EXPECT_EQ(cx_strcmp(list[2], cx_str("a,csv,string")), 0);
 
-    /* call the _m variant just for coverage */
+    // call the _m variant just for coverage
     auto mtest = cx_strdup(test);
     cxmutstr mlist[4];
     n = cx_strsplit_m(mtest, cx_str("is,"), 4, mlist);
@@ -373,25 +373,25 @@
     cxstring *list;
     size_t n;
 
-    /* special case: empty string */
+    // special case: empty string
     n = cx_strsplit_a(&alloc, test, cx_str(""), capa, &list);
     ASSERT_EQ(n, 1);
     EXPECT_EQ(cx_strcmp(list[0], test), 0);
     cxFree(&alloc, list);
 
-    /* no delimiter occurrence */
+    // no delimiter occurrence
     n = cx_strsplit_a(&alloc, test, cx_str("z"), capa, &list);
     ASSERT_EQ(n, 1);
     EXPECT_EQ(cx_strcmp(list[0], test), 0);
     cxFree(&alloc, list);
 
-    /* partially matching delimiter */
+    // partially matching delimiter
     n = cx_strsplit_a(&alloc, test, cx_str("is,not"), capa, &list);
     ASSERT_EQ(n, 1);
     EXPECT_EQ(cx_strcmp(list[0], test), 0);
     cxFree(&alloc, list);
 
-    /* matching single-char delimiter */
+    // matching single-char delimiter
     n = cx_strsplit_a(&alloc, test, cx_str(","), capa, &list);
     ASSERT_EQ(n, 5);
     EXPECT_EQ(cx_strcmp(list[0], cx_str("this")), 0);
@@ -401,7 +401,7 @@
     EXPECT_EQ(cx_strcmp(list[4], cx_str("string")), 0);
     cxFree(&alloc, list);
 
-    /* matching multi-char delimiter */
+    // matching multi-char delimiter
     n = cx_strsplit_a(&alloc, test, cx_str("is"), capa, &list);
     ASSERT_EQ(n, 3);
     EXPECT_EQ(cx_strcmp(list[0], cx_str("th")), 0);
@@ -409,7 +409,7 @@
     EXPECT_EQ(cx_strcmp(list[2], cx_str(",a,csv,string")), 0);
     cxFree(&alloc, list);
 
-    /* bounded list using single-char delimiter */
+    // bounded list using single-char delimiter
     n = cx_strsplit_a(&alloc, test, cx_str(","), 3, &list);
     ASSERT_EQ(n, 3);
     EXPECT_EQ(cx_strcmp(list[0], cx_str("this")), 0);
@@ -417,28 +417,28 @@
     EXPECT_EQ(cx_strcmp(list[2], cx_str("a,csv,string")), 0);
     cxFree(&alloc, list);
 
-    /* bounded list using multi-char delimiter */
+    // bounded list using multi-char delimiter
     n = cx_strsplit_a(&alloc, test, cx_str("is"), 2, &list);
     ASSERT_EQ(n, 2);
     EXPECT_EQ(cx_strcmp(list[0], cx_str("th")), 0);
     EXPECT_EQ(cx_strcmp(list[1], cx_str(",is,a,csv,string")), 0);
     cxFree(&alloc, list);
 
-    /* start with delimiter */
+    // start with delimiter
     n = cx_strsplit_a(&alloc, test, cx_str("this"), capa, &list);
     ASSERT_EQ(n, 2);
     EXPECT_EQ(cx_strcmp(list[0], cx_str("")), 0);
     EXPECT_EQ(cx_strcmp(list[1], cx_str(",is,a,csv,string")), 0);
     cxFree(&alloc, list);
 
-    /* end with delimiter */
+    // end with delimiter
     n = cx_strsplit_a(&alloc, test, cx_str("string"), capa, &list);
     ASSERT_EQ(n, 2);
     EXPECT_EQ(cx_strcmp(list[0], cx_str("this,is,a,csv,")), 0);
     EXPECT_EQ(cx_strcmp(list[1], cx_str("")), 0);
     cxFree(&alloc, list);
 
-    /* end with delimiter exceed bound */
+    // end with delimiter exceed bound
     n = cx_strsplit_a(&alloc, cx_str("a,b,c,"), cx_str(","), 3, &list);
     ASSERT_EQ(n, 3);
     EXPECT_EQ(cx_strcmp(list[0], cx_str("a")), 0);
@@ -446,20 +446,20 @@
     EXPECT_EQ(cx_strcmp(list[2], cx_str("c,")), 0);
     cxFree(&alloc, list);
 
-    /* exact match */
+    // exact match
     n = cx_strsplit_a(&alloc, test, cx_str("this,is,a,csv,string"), capa, &list);
     ASSERT_EQ(n, 2);
     EXPECT_EQ(cx_strcmp(list[0], cx_str("")), 0);
     EXPECT_EQ(cx_strcmp(list[1], cx_str("")), 0);
     cxFree(&alloc, list);
 
-    /* string to be split is only substring */
+    // string to be split is only substring
     n = cx_strsplit_a(&alloc, test, cx_str("this,is,a,csv,string,with,extension"), capa, &list);
     ASSERT_EQ(n, 1);
     EXPECT_EQ(cx_strcmp(list[0], test), 0);
     cxFree(&alloc, list);
 
-    /* subsequent encounter of delimiter (the string between is empty) */
+    // subsequent encounter of delimiter (the string between is empty)
     n = cx_strsplit_a(&alloc, test, cx_str("is,"), capa, &list);
     ASSERT_EQ(n, 3);
     EXPECT_EQ(cx_strcmp(list[0], cx_str("th")), 0);
@@ -467,7 +467,7 @@
     EXPECT_EQ(cx_strcmp(list[2], cx_str("a,csv,string")), 0);
     cxFree(&alloc, list);
 
-    /* call the _m variant just for coverage */
+    // call the _m variant just for coverage
     auto mtest = cx_strdup(test);
     cxmutstr *mlist;
     n = cx_strsplit_ma(&alloc, mtest, cx_str("is,"), 4, &mlist);
@@ -496,7 +496,7 @@
     EXPECT_EQ(cx_strcmp(t5, cx_str("")), 0);
     EXPECT_EQ(cx_strcmp(empty, cx_str("")), 0);
 
-    /* call the _m variant just for coverage */
+    // call the _m variant just for coverage
     cxmutstr m1 = cx_strtrim_m(cx_mutstr((char *) "  ein test  \t "));
     EXPECT_EQ(cx_strcmp(cx_strcast(m1), cx_str("ein test")), 0);
 }

mercurial