| 55 | } |
| 56 | |
| 57 | void TestBase64(const string& input, const string& expected_encoded) { |
| 58 | string intermediate; |
| 59 | Base64Encode(input, &intermediate); |
| 60 | string output; |
| 61 | if (!expected_encoded.empty()) { |
| 62 | EXPECT_EQ(intermediate, expected_encoded); |
| 63 | } |
| 64 | EXPECT_TRUE(Base64Decode(intermediate, &output)); |
| 65 | EXPECT_EQ(input, output); |
| 66 | |
| 67 | // Convert string to vector and try that also |
| 68 | vector<uint8_t> input_vector; |
| 69 | input_vector.resize(input.size()); |
| 70 | memcpy(&input_vector[0], input.c_str(), input.size()); |
| 71 | string intermediate2; |
| 72 | Base64Encode(input_vector, &intermediate2); |
| 73 | EXPECT_EQ(intermediate, intermediate2); |
| 74 | } |
| 75 | |
| 76 | // Test URL encoding. Check that the values that are put in are the |
| 77 | // same that come out. |
no test coverage detected