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

Function TestBase64

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

Source from the content-addressed store, hash-verified

50}
51
52void TestBase64(const string& input, const string& expected_encoded) {
53 string intermediate;
54 Base64Encode(input, &intermediate);
55 if (!expected_encoded.empty()) {
56 EXPECT_EQ(intermediate, expected_encoded);
57 }
58 int64_t out_max = 0;
59 EXPECT_TRUE(Base64DecodeBufLen(intermediate.c_str(), intermediate.size(), &out_max));
60 string output(out_max, '\0');
61 unsigned out_len = 0;
62 EXPECT_TRUE(Base64Decode(intermediate.c_str(), intermediate.size(),
63 out_max, const_cast<char*>(output.c_str()), &out_len));
64 output.resize(out_len);
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.data(), input.c_str(), input.size());
71 string intermediate2;
72 Base64Encode(input_vector, &intermediate2);
73 EXPECT_EQ(intermediate, intermediate2);
74}
75
76// Test Base64 encoding when the variables in which the calculated maximal output size and
77// the actual output size are stored have specific initial values (regression test for

Callers 1

TESTFunction · 0.70

Calls 7

Base64DecodeBufLenFunction · 0.85
resizeMethod · 0.80
Base64EncodeFunction · 0.70
Base64DecodeFunction · 0.70
emptyMethod · 0.45
sizeMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected