Files
textmate/Frameworks/text/tests/t_tokenize.cc
Allan Odgaard 9894969e67 Initial commit
2012-08-09 16:25:56 +02:00

22 lines
713 B
C++

#include <text/tokenize.h>
class TokenizeTests : public CxxTest::TestSuite
{
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);
}
public:
void test_tokenize ()
{
TS_ASSERT_EQUALS(replace_token( "foo/bar", '/', " » "), "foo » bar" );
TS_ASSERT_EQUALS(replace_token("/foo/bar", '/', " » "), " » foo » bar" );
TS_ASSERT_EQUALS(replace_token( "foo/bar/", '/', " » "), "foo » bar » ");
TS_ASSERT_EQUALS(replace_token("/foo/bar/", '/', " » "), " » foo » bar » ");
}
};