| 170 | } |
| 171 | |
| 172 | TEST(StringToInt, Basic) { |
| 173 | TestIntValue<int8_t>("123", 123, StringParser::PARSE_SUCCESS); |
| 174 | TestIntValue<int16_t>("123", 123, StringParser::PARSE_SUCCESS); |
| 175 | TestIntValue<int32_t>("123", 123, StringParser::PARSE_SUCCESS); |
| 176 | TestIntValue<int64_t>("123", 123, StringParser::PARSE_SUCCESS); |
| 177 | |
| 178 | TestIntValue<int8_t>("123", 123, StringParser::PARSE_SUCCESS); |
| 179 | TestIntValue<int16_t>("12345", 12345, StringParser::PARSE_SUCCESS); |
| 180 | TestIntValue<int32_t>("12345678", 12345678, StringParser::PARSE_SUCCESS); |
| 181 | TestIntValue<int64_t>("12345678901234", 12345678901234, StringParser::PARSE_SUCCESS); |
| 182 | |
| 183 | TestIntValue<int8_t>("-10", -10, StringParser::PARSE_SUCCESS); |
| 184 | TestIntValue<int16_t>("-10", -10, StringParser::PARSE_SUCCESS); |
| 185 | TestIntValue<int32_t>("-10", -10, StringParser::PARSE_SUCCESS); |
| 186 | TestIntValue<int64_t>("-10", -10, StringParser::PARSE_SUCCESS); |
| 187 | |
| 188 | TestIntValue<int8_t>("+1", 1, StringParser::PARSE_SUCCESS); |
| 189 | TestIntValue<int16_t>("+1", 1, StringParser::PARSE_SUCCESS); |
| 190 | TestIntValue<int32_t>("+1", 1, StringParser::PARSE_SUCCESS); |
| 191 | TestIntValue<int64_t>("+1", 1, StringParser::PARSE_SUCCESS); |
| 192 | |
| 193 | TestIntValue<int8_t>("+0", 0, StringParser::PARSE_SUCCESS); |
| 194 | TestIntValue<int16_t>("-0", 0, StringParser::PARSE_SUCCESS); |
| 195 | TestIntValue<int32_t>("+0", 0, StringParser::PARSE_SUCCESS); |
| 196 | TestIntValue<int64_t>("-0", 0, StringParser::PARSE_SUCCESS); |
| 197 | } |
| 198 | |
| 199 | TEST(StringToInt, InvalidLeadingTrailing) { |
| 200 | // Test that trailing garbage is not allowed. |
nothing calls this directly
no test coverage detected