25 #ifndef WSTRINGUTILS_TEST_H
26 #define WSTRINGUTILS_TEST_H
31 #include <cxxtest/TestSuite.h>
33 #include "../WStringUtils.h"
35 namespace su = string_utils;
50 std::vector< double > pansen;
51 using string_utils::operator<<;
53 TS_ASSERT_EQUALS( ss.str(),
"[]" );
56 pansen = std::vector< double >( 2, 3.1415 );
58 std::string expected(
"[3.1415000000000002e+00, 1.4139999999999999e+00]" );
60 TS_ASSERT_EQUALS( ss.str(), expected );
70 std::string str(
" abc\t \r\n \t \n\n\n" );
71 std::string expected(
" abc" );
72 std::string actual = su::rTrim( str );
73 TS_ASSERT_EQUALS( expected, actual );
74 TS_ASSERT_EQUALS( str,
" abc\t \r\n \t \n\n\n" );
77 TS_ASSERT_EQUALS( su::rTrim( std::string(
"" ) ),
"" );
78 TS_ASSERT_EQUALS( su::rTrim( std::string(
" " ) ),
"" );
79 TS_ASSERT_EQUALS( su::rTrim( std::string(
"abc" ) ),
"abc" );
83 TS_ASSERT_EQUALS( su::rTrim( str,
"pn" ),
" panse" );
91 std::string str(
"\t \r\n \t \n\n\nabc " );
92 std::string expected(
"abc " );
93 std::string actual = su::lTrim( str );
94 TS_ASSERT_EQUALS( expected, actual );
95 TS_ASSERT_EQUALS( str,
"\t \r\n \t \n\n\nabc " );
98 TS_ASSERT_EQUALS( su::lTrim( std::string(
"" ) ),
"" );
99 TS_ASSERT_EQUALS( su::lTrim( std::string(
" " ) ),
"" );
100 TS_ASSERT_EQUALS( su::lTrim( std::string(
"abc" ) ),
"abc" );
103 str =
"splendor pansen ";
104 TS_ASSERT_EQUALS( su::lTrim( str,
"splendor " ),
"ansen " );
116 std::string str(
"loWeR text\t with some ü\n" );
117 std::string expected(
"LOWER TEXT\t WITH SOME ü\n" );
119 TS_ASSERT_EQUALS( su::toUpper( str ), expected );
120 TS_ASSERT_EQUALS( str,
"loWeR text\t with some ü\n" );
121 expected =
"lower text\t with some ü\n";
122 TS_ASSERT_EQUALS( su::toLower( str ), expected );
123 TS_ASSERT_EQUALS( str,
"loWeR text\t with some ü\n" );
133 std::vector< std::string > expected;
134 TS_ASSERT_EQUALS( su::tokenize( source ), expected );
135 source =
"Foo bar-foo \r\n\t blubb ";
136 expected.push_back(
"Foo" );
137 expected.push_back(
"bar-foo" );
138 expected.push_back(
"blubb" );
139 TS_ASSERT_EQUALS( su::tokenize( source ), expected );
140 TS_ASSERT_EQUALS( source,
"Foo bar-foo \r\n\t blubb " );
142 expected.push_back(
"Foo " );
143 expected.push_back(
"ar-foo \r\n\t " );
144 expected.push_back(
"lu" );
145 expected.push_back(
"" );
146 expected.push_back(
" " );
147 TS_ASSERT_EQUALS( su::tokenize( source,
"b",
false ), expected );
151 #endif // WSTRINGUTILS_TEST_H