Tests encoding/decoding of input. If expected_encoded is non-empty, the encoded string is validated against it.
| 31 | // Tests encoding/decoding of input. If expected_encoded is non-empty, the |
| 32 | // encoded string is validated against it. |
| 33 | void TestUrl(const string& input, const string& expected_encoded, bool hive_compat) { |
| 34 | string intermediate; |
| 35 | UrlEncode(input, &intermediate, hive_compat); |
| 36 | string output; |
| 37 | if (!expected_encoded.empty()) { |
| 38 | EXPECT_EQ(intermediate, expected_encoded); |
| 39 | } |
| 40 | EXPECT_TRUE(UrlDecode(intermediate, &output, hive_compat)); |
| 41 | EXPECT_EQ(input, output); |
| 42 | |
| 43 | // Convert string to vector and try that also |
| 44 | vector<uint8_t> input_vector; |
| 45 | input_vector.resize(input.size()); |
| 46 | Ubsan::MemCpy(input_vector.data(), input.c_str(), input.size()); |
| 47 | string intermediate2; |
| 48 | UrlEncode(input_vector, &intermediate2, hive_compat); |
| 49 | EXPECT_EQ(intermediate, intermediate2); |
| 50 | } |
| 51 | |
| 52 | void TestBase64(const string& input, const string& expected_encoded) { |
| 53 | string intermediate; |