Exemple #1
0
void StringTest::testTrimLeft()
{
    {
        std::string s = "abc";
        assert (trimLeft(s) == "abc");
    }
    std::string s = " abc ";
    assert (trimLeft(s) == "abc ");
    {
        std::string s = "  ab c ";
        assert (trimLeft(s) == "ab c ");
    }
}
Exemple #2
0
int main(int argc, char** argv) {

 string hello("  Hello, world!  ");

 cout << hello << "\n";

 string s1(trimLeft(hello)); // "Hello, world!  "

 cout << s1 << "\n";

 trimRightInPlace(s1);            // "Hello, world!"

 cout << s1 << "\n";

 string s2(trim(hello));     // "Hello, world!"

 cout << s2 << "\n";

 return 0;

}