test/test_string.cpp

changeset 628
1e2be40f0cb5
parent 598
70b7456b5b12
child 645
ec50abb285ad
     1.1 --- a/test/test_string.cpp	Sun Nov 20 17:48:42 2022 +0100
     1.2 +++ b/test/test_string.cpp	Sun Nov 20 21:08:36 2022 +0100
     1.3 @@ -272,22 +272,22 @@
     1.4      cxstring list[8];
     1.5      size_t n;
     1.6  
     1.7 -    /* special case: empty string */
     1.8 +    // special case: empty string
     1.9      n = cx_strsplit(test, cx_str(""), capa, list);
    1.10      ASSERT_EQ(n, 1);
    1.11      EXPECT_EQ(cx_strcmp(list[0], test), 0);
    1.12  
    1.13 -    /* no delimiter occurrence */
    1.14 +    // no delimiter occurrence
    1.15      n = cx_strsplit(test, cx_str("z"), capa, list);
    1.16      ASSERT_EQ(n, 1);
    1.17      EXPECT_EQ(cx_strcmp(list[0], test), 0);
    1.18  
    1.19 -    /* partially matching delimiter */
    1.20 +    // partially matching delimiter
    1.21      n = cx_strsplit(test, cx_str("is,not"), capa, list);
    1.22      ASSERT_EQ(n, 1);
    1.23      EXPECT_EQ(cx_strcmp(list[0], test), 0);
    1.24  
    1.25 -    /* matching single-char delimiter */
    1.26 +    // matching single-char delimiter
    1.27      n = cx_strsplit(test, cx_str(","), capa, list);
    1.28      ASSERT_EQ(n, 5);
    1.29      EXPECT_EQ(cx_strcmp(list[0], cx_str("this")), 0);
    1.30 @@ -296,65 +296,65 @@
    1.31      EXPECT_EQ(cx_strcmp(list[3], cx_str("csv")), 0);
    1.32      EXPECT_EQ(cx_strcmp(list[4], cx_str("string")), 0);
    1.33  
    1.34 -    /* matching multi-char delimiter */
    1.35 +    // matching multi-char delimiter
    1.36      n = cx_strsplit(test, cx_str("is"), capa, list);
    1.37      ASSERT_EQ(n, 3);
    1.38      EXPECT_EQ(cx_strcmp(list[0], cx_str("th")), 0);
    1.39      EXPECT_EQ(cx_strcmp(list[1], cx_str(",")), 0);
    1.40      EXPECT_EQ(cx_strcmp(list[2], cx_str(",a,csv,string")), 0);
    1.41  
    1.42 -    /* bounded list using single-char delimiter */
    1.43 +    // bounded list using single-char delimiter
    1.44      n = cx_strsplit(test, cx_str(","), 3, list);
    1.45      ASSERT_EQ(n, 3);
    1.46      EXPECT_EQ(cx_strcmp(list[0], cx_str("this")), 0);
    1.47      EXPECT_EQ(cx_strcmp(list[1], cx_str("is")), 0);
    1.48      EXPECT_EQ(cx_strcmp(list[2], cx_str("a,csv,string")), 0);
    1.49  
    1.50 -    /* bounded list using multi-char delimiter */
    1.51 +    // bounded list using multi-char delimiter
    1.52      n = cx_strsplit(test, cx_str("is"), 2, list);
    1.53      ASSERT_EQ(n, 2);
    1.54      EXPECT_EQ(cx_strcmp(list[0], cx_str("th")), 0);
    1.55      EXPECT_EQ(cx_strcmp(list[1], cx_str(",is,a,csv,string")), 0);
    1.56  
    1.57 -    /* start with delimiter */
    1.58 +    // start with delimiter
    1.59      n = cx_strsplit(test, cx_str("this"), capa, list);
    1.60      ASSERT_EQ(n, 2);
    1.61      EXPECT_EQ(cx_strcmp(list[0], cx_str("")), 0);
    1.62      EXPECT_EQ(cx_strcmp(list[1], cx_str(",is,a,csv,string")), 0);
    1.63  
    1.64 -    /* end with delimiter */
    1.65 +    // end with delimiter
    1.66      n = cx_strsplit(test, cx_str("string"), capa, list);
    1.67      ASSERT_EQ(n, 2);
    1.68      EXPECT_EQ(cx_strcmp(list[0], cx_str("this,is,a,csv,")), 0);
    1.69      EXPECT_EQ(cx_strcmp(list[1], cx_str("")), 0);
    1.70  
    1.71  
    1.72 -    /* end with delimiter exceed bound */
    1.73 +    // end with delimiter exceed bound
    1.74      n = cx_strsplit(cx_str("a,b,c,"), cx_str(","), 3, list);
    1.75      ASSERT_EQ(n, 3);
    1.76      EXPECT_EQ(cx_strcmp(list[0], cx_str("a")), 0);
    1.77      EXPECT_EQ(cx_strcmp(list[1], cx_str("b")), 0);
    1.78      EXPECT_EQ(cx_strcmp(list[2], cx_str("c,")), 0);
    1.79  
    1.80 -    /* exact match */
    1.81 +    // exact match
    1.82      n = cx_strsplit(test, cx_str("this,is,a,csv,string"), capa, list);
    1.83      ASSERT_EQ(n, 2);
    1.84      EXPECT_EQ(cx_strcmp(list[0], cx_str("")), 0);
    1.85      EXPECT_EQ(cx_strcmp(list[1], cx_str("")), 0);
    1.86  
    1.87 -    /* string to be split is only substring */
    1.88 +    // string to be split is only substring
    1.89      n = cx_strsplit(test, cx_str("this,is,a,csv,string,with,extension"), capa, list);
    1.90      ASSERT_EQ(n, 1);
    1.91      EXPECT_EQ(cx_strcmp(list[0], test), 0);
    1.92  
    1.93 -    /* subsequent encounter of delimiter (the string between is empty) */
    1.94 +    // subsequent encounter of delimiter (the string between is empty)
    1.95      n = cx_strsplit(test, cx_str("is,"), capa, list);
    1.96      ASSERT_EQ(n, 3);
    1.97      EXPECT_EQ(cx_strcmp(list[0], cx_str("th")), 0);
    1.98      EXPECT_EQ(cx_strcmp(list[1], cx_str("")), 0);
    1.99      EXPECT_EQ(cx_strcmp(list[2], cx_str("a,csv,string")), 0);
   1.100  
   1.101 -    /* call the _m variant just for coverage */
   1.102 +    // call the _m variant just for coverage
   1.103      auto mtest = cx_strdup(test);
   1.104      cxmutstr mlist[4];
   1.105      n = cx_strsplit_m(mtest, cx_str("is,"), 4, mlist);
   1.106 @@ -373,25 +373,25 @@
   1.107      cxstring *list;
   1.108      size_t n;
   1.109  
   1.110 -    /* special case: empty string */
   1.111 +    // special case: empty string
   1.112      n = cx_strsplit_a(&alloc, test, cx_str(""), capa, &list);
   1.113      ASSERT_EQ(n, 1);
   1.114      EXPECT_EQ(cx_strcmp(list[0], test), 0);
   1.115      cxFree(&alloc, list);
   1.116  
   1.117 -    /* no delimiter occurrence */
   1.118 +    // no delimiter occurrence
   1.119      n = cx_strsplit_a(&alloc, test, cx_str("z"), capa, &list);
   1.120      ASSERT_EQ(n, 1);
   1.121      EXPECT_EQ(cx_strcmp(list[0], test), 0);
   1.122      cxFree(&alloc, list);
   1.123  
   1.124 -    /* partially matching delimiter */
   1.125 +    // partially matching delimiter
   1.126      n = cx_strsplit_a(&alloc, test, cx_str("is,not"), capa, &list);
   1.127      ASSERT_EQ(n, 1);
   1.128      EXPECT_EQ(cx_strcmp(list[0], test), 0);
   1.129      cxFree(&alloc, list);
   1.130  
   1.131 -    /* matching single-char delimiter */
   1.132 +    // matching single-char delimiter
   1.133      n = cx_strsplit_a(&alloc, test, cx_str(","), capa, &list);
   1.134      ASSERT_EQ(n, 5);
   1.135      EXPECT_EQ(cx_strcmp(list[0], cx_str("this")), 0);
   1.136 @@ -401,7 +401,7 @@
   1.137      EXPECT_EQ(cx_strcmp(list[4], cx_str("string")), 0);
   1.138      cxFree(&alloc, list);
   1.139  
   1.140 -    /* matching multi-char delimiter */
   1.141 +    // matching multi-char delimiter
   1.142      n = cx_strsplit_a(&alloc, test, cx_str("is"), capa, &list);
   1.143      ASSERT_EQ(n, 3);
   1.144      EXPECT_EQ(cx_strcmp(list[0], cx_str("th")), 0);
   1.145 @@ -409,7 +409,7 @@
   1.146      EXPECT_EQ(cx_strcmp(list[2], cx_str(",a,csv,string")), 0);
   1.147      cxFree(&alloc, list);
   1.148  
   1.149 -    /* bounded list using single-char delimiter */
   1.150 +    // bounded list using single-char delimiter
   1.151      n = cx_strsplit_a(&alloc, test, cx_str(","), 3, &list);
   1.152      ASSERT_EQ(n, 3);
   1.153      EXPECT_EQ(cx_strcmp(list[0], cx_str("this")), 0);
   1.154 @@ -417,28 +417,28 @@
   1.155      EXPECT_EQ(cx_strcmp(list[2], cx_str("a,csv,string")), 0);
   1.156      cxFree(&alloc, list);
   1.157  
   1.158 -    /* bounded list using multi-char delimiter */
   1.159 +    // bounded list using multi-char delimiter
   1.160      n = cx_strsplit_a(&alloc, test, cx_str("is"), 2, &list);
   1.161      ASSERT_EQ(n, 2);
   1.162      EXPECT_EQ(cx_strcmp(list[0], cx_str("th")), 0);
   1.163      EXPECT_EQ(cx_strcmp(list[1], cx_str(",is,a,csv,string")), 0);
   1.164      cxFree(&alloc, list);
   1.165  
   1.166 -    /* start with delimiter */
   1.167 +    // start with delimiter
   1.168      n = cx_strsplit_a(&alloc, test, cx_str("this"), capa, &list);
   1.169      ASSERT_EQ(n, 2);
   1.170      EXPECT_EQ(cx_strcmp(list[0], cx_str("")), 0);
   1.171      EXPECT_EQ(cx_strcmp(list[1], cx_str(",is,a,csv,string")), 0);
   1.172      cxFree(&alloc, list);
   1.173  
   1.174 -    /* end with delimiter */
   1.175 +    // end with delimiter
   1.176      n = cx_strsplit_a(&alloc, test, cx_str("string"), capa, &list);
   1.177      ASSERT_EQ(n, 2);
   1.178      EXPECT_EQ(cx_strcmp(list[0], cx_str("this,is,a,csv,")), 0);
   1.179      EXPECT_EQ(cx_strcmp(list[1], cx_str("")), 0);
   1.180      cxFree(&alloc, list);
   1.181  
   1.182 -    /* end with delimiter exceed bound */
   1.183 +    // end with delimiter exceed bound
   1.184      n = cx_strsplit_a(&alloc, cx_str("a,b,c,"), cx_str(","), 3, &list);
   1.185      ASSERT_EQ(n, 3);
   1.186      EXPECT_EQ(cx_strcmp(list[0], cx_str("a")), 0);
   1.187 @@ -446,20 +446,20 @@
   1.188      EXPECT_EQ(cx_strcmp(list[2], cx_str("c,")), 0);
   1.189      cxFree(&alloc, list);
   1.190  
   1.191 -    /* exact match */
   1.192 +    // exact match
   1.193      n = cx_strsplit_a(&alloc, test, cx_str("this,is,a,csv,string"), capa, &list);
   1.194      ASSERT_EQ(n, 2);
   1.195      EXPECT_EQ(cx_strcmp(list[0], cx_str("")), 0);
   1.196      EXPECT_EQ(cx_strcmp(list[1], cx_str("")), 0);
   1.197      cxFree(&alloc, list);
   1.198  
   1.199 -    /* string to be split is only substring */
   1.200 +    // string to be split is only substring
   1.201      n = cx_strsplit_a(&alloc, test, cx_str("this,is,a,csv,string,with,extension"), capa, &list);
   1.202      ASSERT_EQ(n, 1);
   1.203      EXPECT_EQ(cx_strcmp(list[0], test), 0);
   1.204      cxFree(&alloc, list);
   1.205  
   1.206 -    /* subsequent encounter of delimiter (the string between is empty) */
   1.207 +    // subsequent encounter of delimiter (the string between is empty)
   1.208      n = cx_strsplit_a(&alloc, test, cx_str("is,"), capa, &list);
   1.209      ASSERT_EQ(n, 3);
   1.210      EXPECT_EQ(cx_strcmp(list[0], cx_str("th")), 0);
   1.211 @@ -467,7 +467,7 @@
   1.212      EXPECT_EQ(cx_strcmp(list[2], cx_str("a,csv,string")), 0);
   1.213      cxFree(&alloc, list);
   1.214  
   1.215 -    /* call the _m variant just for coverage */
   1.216 +    // call the _m variant just for coverage
   1.217      auto mtest = cx_strdup(test);
   1.218      cxmutstr *mlist;
   1.219      n = cx_strsplit_ma(&alloc, mtest, cx_str("is,"), 4, &mlist);
   1.220 @@ -496,7 +496,7 @@
   1.221      EXPECT_EQ(cx_strcmp(t5, cx_str("")), 0);
   1.222      EXPECT_EQ(cx_strcmp(empty, cx_str("")), 0);
   1.223  
   1.224 -    /* call the _m variant just for coverage */
   1.225 +    // call the _m variant just for coverage
   1.226      cxmutstr m1 = cx_strtrim_m(cx_mutstr((char *) "  ein test  \t "));
   1.227      EXPECT_EQ(cx_strcmp(cx_strcast(m1), cx_str("ein test")), 0);
   1.228  }

mercurial