@@ -37,11 +37,13 @@ class TestUtilities : public TestBase {
37
37
void testUrlEncode ();
38
38
void testUrlDecode ();
39
39
void testPadString ();
40
+ void testStartsWith ();
40
41
void testStrEqual ();
41
42
void testStringTrim ();
42
43
void testStrToIntConversion ();
43
44
void testStringReplace ();
44
45
void testStringAllowed ();
46
+ void testUTF8 ();
45
47
void testWrapRows ();
46
48
void testIsNumber ();
47
49
void testIsPowerOfTwo ();
@@ -60,11 +62,13 @@ void TestUtilities::runTests(IGameDef *gamedef)
60
62
TEST (testUrlEncode);
61
63
TEST (testUrlDecode);
62
64
TEST (testPadString);
65
+ TEST (testStartsWith);
63
66
TEST (testStrEqual);
64
67
TEST (testStringTrim);
65
68
TEST (testStrToIntConversion);
66
69
TEST (testStringReplace);
67
70
TEST (testStringAllowed);
71
+ TEST (testUTF8);
68
72
TEST (testWrapRows);
69
73
TEST (testIsNumber);
70
74
TEST (testIsPowerOfTwo);
@@ -123,6 +127,8 @@ void TestUtilities::testLowercase()
123
127
124
128
void TestUtilities::testTrim ()
125
129
{
130
+ UASSERT (trim (" " ) == " " );
131
+ UASSERT (trim (" dirt_with_grass" ) == " dirt_with_grass" );
126
132
UASSERT (trim (" \n \t\r Foo bAR \r\n\t\t " ) == " Foo bAR" );
127
133
UASSERT (trim (" \n \t\r \r\n\t\t " ) == " " );
128
134
}
@@ -169,6 +175,19 @@ void TestUtilities::testPadString()
169
175
UASSERT (padStringRight (" hello" , 8 ) == " hello " );
170
176
}
171
177
178
+ void TestUtilities::testStartsWith ()
179
+ {
180
+ UASSERT (str_starts_with (std::string (), std::string ()) == true );
181
+ UASSERT (str_starts_with (std::string (" the sharp pickaxe" ),
182
+ std::string ()) == true );
183
+ UASSERT (str_starts_with (std::string (" the sharp pickaxe" ),
184
+ std::string (" the" )) == true );
185
+ UASSERT (str_starts_with (std::string (" the sharp pickaxe" ),
186
+ std::string (" The" )) == false );
187
+ UASSERT (str_starts_with (std::string (" the sharp pickaxe" ),
188
+ std::string (" The" ), true ) == true );
189
+ UASSERT (str_starts_with (std::string (" T" ), std::string (" The" )) == false );
190
+ }
172
191
173
192
void TestUtilities::testStrEqual ()
174
193
{
@@ -213,6 +232,12 @@ void TestUtilities::testStringAllowed()
213
232
UASSERT (string_allowed_blacklist (" hello123" , " 123" ) == false );
214
233
}
215
234
235
+ void TestUtilities::testUTF8 ()
236
+ {
237
+ UASSERT (wide_to_utf8 (utf8_to_wide (" " )) == " " );
238
+ UASSERT (wide_to_utf8 (utf8_to_wide (" the shovel dug a crumbly node!" ))
239
+ == " the shovel dug a crumbly node!" );
240
+ }
216
241
217
242
void TestUtilities::testWrapRows ()
218
243
{
0 commit comments