| 100 | class ASCIIValidationTest : public UTF8Test {}; |
| 101 | |
| 102 | ::testing::AssertionResult IsValidUTF8(const std::string& s) { |
| 103 | if (ValidateUTF8(reinterpret_cast<const uint8_t*>(s.data()), s.size())) { |
| 104 | return ::testing::AssertionSuccess(); |
| 105 | } else { |
| 106 | std::string h = HexEncode(reinterpret_cast<const uint8_t*>(s.data()), |
| 107 | static_cast<int32_t>(s.size())); |
| 108 | return ::testing::AssertionFailure() |
| 109 | << "string '" << h << "' didn't validate as UTF8"; |
| 110 | } |
| 111 | } |
| 112 | |
| 113 | ::testing::AssertionResult IsInvalidUTF8(const std::string& s) { |
| 114 | if (!ValidateUTF8(reinterpret_cast<const uint8_t*>(s.data()), s.size())) { |
no test coverage detected