Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • tests/collections/string-api-coverage.cfa

    re8b3717 r55b060d  
    5151    sout | (s == "hello") | (s == "world");
    5252    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"   );
    6161
    6262
     
    6666    //
    6767    {
    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
    7370
    7471        string b2 = s;
    7572        sout | b2; // hello
    76 
    77         string b2x = { s, 4 };
    78         sout | b2x; // hell
    7973
    8074        // todo: a plain string &
     
    9488        b4 = s_constref;
    9589        sout | b4;  // world
    96 
    97         string b5 = 'Q';
    98         sout | b5; // Q
    99 
    100 
    10190    }
    10291                                            assertWellFormedHandleList( 10 );
    103     //
    104     // Assignments
    105     //
    106     {
    107         string b = "xxx";
    108 
    109         b = "1234567";
    110         sout | b; // 1234567
    111 
    112         b = "xxx";
    113         b = s;
    114         sout | b; // hello
    115        
    116         b = "xxx";
    117         b = 'Q';
    118         sout | b; // Q
    119        
    120         b = "xxx";
    121         assign( b, "1234567", 3 );
    122         sout | b; // 123
    123 
    124         b = "xxx";
    125         assign( b, s, 4 );
    126         sout | b; // hell
    127 
    128         b = "xxx";
    129         strcpy(b, "1234567");
    130         sout | b; // 1234567
    131 
    132         b = "xxx";
    133         strcpy(b, s);
    134         sout | b; // hello
    135        
    136         b = "xxx";
    137         strncpy( b, "1234567", 3 );
    138         sout | b; // 123
    139 
    140         b = "xxx";
    141         strncpy( b, s, 4 );
    142         sout | b; // hell
    143     }
    144                                             assertWellFormedHandleList( 10 );
    145 
    146 
    14792
    14893    sout | size(s); // 5
     
    181126    sout | sx; // bye, friend
    182127
    183     sx = "o";
    184     strcat( sx, s );
    185     sout | sx; // ohello
    186 
    187     sx = "o";
    188     append( sx, s, 4 );
    189     sout | sx; // ohell
    190 
    191     sx = "o";
    192     strncat( sx, s, 4 );
    193     sout | sx; // ohell
    194 
    195     sx = "o";
    196     strcat( sx, "mydarling" );
    197     sout | sx; // omydarling
    198 
    199     sx = "o";
    200     append( sx, "mydarling", 2 );
    201     sout | sx; // omy
    202 
    203     sx = "o";
    204     strncat( sx, "mydarling", 2 );
    205     sout | sx; // omy
    206 
    207128    //
    208129    // repetition
    209130    //
    210 
    211     sx = s;
    212     sx *= 4;
    213     sout | sx; // hellohellohellohello
    214 
    215131    sx = s * 3;
    216132    sout | sx; // hellohellohello
     
    226142    //
    227143
    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    //...
    236145
    237146    //
     
    335244        | find( alphabet        , "def")  // 3
    336245        | find( alphabet( 0, 26), "def")  // 3
    337         | 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
     246        | 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
    341250        | find( alphabet( 0,  6), "def")  // 3
    342251        | find( alphabet( 0,  5), "def")  // 5, not found
     
    346255        | includes( alphabet        , "def")  // true
    347256        | includes( alphabet( 0, 26), "def")  // true
    348         | 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
     257        | 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
    352261        | includes( alphabet( 0,  6), "def")  // true
    353262        | includes( alphabet( 0,  5), "def")  // false
     
    357266        | startsWith( alphabet        , "abc")  // true
    358267        | startsWith( alphabet( 0, 26), "abc")  // true
    359         | startsWith( alphabet( 1, 25), "abc")  // false
    360         | startsWith( alphabet( 1, 25),  "bc")  // true
     268        | startsWith( alphabet( 1, 26), "abc")  // false
     269        | startsWith( alphabet( 1, 26),  "bc")  // true
    361270        | startsWith( alphabet( 0, 26), "abc")  // true
    362271        | startsWith( alphabet( 0,  4), "abc")  // true
     
    372281        | endsWith( alphabet( 0, 25), "xy" )  // true
    373282        | endsWith( alphabet( 0, 26), "xyz")  // true
    374         | endsWith( alphabet(23,  3), "xyz")  // true
    375         | endsWith( alphabet(24,  2), "xyz")  // false
    376         | endsWith( alphabet(24,  2),  "yz")  // true
     283        | endsWith( alphabet(23, 26), "xyz")  // true
     284        | endsWith( alphabet(24, 26), "xyz")  // false
     285        | endsWith( alphabet(24, 26),  "yz")  // true
    377286        | endsWith( alphabet        , "abc"); // false
    378287
Note: See TracChangeset for help on using the changeset viewer.