Files
textmate/Frameworks/text/tests/t_tokenize.cc
2013-07-26 13:53:58 +02:00

18 lines
633 B
C++

#include <text/tokenize.h>
static std::string replace_token (std::string const& str, char token, std::string const& replacement)
{
std::vector<std::string> v;
citerate(component, text::tokenize(str.begin(), str.end(), token))
v.push_back(*component);
return text::join(v, replacement);
}
void test_tokenize ()
{
OAK_ASSERT_EQ(replace_token( "foo/bar", '/', " » "), "foo » bar" );
OAK_ASSERT_EQ(replace_token("/foo/bar", '/', " » "), " » foo » bar" );
OAK_ASSERT_EQ(replace_token( "foo/bar/", '/', " » "), "foo » bar » ");
OAK_ASSERT_EQ(replace_token("/foo/bar/", '/', " » "), " » foo » bar » ");
}