Test Base64 encoding when the variables in which the calculated maximal output size and the actual output size are stored have specific initial values (regression test for IMPALA-12986).
| 77 | // the actual output size are stored have specific initial values (regression test for |
| 78 | // IMPALA-12986). |
| 79 | void TestBase64EncodeWithInitialValues(int64_t initial_max_value, |
| 80 | int64_t initial_out_value) { |
| 81 | const string bytes = "abc\1\2\3"; |
| 82 | |
| 83 | int64_t base64_max_len = initial_max_value; |
| 84 | bool succ = Base64EncodeBufLen(bytes.size(), &base64_max_len); |
| 85 | EXPECT_TRUE(succ); |
| 86 | |
| 87 | // 'base64_max_len' includes the null terminator. |
| 88 | string buf(base64_max_len - 1, '\0'); |
| 89 | unsigned base64_len = initial_out_value; |
| 90 | succ = Base64Encode(bytes.c_str(), bytes.size(), base64_max_len, buf.data(), |
| 91 | &base64_len); |
| 92 | EXPECT_TRUE(succ); |
| 93 | |
| 94 | const string expected = "YWJjAQID"; |
| 95 | EXPECT_EQ(expected, buf); |
| 96 | } |
| 97 | |
| 98 | // Test URL encoding. Check that the values that are put in are the |
| 99 | // same that come out. |
no test coverage detected