38 #include <gtest/gtest.h>
49 TEST(StrTest, EatLeadWhite)
51 std::string
val =
" hello there ";
56 TEST(StrTest, EatLeadWhiteNoLeadingWhitespace)
58 std::string
val =
"hello there ";
65 std::string
val =
" hello there ";
70 TEST(StrTest, EatEndWhiteNoTrailingWhitespace)
72 std::string
val =
" hello there";
79 std::string
val =
" hello there ";
84 TEST(StrTest, EatWhiteNoWhitespace)
86 std::string
val =
"hello there";
97 std::string
val =
"gOoDbYe FOO@barr!";
112 std::string
val =
"abcdefg abcdefg";
122 TEST(StrTest, SplitFirstNoChar)
124 std::string
val =
"abcdefg abcdefg";
134 TEST(StrTest, SplitFirstOnFirstChar)
136 std::string
val =
"abcdefg abcdefg";
148 std::string
val =
"abcdefg abcdefg";
160 std::string
val =
"abcdefg abcdefg";
170 TEST(StrTest, SplitLastOnLastChar)
172 std::string
val =
"abcdefg abcdefg";
193 std::string
val =
" Hello, this is a sentence. ";
210 TEST(StrTest, TokenizeOnSpaceIgnFalse)
216 std::string
val =
" Hello, this is a sentence. ";
235 TEST(StrTest, TokenizedTokenDoesNotExist)
237 std::string
val =
"abcdefg";
254 std::string input =
"-128";
259 TEST(StrTest, ToNumber8BitIntStringOutOfRange)
262 std::string input =
"-129";
266 TEST(StrTest, ToNumber8BitIntInvalidString)
269 std::string input =
"onetwoeight";
273 TEST(StrTest, ToNumberUnsigned8BitInt)
276 std::string input =
"255";
281 TEST(StrTest, ToNumberUnsigned8BitIntNegative)
284 std::string input =
"-1";
288 TEST(StrTest, ToNumber64BitInt)
291 int64_t input_number = 0xFFFFFFFFFFFFFFFF;
297 TEST(StrTest, ToNumber64BitIntInvalidString)
300 std::string input =
" ";
307 std::string input =
"0.1";
308 float expected_output = 0.1;
313 TEST(StrTest, ToNumberFloatIntegerString)
316 std::string input =
"10";
317 float expected_output = 10.0;
322 TEST(StrTest, ToNumberFloatNegative)
325 std::string input =
"-0.1";
326 float expected_output = -0.1;
334 std::string input =
"0.0001";
335 double expected_output = 0.0001;
340 TEST(StrTest, ToNumberDoubleIntegerString)
343 std::string input =
"12345";
344 double expected_output = 12345.0;
349 TEST(StrTest, ToNumberDoubleNegative)
352 std::string input =
"-1.2345";
353 double expected_output = -1.2345;
376 TEST(StrTest, ToBoolInvalidInput)
386 TEST(StrTest, QuoteStringNoSpace)
391 TEST(StrTest, QuoteStringWithSpace)
396 TEST(StrTest, QuoteQuotedString)
404 TEST(StrTest, QuoteStringWithTab)
419 TEST(StrTest, StartswithDoubleStringDoesStartWith)
421 std::string
s =
"Hello, how are you?";
422 std::string prefix =
"Hello";
426 TEST(StrTest, StartswithDoubleStringDoesNotStartWith)
428 std::string
s =
"Hello, how are you?";
429 std::string prefix =
"ello";
433 TEST(StrTest, StartswithDoubleCharArrayDoesStartWith)
435 const char*
s =
"abcdefg";
436 const char* prefix =
"ab";
440 TEST(StrTest, StartswithDoubleCharArrayDoesNotStartWith)
442 const char*
s =
" abcdefg";
443 const char* prefix =
"a";
447 TEST(StrTest, StartswithStringCharArrayDoesStartWith)
449 std::string
s =
"foobarr";
450 const char* prefix =
"f";
454 TEST(StrTest, StartswithStringCharArrayDoesNotStartWith)
456 std::string
s =
"foobarr";
457 const char* prefix =
"barr";