15 #include <gtest/gtest.h>
25 using namespace impala;
27 extern string EncodeNdv(
const string& ndv,
bool* is_encoded);
28 extern string DecodeNdv(
const string& ndv,
bool is_encoded);
32 TEST(RleTest, TestEmptyRle) {
36 const string& encoded =
EncodeNdv(test, &is_encoded);
37 ASSERT_EQ(8, encoded.size());
38 ASSERT_TRUE(is_encoded);
40 const string& decoded =
DecodeNdv(encoded, is_encoded);
41 ASSERT_EQ(
HLL_LEN, decoded.size());
42 ASSERT_EQ(test, decoded);
45 TEST(RleTest, TestNoEncode) {
47 for (
int i = 0; i <
HLL_LEN; ++i) {
48 test += (i % 2 == 0) ?
'A' :
'B';
52 const string& encoded =
EncodeNdv(test, &is_encoded);
53 ASSERT_FALSE(is_encoded);
54 ASSERT_EQ(encoded, test);
56 ASSERT_EQ(
DecodeNdv(encoded, is_encoded), test);
59 TEST(RleTest, TestEncode) {
61 for (
int i = 0; i <
HLL_LEN; ++i) {
62 test += (i < 512) ?
'A' :
'B';
66 const string& encoded =
EncodeNdv(test, &is_encoded);
67 ASSERT_EQ(8, encoded.size());
68 ASSERT_TRUE(is_encoded);
69 ASSERT_EQ(
DecodeNdv(encoded, is_encoded), test);
73 int main(
int argc,
char** argv) {
75 ::testing::InitGoogleTest(&argc, argv);
76 return RUN_ALL_TESTS();
int main(int argc, char **argv)
string DecodeNdv(const string &ndv, bool is_encoded)
static const int HLL_PRECISION
string EncodeNdv(const string &ndv, bool *is_encoded)