- Timestamp:
- Jan 18, 2024, 10:17:21 PM (14 months ago)
- Branches:
- master
- Children:
- f988834
- Parents:
- 906d8fa
- Location:
- tests/collections
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified tests/collections/.expect/string-api-coverage.txt ¶
r906d8fa re8b3717 51 51 QQQ 52 52 asdfasdfasdf 53 lo 54 hello heliocentric 53 55 e 54 56 help!!!o -
TabularUnified tests/collections/string-api-coverage.cfa ¶
r906d8fa re8b3717 51 51 sout | (s == "hello") | (s == "world"); 52 52 sout | (s != "world") | (s != "hello"); 53 sout | ( frag == s(1, 4) ) | ( s3 == s(1,4) );54 sout | ( s3 != s(1, 4) ) | ( frag != s(1,4) );55 sout | ( s2(1, 4) == s(1,4) ) | ( s3(1,4) == s(1,4) );56 sout | ( s3(1, 4) != s(1,4) ) | ( s2(1,4) != s(1,4) );57 sout | ( s(1, 4) == frag ) | ( s(1,4) == s3 );58 sout | ( s(1, 4) != s3 ) | ( s(1,4) != frag );59 sout | ( s(1, 4) == "ell" ) | ( s(1,4) == "world" );60 sout | ( s(1, 4) != "world" ) | ( s(1,4) != "ell" );53 sout | ( frag == s(1,3) ) | ( s3 == s(1,3) ); 54 sout | ( s3 != s(1,3) ) | ( frag != s(1,3) ); 55 sout | ( s2(1,3) == s(1,3) ) | ( s3(1,3) == s(1,3) ); 56 sout | ( s3(1,3) != s(1,3) ) | ( s2(1,3) != s(1,3) ); 57 sout | ( s(1,3) == frag ) | ( s(1,3) == s3 ); 58 sout | ( s(1,3) != s3 ) | ( s(1,3) != frag ); 59 sout | ( s(1,3) == "ell" ) | ( s(1,3) == "world" ); 60 sout | ( s(1,3) != "world" ) | ( s(1,3) != "ell" ); 61 61 62 62 … … 226 226 // 227 227 228 //... 228 // Range cases treated thoroughly in "string-overwrite" test. 229 // Composability with comparison and search are demoed above and below. 230 // Coverage here adds the single-argument ("rest of string") overload. 231 232 sx = s; 233 sout | sx(3); // lo 234 sx(3) = "iocentric"; 235 sout | s | sx; // hello heliocentric 229 236 230 237 // … … 328 335 | find( alphabet , "def") // 3 329 336 | find( alphabet( 0, 26), "def") // 3 330 | find( alphabet( 2, 2 6), "def") // 1331 | find( alphabet( 3, 2 6), "def") // 0332 | find( alphabet( 4, 2 6), "def") // 22, not found333 | find( alphabet( 4, 2 6), "ef") // 0337 | find( alphabet( 2, 24), "def") // 1 338 | find( alphabet( 3, 23), "def") // 0 339 | find( alphabet( 4, 22), "def") // 22, not found 340 | find( alphabet( 4, 22), "ef") // 0 334 341 | find( alphabet( 0, 6), "def") // 3 335 342 | find( alphabet( 0, 5), "def") // 5, not found … … 339 346 | includes( alphabet , "def") // true 340 347 | includes( alphabet( 0, 26), "def") // true 341 | includes( alphabet( 2, 2 6), "def") // true342 | includes( alphabet( 3, 2 6), "def") // true343 | includes( alphabet( 4, 2 6), "def") // false344 | includes( alphabet( 4, 2 6), "ef") // true348 | includes( alphabet( 2, 24), "def") // true 349 | includes( alphabet( 3, 23), "def") // true 350 | includes( alphabet( 4, 22), "def") // false 351 | includes( alphabet( 4, 22), "ef") // true 345 352 | includes( alphabet( 0, 6), "def") // true 346 353 | includes( alphabet( 0, 5), "def") // false … … 350 357 | startsWith( alphabet , "abc") // true 351 358 | startsWith( alphabet( 0, 26), "abc") // true 352 | startsWith( alphabet( 1, 2 6), "abc") // false353 | startsWith( alphabet( 1, 2 6), "bc") // true359 | startsWith( alphabet( 1, 25), "abc") // false 360 | startsWith( alphabet( 1, 25), "bc") // true 354 361 | startsWith( alphabet( 0, 26), "abc") // true 355 362 | startsWith( alphabet( 0, 4), "abc") // true … … 365 372 | endsWith( alphabet( 0, 25), "xy" ) // true 366 373 | endsWith( alphabet( 0, 26), "xyz") // true 367 | endsWith( alphabet(23, 26), "xyz") // true368 | endsWith( alphabet(24, 26), "xyz") // false369 | endsWith( alphabet(24, 26), "yz") // true374 | endsWith( alphabet(23, 3), "xyz") // true 375 | endsWith( alphabet(24, 2), "xyz") // false 376 | endsWith( alphabet(24, 2), "yz") // true 370 377 | endsWith( alphabet , "abc"); // false 371 378 -
TabularUnified tests/collections/string-overwrite.cfa ¶
r906d8fa re8b3717 9 9 MS = modifier start 10 10 ME = modifier end 11 ML = modifier length 11 12 WS = witness start 12 13 WE = witness end 14 WL = witness length 13 15 14 16 The test does: … … 71 73 72 74 73 void showOneReplacement(string & s, int ms, int me, int ws, int we, const char* replaceWith) { 75 void showOneReplacement(string & s, int ms, int ml, int ws, int wl, const char* replaceWith) { 76 77 int me = ms + ml; 78 int we = ws + wl; 74 79 75 80 assert( ms >= 0 && ms <= me && me <= size(s) ); 76 81 assert( ws >= 0 && ws <= we && we <= size(s) ); 77 82 78 string mod = s(ms, m e)`shareEdits;79 string wit = s(ws, w e)`shareEdits;83 string mod = s(ms, ml)`shareEdits; 84 string wit = s(ws, wl)`shareEdits; 80 85 81 86 string modOld = mod; … … 118 123 void runReplaceCases() { 119 124 char * alphabetTemplate = "abcdefghijklmnopqrstuvwxyz"; 120 struct { int ms; int m e; int ws; int we; char *replaceWith; char *label; } cases[] = {121 { 12, 14, 10, 20, "xxxxx", "warmup" },122 { 10, 10, 10, 10, "=====", "1" },123 { 10, 10, 10, 10, "==" , "" },124 { 10, 10, 10, 10, "=" , "" },125 { 10, 10, 10, 10, "" , "" },126 { 10, 12, 12, 12, "=====", "2" },127 { 10, 12, 12, 12, "==" , "" },128 { 10, 12, 12, 12, "=" , "" },129 { 10, 12, 12, 12, "" , "" },130 { 12, 12, 10, 12, "=====", "3" },131 { 12, 12, 10, 12, "==" , "" },132 { 12, 12, 10, 12, "=" , "" },133 { 12, 12, 10, 12, "" , "" },134 { 10, 10, 12, 12, "=====", "4" },135 { 10, 10, 12, 12, "==" , "" },136 { 10, 10, 12, 12, "=" , "" },137 { 10, 10, 12, 12, "" , "" },138 { 12, 12, 10, 10, "=====", "5" },139 { 12, 12, 10, 10, "==" , "" },140 { 12, 12, 10, 10, "=" , "" },141 { 12, 12, 10, 10, "" , "" },142 { 10, 12, 10, 12, "=====", "6" },143 { 10, 12, 10, 12, "==" , "" },144 { 10, 12, 10, 12, "=" , "" },145 { 10, 12, 10, 12, "" , "" },146 { 10, 12, 10, 10, "=====", "7" },147 { 10, 12, 10, 10, "==" , "" },148 { 10, 12, 10, 10, "=" , "" },149 { 10, 12, 10, 10, "" , "" },150 { 10, 10, 10, 12, "=====", "8" },151 { 10, 10, 10, 12, "==" , "" },152 { 10, 10, 10, 12, "=" , "" },153 { 10, 10, 10, 12, "" , "" },154 { 10, 12, 14, 14, "=====", "9" },155 { 10, 12, 14, 14, "==" , "" },156 { 10, 12, 14, 14, "=" , "" },157 { 10, 12, 14, 14, "" , "" },158 { 10, 14, 12, 14, "=====", "10" },159 { 10, 14, 12, 14, "==" , "" },160 { 10, 14, 12, 14, "=" , "" }, // FORMERLY unrunnable bug: tries to print seemingly infinite string161 { 10, 14, 12, 14, "" , "" }, // ditto162 { 14, 14, 10, 12, "=====", "11" },163 { 14, 14, 10, 12, "==" , "" },164 { 14, 14, 10, 12, "=" , "" },165 { 14, 14, 10, 12, "" , "" },166 { 12, 14, 10, 14, "=====", "12" }, // correctness observation: watching klmn while mn |-> xxx gives klxxx because the mn is inside what I'm watching167 { 12, 14, 10, 14, "==" , "" },168 { 12, 14, 10, 14, "=" , "" },169 { 12, 14, 10, 14, "" , "" },170 { 10, 12, 12, 14, "=====", "13" },171 { 10, 12, 12, 14, "==" , "" },172 { 10, 12, 12, 14, "=" , "" },173 { 10, 12, 12, 14, "" , "" },174 { 10, 14, 12, 12, "=====", "14" },175 { 10, 14, 12, 12, "==" , "" },176 { 10, 14, 12, 12, "=" , "" },177 { 10, 14, 12, 12, "" , "" },178 { 12, 14, 10, 12, "=====", "15" },179 { 12, 14, 10, 12, "==" , "" },180 { 12, 14, 10, 12, "=" , "" },181 { 12, 14, 10, 12, "" , "" },182 { 12, 12, 10, 14, "=====", "16" },183 { 12, 12, 10, 14, "==" , "" },184 { 12, 12, 10, 14, "=" , "" },185 { 12, 12, 10, 14, "" , "" },186 { 10, 14, 10, 12, "=====", "17" },187 { 10, 14, 10, 12, "==" , "" },188 { 10, 14, 10, 12, "=" , "" },189 { 10, 14, 10, 12, "" , "" },190 { 10, 10, 12, 14, "=====", "18" },191 { 10, 10, 12, 14, "==" , "" },192 { 10, 10, 12, 14, "=" , "" },193 { 10, 10, 12, 14, "" , "" },194 { 10, 12, 10, 14, "=====", "19" },195 { 10, 12, 10, 14, "==" , "" },196 { 10, 12, 10, 14, "=" , "" },197 { 10, 12, 10, 14, "" , "" },198 { 12, 14, 10, 10, "=====", "20" },199 { 12, 14, 10, 10, "==" , "" },200 { 12, 14, 10, 10, "=" , "" },201 { 12, 14, 10, 10, "" , "" },202 { 10, 12, 14, 16, "=====", "21" },203 { 10, 12, 14, 16, "==" , "" },204 { 10, 12, 14, 16, "=" , "" },205 { 10, 12, 14, 16, "" , "" },206 { 10, 14, 12, 16, "=====", "22" },207 { 10, 14, 12, 16, "==" , "" },208 { 10, 14, 12, 16, "=" , "" },209 { 10, 14, 12, 16, "" , "" },210 { 10, 16, 12, 14, "=====", "23" },211 { 10, 16, 12, 14, "==" , "" },212 { 10, 16, 12, 14, "=" , "" },213 { 10, 16, 12, 14, "" , "" },214 { 14, 16, 10, 12, "=====", "24" },215 { 14, 16, 10, 12, "==" , "" },216 { 14, 16, 10, 12, "=" , "" },217 { 14, 16, 10, 12, "" , "" },218 { 12, 16, 10, 14, "=====", "25" },219 { 12, 16, 10, 14, "==" , "" },220 { 12, 16, 10, 14, "=" , "" },221 { 12, 16, 10, 14, "" , "" },222 { 12, 14, 10, 16, "=====", "26" },223 { 12, 14, 10, 16, "==" , "" },224 { 12, 14, 10, 16, "=" , "" },225 { 12, 14, 10, 16, "" , "" },125 struct { int ms; int ml; int ws; int wl; char *replaceWith; char *label; } cases[] = { 126 { 12, 2, 10, 10, "xxxxx", "warmup" }, 127 { 10, 0, 10, 0, "=====", "1" }, 128 { 10, 0, 10, 0, "==" , "" }, 129 { 10, 0, 10, 0, "=" , "" }, 130 { 10, 0, 10, 0, "" , "" }, 131 { 10, 2, 12, 0, "=====", "2" }, 132 { 10, 2, 12, 0, "==" , "" }, 133 { 10, 2, 12, 0, "=" , "" }, 134 { 10, 2, 12, 0, "" , "" }, 135 { 12, 0, 10, 2, "=====", "3" }, 136 { 12, 0, 10, 2, "==" , "" }, 137 { 12, 0, 10, 2, "=" , "" }, 138 { 12, 0, 10, 2, "" , "" }, 139 { 10, 0, 12, 0, "=====", "4" }, 140 { 10, 0, 12, 0, "==" , "" }, 141 { 10, 0, 12, 0, "=" , "" }, 142 { 10, 0, 12, 0, "" , "" }, 143 { 12, 0, 10, 0, "=====", "5" }, 144 { 12, 0, 10, 0, "==" , "" }, 145 { 12, 0, 10, 0, "=" , "" }, 146 { 12, 0, 10, 0, "" , "" }, 147 { 10, 2, 10, 2, "=====", "6" }, 148 { 10, 2, 10, 2, "==" , "" }, 149 { 10, 2, 10, 2, "=" , "" }, 150 { 10, 2, 10, 2, "" , "" }, 151 { 10, 2, 10, 0, "=====", "7" }, 152 { 10, 2, 10, 0, "==" , "" }, 153 { 10, 2, 10, 0, "=" , "" }, 154 { 10, 2, 10, 0, "" , "" }, 155 { 10, 0, 10, 2, "=====", "8" }, 156 { 10, 0, 10, 2, "==" , "" }, 157 { 10, 0, 10, 2, "=" , "" }, 158 { 10, 0, 10, 2, "" , "" }, 159 { 10, 2, 14, 0, "=====", "9" }, 160 { 10, 2, 14, 0, "==" , "" }, 161 { 10, 2, 14, 0, "=" , "" }, 162 { 10, 2, 14, 0, "" , "" }, 163 { 10, 4, 12, 2, "=====", "10" }, 164 { 10, 4, 12, 2, "==" , "" }, 165 { 10, 4, 12, 2, "=" , "" }, // FORMERLY unrunnable bug: tries to print seemingly infinite string 166 { 10, 4, 12, 2, "" , "" }, // ditto 167 { 14, 0, 10, 2, "=====", "11" }, 168 { 14, 0, 10, 2, "==" , "" }, 169 { 14, 0, 10, 2, "=" , "" }, 170 { 14, 0, 10, 2, "" , "" }, 171 { 12, 2, 10, 4, "=====", "12" }, // correctness observation: watching klmn while mn |-> xxx gives klxxx because the mn is inside what I'm watching 172 { 12, 2, 10, 4, "==" , "" }, 173 { 12, 2, 10, 4, "=" , "" }, 174 { 12, 2, 10, 4, "" , "" }, 175 { 10, 2, 12, 2, "=====", "13" }, 176 { 10, 2, 12, 2, "==" , "" }, 177 { 10, 2, 12, 2, "=" , "" }, 178 { 10, 2, 12, 2, "" , "" }, 179 { 10, 4, 12, 0, "=====", "14" }, 180 { 10, 4, 12, 0, "==" , "" }, 181 { 10, 4, 12, 0, "=" , "" }, 182 { 10, 4, 12, 0, "" , "" }, 183 { 12, 2, 10, 2, "=====", "15" }, 184 { 12, 2, 10, 2, "==" , "" }, 185 { 12, 2, 10, 2, "=" , "" }, 186 { 12, 2, 10, 2, "" , "" }, 187 { 12, 0, 10, 4, "=====", "16" }, 188 { 12, 0, 10, 4, "==" , "" }, 189 { 12, 0, 10, 4, "=" , "" }, 190 { 12, 0, 10, 4, "" , "" }, 191 { 10, 4, 10, 2, "=====", "17" }, 192 { 10, 4, 10, 2, "==" , "" }, 193 { 10, 4, 10, 2, "=" , "" }, 194 { 10, 4, 10, 2, "" , "" }, 195 { 10, 0, 12, 2, "=====", "18" }, 196 { 10, 0, 12, 2, "==" , "" }, 197 { 10, 0, 12, 2, "=" , "" }, 198 { 10, 0, 12, 2, "" , "" }, 199 { 10, 2, 10, 4, "=====", "19" }, 200 { 10, 2, 10, 4, "==" , "" }, 201 { 10, 2, 10, 4, "=" , "" }, 202 { 10, 2, 10, 4, "" , "" }, 203 { 12, 2, 10, 0, "=====", "20" }, 204 { 12, 2, 10, 0, "==" , "" }, 205 { 12, 2, 10, 0, "=" , "" }, 206 { 12, 2, 10, 0, "" , "" }, 207 { 10, 2, 14, 2, "=====", "21" }, 208 { 10, 2, 14, 2, "==" , "" }, 209 { 10, 2, 14, 2, "=" , "" }, 210 { 10, 2, 14, 2, "" , "" }, 211 { 10, 4, 12, 4, "=====", "22" }, 212 { 10, 4, 12, 4, "==" , "" }, 213 { 10, 4, 12, 4, "=" , "" }, 214 { 10, 4, 12, 4, "" , "" }, 215 { 10, 6, 12, 2, "=====", "23" }, 216 { 10, 6, 12, 2, "==" , "" }, 217 { 10, 6, 12, 2, "=" , "" }, 218 { 10, 6, 12, 2, "" , "" }, 219 { 14, 2, 10, 2, "=====", "24" }, 220 { 14, 2, 10, 2, "==" , "" }, 221 { 14, 2, 10, 2, "=" , "" }, 222 { 14, 2, 10, 2, "" , "" }, 223 { 12, 4, 10, 4, "=====", "25" }, 224 { 12, 4, 10, 4, "==" , "" }, 225 { 12, 4, 10, 4, "=" , "" }, 226 { 12, 4, 10, 4, "" , "" }, 227 { 12, 2, 10, 6, "=====", "26" }, 228 { 12, 2, 10, 6, "==" , "" }, 229 { 12, 2, 10, 6, "=" , "" }, 230 { 12, 2, 10, 6, "" , "" }, 226 231 }; 227 232 for ( i; sizeof(cases)/sizeof(cases[0]) ) { 228 233 sout | "------------------------------------------------------------------------" | cases[i].label; 229 234 string replaceIn = alphabetTemplate; 230 showOneReplacement( replaceIn, cases[i].ms, cases[i].m e, cases[i].ws, cases[i].we, cases[i].replaceWith );235 showOneReplacement( replaceIn, cases[i].ms, cases[i].ml, cases[i].ws, cases[i].wl, cases[i].replaceWith ); 231 236 } 232 237 } … … 244 249 string s = "abcdefghijklmnopqrstuvwxyz"; 245 250 246 s(5, 10) = "qqqqq"; // start=5, end=10, len=5247 248 sout | s; 249 250 251 s(5, 5) = "-----"; // start=5, end=5, len=0251 s(5,5) = "qqqqq"; // start=5, end=10, len=5 252 253 sout | s; 254 255 256 s(5,0) = "-----"; // start=5, end=5, len=0 252 257 253 258 sout | s;
Note: See TracChangeset
for help on using the changeset viewer.