src/base/str.test.cc
/*
 * str.cc's "tokenize" function splits a string into its constituent tokens.
 * It splits based on an input character.
 */
str.cc's "tokenize" function splits a string into its constituent tokens.
It splits based on an input character.
str . cc ' s " tokenize " function splits a string into its constituent tokens . It splits based on an input character .
TEST(StrTest, TokenizeOnSpace)
{
    std::string val = " Hello,  this  is  a  sentence. ";
    std::vector<std::string> tokens;
    tokenize(tokens, val, ' ');
    EXPECT_EQ(" Hello,  this  is  a  sentence. ", val);
    EXPECT_EQ(5, tokens.size());
    EXPECT_EQ("Hello,", tokens[0]);
    EXPECT_EQ("this", tokens[1]);
    EXPECT_EQ("is", tokens[2]);
    EXPECT_EQ("a", tokens[3]);
    EXPECT_EQ("sentence.", tokens[4]);
}
TEST ( StrTest , TokenizeOnSpace ) { std :: string val = " " ; std :: vector < std :: string > tokens ; tokenize ( tokens , val , ' ' ) ; EXPECT_EQ ( " " , val ) ; EXPECT_EQ ( 5 , tokens . size ( ) ) ; EXPECT_EQ ( " " , tokens [ 0 ] ) ; EXPECT_EQ ( " " , tokens [ 1 ] ) ; EXPECT_EQ ( " " , tokens [ 2 ] ) ; EXPECT_EQ ( " " , tokens [ 3 ] ) ; EXPECT_EQ ( " " , tokens [ 4 ] ) ; }
str.cc's "tokenize" function splits a string into its constituent tokens.
str . cc ' s " tokenize " function splits a string into its constituent tokens .
/*
     * val has a double space between each token with trailing and leading
     * whitespace.
     */ /*
     * By default 'ign' is true. This means empty tokens are not included in
     * the output list.
     */