- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
tests/collections/string-api-coverage.cfa
re8b3717 r55b060d 51 51 sout | (s == "hello") | (s == "world"); 52 52 sout | (s != "world") | (s != "hello"); 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" );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" ); 61 61 62 62 … … 66 66 // 67 67 { 68 string b1 = "1234567"; 69 sout | b1; // 1234567 70 71 string b1x = { "1234567", 3 }; 72 sout | b1x; // 123 68 string b1 = { "1234567", 3 }; 69 sout | b1; // 123 73 70 74 71 string b2 = s; 75 72 sout | b2; // hello 76 77 string b2x = { s, 4 };78 sout | b2x; // hell79 73 80 74 // todo: a plain string & … … 94 88 b4 = s_constref; 95 89 sout | b4; // world 96 97 string b5 = 'Q';98 sout | b5; // Q99 100 101 90 } 102 91 assertWellFormedHandleList( 10 ); 103 //104 // Assignments105 //106 {107 string b = "xxx";108 109 b = "1234567";110 sout | b; // 1234567111 112 b = "xxx";113 b = s;114 sout | b; // hello115 116 b = "xxx";117 b = 'Q';118 sout | b; // Q119 120 b = "xxx";121 assign( b, "1234567", 3 );122 sout | b; // 123123 124 b = "xxx";125 assign( b, s, 4 );126 sout | b; // hell127 128 b = "xxx";129 strcpy(b, "1234567");130 sout | b; // 1234567131 132 b = "xxx";133 strcpy(b, s);134 sout | b; // hello135 136 b = "xxx";137 strncpy( b, "1234567", 3 );138 sout | b; // 123139 140 b = "xxx";141 strncpy( b, s, 4 );142 sout | b; // hell143 }144 assertWellFormedHandleList( 10 );145 146 147 92 148 93 sout | size(s); // 5 … … 181 126 sout | sx; // bye, friend 182 127 183 sx = "o";184 strcat( sx, s );185 sout | sx; // ohello186 187 sx = "o";188 append( sx, s, 4 );189 sout | sx; // ohell190 191 sx = "o";192 strncat( sx, s, 4 );193 sout | sx; // ohell194 195 sx = "o";196 strcat( sx, "mydarling" );197 sout | sx; // omydarling198 199 sx = "o";200 append( sx, "mydarling", 2 );201 sout | sx; // omy202 203 sx = "o";204 strncat( sx, "mydarling", 2 );205 sout | sx; // omy206 207 128 // 208 129 // repetition 209 130 // 210 211 sx = s;212 sx *= 4;213 sout | sx; // hellohellohellohello214 215 131 sx = s * 3; 216 132 sout | sx; // hellohellohello … … 226 142 // 227 143 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 144 //... 236 145 237 146 // … … 335 244 | find( alphabet , "def") // 3 336 245 | find( alphabet( 0, 26), "def") // 3 337 | find( alphabet( 2, 2 4), "def") // 1338 | find( alphabet( 3, 2 3), "def") // 0339 | find( alphabet( 4, 2 2), "def") // 22, not found340 | find( alphabet( 4, 2 2), "ef") // 0246 | find( alphabet( 2, 26), "def") // 1 247 | find( alphabet( 3, 26), "def") // 0 248 | find( alphabet( 4, 26), "def") // 22, not found 249 | find( alphabet( 4, 26), "ef") // 0 341 250 | find( alphabet( 0, 6), "def") // 3 342 251 | find( alphabet( 0, 5), "def") // 5, not found … … 346 255 | includes( alphabet , "def") // true 347 256 | includes( alphabet( 0, 26), "def") // true 348 | includes( alphabet( 2, 2 4), "def") // true349 | includes( alphabet( 3, 2 3), "def") // true350 | includes( alphabet( 4, 2 2), "def") // false351 | includes( alphabet( 4, 2 2), "ef") // true257 | includes( alphabet( 2, 26), "def") // true 258 | includes( alphabet( 3, 26), "def") // true 259 | includes( alphabet( 4, 26), "def") // false 260 | includes( alphabet( 4, 26), "ef") // true 352 261 | includes( alphabet( 0, 6), "def") // true 353 262 | includes( alphabet( 0, 5), "def") // false … … 357 266 | startsWith( alphabet , "abc") // true 358 267 | startsWith( alphabet( 0, 26), "abc") // true 359 | startsWith( alphabet( 1, 2 5), "abc") // false360 | startsWith( alphabet( 1, 2 5), "bc") // true268 | startsWith( alphabet( 1, 26), "abc") // false 269 | startsWith( alphabet( 1, 26), "bc") // true 361 270 | startsWith( alphabet( 0, 26), "abc") // true 362 271 | startsWith( alphabet( 0, 4), "abc") // true … … 372 281 | endsWith( alphabet( 0, 25), "xy" ) // true 373 282 | endsWith( alphabet( 0, 26), "xyz") // true 374 | endsWith( alphabet(23, 3), "xyz") // true375 | endsWith( alphabet(24, 2), "xyz") // false376 | endsWith( alphabet(24, 2), "yz") // true283 | endsWith( alphabet(23, 26), "xyz") // true 284 | endsWith( alphabet(24, 26), "xyz") // false 285 | endsWith( alphabet(24, 26), "yz") // true 377 286 | endsWith( alphabet , "abc"); // false 378 287
Note:
See TracChangeset
for help on using the changeset viewer.