| 156 | } |
| 157 | |
| 158 | void TestStringToFloatPreprocess(const char* s, const char* expected) { |
| 159 | string trailers[] = {"", "4567", "fdfgh"}; |
| 160 | for (int i = 0; i < 3; ++i) { |
| 161 | string input = s + trailers[i]; |
| 162 | // don't process trailers |
| 163 | int processing_len = input.length() - trailers[i].length(); |
| 164 | char result[input.length() + 2]; |
| 165 | int res = StringParser::StringToFloatPreprocess(input.data(), processing_len, |
| 166 | result); |
| 167 | EXPECT_EQ(strlen(expected), res); |
| 168 | EXPECT_EQ(string(result), string(expected)); |
| 169 | } |
| 170 | } |
| 171 | |
| 172 | TEST(StringToInt, Basic) { |
| 173 | TestIntValue<int8_t>("123", 123, StringParser::PARSE_SUCCESS); |