Ignore:
Timestamp:
2018-07-05T21:41:18Z (6 years ago)
Author:
Dzejrou <dzejrou@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
e502572b
Parents:
2d302d6
git-author:
Jaroslav Jindrak <dzejrou@…> (2017-11-01 19:07:07)
git-committer:
Dzejrou <dzejrou@…> (2018-07-05 21:41:18)
Message:

cpp: finished std::string::insert tests and fixed some problems with length and other bugs revealed by the tests

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/cpp/src/internal/test/string.cpp

    r2d302d6 red81b1f  
    5555        test_eq(
    5656            "size of string",
    57             str1.size(), 6ul
     57            str1.size(), 5ul
    5858        );
    5959        test_eq(
    6060            "initialization from a cstring literal",
    6161            str1.begin(), str1.end(),
    62             check1, check1 + 6
     62            check1, check1 + 5
    6363        );
    6464
     
    140140
    141141        std::string str5{"hello, "};
    142         str5.append({'w', 'o', 'r', 'l', 'd', '\0'});
     142        str5.append({'w', 'o', 'r', 'l', 'd'});
    143143        test_eq(
    144144            "append initializer list",
     
    187187        std::string insertee{"ello"};
    188188        str4.insert(str4.begin() + 1, insertee.begin(),
    189                     insertee.end() - 1);
     189                    insertee.end());
    190190        test_eq(
    191191            "insert iterator range",
     
    193193            check.begin(), check.end()
    194194        );
    195         /* std::printf("|%s|\n", str4.c_str()); */
     195
     196        std::string str5{"hel, world"};
     197        std::initializer_list<char> init{'l', 'o'};
     198        str5.insert(str5.begin() + 3, init);
     199        test_eq(
     200            "insert initializer list",
     201            str5.begin(), str5.end(),
     202            check.begin(), check.end()
     203        );
    196204    }
    197205}
Note: See TracChangeset for help on using the changeset viewer.