MCPcopy Create free account
hub / github.com/apache/impala / TestBase64EncodeWithInitialValues

Function TestBase64EncodeWithInitialValues

be/src/util/coding-util-test.cc:79–96  ·  view source on GitHub ↗

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).

Source from the content-addressed store, hash-verified

77// the actual output size are stored have specific initial values (regression test for
78// IMPALA-12986).
79void 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.

Callers 1

TESTFunction · 0.85

Calls 4

Base64EncodeBufLenFunction · 0.85
Base64EncodeFunction · 0.70
sizeMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected