[refactor] Unify all unit tests into one binary file (#8958)
1. solved the previous delayed unit test file size is too large (1.7G+) and the unit test link time is too long problem problems 2. Unify all unit tests into one file to significantly reduce unit test execution time to less than 3 mins 3. temporarily disable stream_load_test.cpp, metrics_action_test.cpp, load_channel_mgr_test.cpp because it will re-implement part of the code and affect other tests
This commit is contained in:
@ -66,7 +66,7 @@ TEST_F(BitmapFunctionsTest, bitmap_empty) {
|
||||
BitmapValue bitmap;
|
||||
StringVal expected = convert_bitmap_to_string(ctx, bitmap);
|
||||
|
||||
ASSERT_EQ(expected, result);
|
||||
EXPECT_EQ(expected, result);
|
||||
}
|
||||
|
||||
TEST_F(BitmapFunctionsTest, to_bitmap) {
|
||||
@ -78,7 +78,7 @@ TEST_F(BitmapFunctionsTest, to_bitmap) {
|
||||
BitmapValue bitmap(val);
|
||||
StringVal expected = convert_bitmap_to_string(ctx, bitmap);
|
||||
|
||||
ASSERT_EQ(expected, result);
|
||||
EXPECT_EQ(expected, result);
|
||||
}
|
||||
}
|
||||
|
||||
@ -86,19 +86,19 @@ TEST_F(BitmapFunctionsTest, to_bitmap_null) {
|
||||
StringVal input = StringVal::null();
|
||||
StringVal result = BitmapFunctions::to_bitmap(ctx, input);
|
||||
|
||||
ASSERT_EQ(StringVal::null(), result);
|
||||
EXPECT_EQ(StringVal::null(), result);
|
||||
}
|
||||
|
||||
TEST_F(BitmapFunctionsTest, to_bitmap_invalid_argument) {
|
||||
StringVal input = AnyValUtil::from_string_temp(ctx, std::string("-1"));
|
||||
StringVal result = BitmapFunctions::to_bitmap(ctx, input);
|
||||
ASSERT_EQ(StringVal::null(), result);
|
||||
EXPECT_EQ(StringVal::null(), result);
|
||||
}
|
||||
|
||||
TEST_F(BitmapFunctionsTest, to_bitmap_out_of_range) {
|
||||
StringVal input = AnyValUtil::from_string_temp(ctx, std::string("18446744073709551616"));
|
||||
StringVal result = BitmapFunctions::to_bitmap(ctx, input);
|
||||
ASSERT_EQ(StringVal::null(), result);
|
||||
EXPECT_EQ(StringVal::null(), result);
|
||||
}
|
||||
|
||||
TEST_F(BitmapFunctionsTest, bitmap_union_int) {
|
||||
@ -111,7 +111,7 @@ TEST_F(BitmapFunctionsTest, bitmap_union_int) {
|
||||
|
||||
BigIntVal result = BitmapFunctions::bitmap_finalize(ctx, dst);
|
||||
BigIntVal expected(2);
|
||||
ASSERT_EQ(expected, result);
|
||||
EXPECT_EQ(expected, result);
|
||||
}
|
||||
|
||||
TEST_F(BitmapFunctionsTest, bitmap_get_value) {
|
||||
@ -122,20 +122,20 @@ TEST_F(BitmapFunctionsTest, bitmap_get_value) {
|
||||
|
||||
BigIntVal result = BitmapFunctions::bitmap_get_value(ctx, dst);
|
||||
BigIntVal expected(1);
|
||||
ASSERT_EQ(expected, result);
|
||||
EXPECT_EQ(expected, result);
|
||||
|
||||
IntVal src2(1234567);
|
||||
BitmapFunctions::bitmap_update_int(ctx, src2, &dst);
|
||||
|
||||
result = BitmapFunctions::bitmap_get_value(ctx, dst);
|
||||
expected.val = 2;
|
||||
ASSERT_EQ(expected, result);
|
||||
EXPECT_EQ(expected, result);
|
||||
|
||||
BigIntVal finalize_result = BitmapFunctions::bitmap_finalize(ctx, dst);
|
||||
ASSERT_EQ(result, finalize_result);
|
||||
EXPECT_EQ(result, finalize_result);
|
||||
|
||||
BigIntVal null_bitmap = BitmapFunctions::bitmap_get_value(ctx, StringVal::null());
|
||||
ASSERT_EQ(BigIntVal(0), null_bitmap);
|
||||
EXPECT_EQ(BigIntVal(0), null_bitmap);
|
||||
}
|
||||
|
||||
TEST_F(BitmapFunctionsTest, bitmap_union) {
|
||||
@ -163,7 +163,7 @@ TEST_F(BitmapFunctionsTest, bitmap_union) {
|
||||
|
||||
BigIntVal result = BitmapFunctions::bitmap_count(ctx, serialized);
|
||||
BigIntVal expected(2);
|
||||
ASSERT_EQ(expected, result);
|
||||
EXPECT_EQ(expected, result);
|
||||
}
|
||||
|
||||
// test bitmap_intersect
|
||||
@ -185,7 +185,7 @@ TEST_F(BitmapFunctionsTest, bitmap_intersect) {
|
||||
StringVal serialized = BitmapFunctions::bitmap_serialize(ctx, dst);
|
||||
BigIntVal result = BitmapFunctions::bitmap_count(ctx, serialized);
|
||||
BigIntVal expected(2);
|
||||
ASSERT_EQ(expected, result);
|
||||
EXPECT_EQ(expected, result);
|
||||
}
|
||||
|
||||
// test bitmap_intersect with null dst
|
||||
@ -196,7 +196,7 @@ TEST_F(BitmapFunctionsTest, bitmap_intersect_empty) {
|
||||
StringVal serialized = BitmapFunctions::bitmap_serialize(ctx, dst);
|
||||
BigIntVal result = BitmapFunctions::bitmap_count(ctx, serialized);
|
||||
BigIntVal expected(0);
|
||||
ASSERT_EQ(expected, result);
|
||||
EXPECT_EQ(expected, result);
|
||||
}
|
||||
|
||||
TEST_F(BitmapFunctionsTest, bitmap_count) {
|
||||
@ -207,35 +207,35 @@ TEST_F(BitmapFunctionsTest, bitmap_count) {
|
||||
|
||||
BigIntVal result = BitmapFunctions::bitmap_count(ctx, bitmap_str);
|
||||
BigIntVal expected(3);
|
||||
ASSERT_EQ(expected, result);
|
||||
EXPECT_EQ(expected, result);
|
||||
|
||||
BigIntVal null_bitmap = BitmapFunctions::bitmap_count(ctx, StringVal::null());
|
||||
ASSERT_EQ(BigIntVal(0), null_bitmap);
|
||||
EXPECT_EQ(BigIntVal(0), null_bitmap);
|
||||
}
|
||||
|
||||
TEST_F(BitmapFunctionsTest, bitmap_min) {
|
||||
BigIntVal result = BitmapFunctions::bitmap_min(ctx, StringVal::null());
|
||||
ASSERT_TRUE(result.is_null);
|
||||
EXPECT_TRUE(result.is_null);
|
||||
|
||||
BitmapValue bitmap1;
|
||||
StringVal empty_str = convert_bitmap_to_string(ctx, bitmap1);
|
||||
result = BitmapFunctions::bitmap_min(ctx, empty_str);
|
||||
ASSERT_TRUE(result.is_null);
|
||||
EXPECT_TRUE(result.is_null);
|
||||
|
||||
BitmapValue bitmap2 = BitmapValue(1024);
|
||||
StringVal bitmap_str = convert_bitmap_to_string(ctx, bitmap2);
|
||||
result = BitmapFunctions::bitmap_min(ctx, bitmap_str);
|
||||
ASSERT_EQ(BigIntVal(1024), result);
|
||||
EXPECT_EQ(BigIntVal(1024), result);
|
||||
|
||||
BitmapValue bitmap3 = BitmapValue({1024, 1});
|
||||
bitmap_str = convert_bitmap_to_string(ctx, bitmap3);
|
||||
result = BitmapFunctions::bitmap_min(ctx, bitmap_str);
|
||||
ASSERT_EQ(BigIntVal(1), result);
|
||||
EXPECT_EQ(BigIntVal(1), result);
|
||||
|
||||
BitmapValue bitmap4 = BitmapValue({1024, 3, 2});
|
||||
bitmap_str = convert_bitmap_to_string(ctx, bitmap4);
|
||||
result = BitmapFunctions::bitmap_min(ctx, bitmap_str);
|
||||
ASSERT_EQ(BigIntVal(2), result);
|
||||
EXPECT_EQ(BigIntVal(2), result);
|
||||
}
|
||||
|
||||
// test intersect_count
|
||||
@ -271,10 +271,10 @@ void test_bitmap_intersect(FunctionContext* ctx, ValType key1, ValType key2) {
|
||||
intersect2.update(detail::get_val<ValType, ValueType>(key1), bitmap1);
|
||||
intersect2.update(detail::get_val<ValType, ValueType>(key2), bitmap2);
|
||||
StringVal expected = convert_bitmap_intersect_to_string(ctx, intersect2);
|
||||
ASSERT_EQ(expected, intersect1);
|
||||
EXPECT_EQ(expected, intersect1);
|
||||
|
||||
BitmapIntersect<ValueType> intersect2_serde((char*)expected.ptr);
|
||||
ASSERT_EQ(1, intersect2_serde.intersect_count());
|
||||
EXPECT_EQ(1, intersect2_serde.intersect_count());
|
||||
|
||||
StringVal dst2;
|
||||
BitmapFunctions::bitmap_intersect_init<ValueType, ValType>(ctx, &dst2);
|
||||
@ -282,7 +282,7 @@ void test_bitmap_intersect(FunctionContext* ctx, ValType key1, ValType key2) {
|
||||
BigIntVal result = BitmapFunctions::bitmap_intersect_finalize<ValueType>(ctx, dst2);
|
||||
BigIntVal expected_count(1);
|
||||
|
||||
ASSERT_EQ(expected_count, result);
|
||||
EXPECT_EQ(expected_count, result);
|
||||
}
|
||||
|
||||
TEST_F(BitmapFunctionsTest, test_bitmap_intersect) {
|
||||
@ -325,7 +325,7 @@ TEST_F(BitmapFunctionsTest, bitmap_or) {
|
||||
BigIntVal result = BitmapFunctions::bitmap_count(ctx, bitmap_str);
|
||||
|
||||
BigIntVal expected(6);
|
||||
ASSERT_EQ(expected, result);
|
||||
EXPECT_EQ(expected, result);
|
||||
}
|
||||
|
||||
TEST_F(BitmapFunctionsTest, bitmap_or_variable) {
|
||||
@ -333,7 +333,7 @@ TEST_F(BitmapFunctionsTest, bitmap_or_variable) {
|
||||
BitmapValue bitmap1({1024, 1, 2019});
|
||||
BitmapValue bitmap2({0, 33, std::numeric_limits<uint64_t>::min()});
|
||||
BitmapValue bitmap3({33, 5, std::numeric_limits<uint64_t>::max()});
|
||||
BitmapValue bitmap_empty; //test empty
|
||||
BitmapValue bitmap_empty; //test empty
|
||||
|
||||
StringVal bitmap_src1 = convert_bitmap_to_string(ctx, bitmap1);
|
||||
StringVal bitmap_src2 = convert_bitmap_to_string(ctx, bitmap2);
|
||||
@ -344,8 +344,8 @@ TEST_F(BitmapFunctionsTest, bitmap_or_variable) {
|
||||
StringVal bitmap_result = BitmapFunctions::bitmap_or(ctx, bitmap_src1, 3, bitmap_strs);
|
||||
BigIntVal result = BitmapFunctions::bitmap_count(ctx, bitmap_result);
|
||||
|
||||
BigIntVal expected(7);//0,1,5,33,1024,2019,18446744073709551615
|
||||
ASSERT_EQ(expected, result);
|
||||
BigIntVal expected(7); //0,1,5,33,1024,2019,18446744073709551615
|
||||
EXPECT_EQ(expected, result);
|
||||
}
|
||||
{
|
||||
BitmapValue bitmap1({1024, 1, 2019});
|
||||
@ -361,7 +361,7 @@ TEST_F(BitmapFunctionsTest, bitmap_or_variable) {
|
||||
BigIntVal result = BitmapFunctions::bitmap_count(ctx, bitmap_result);
|
||||
|
||||
BigIntVal expected(0);
|
||||
ASSERT_EQ(expected, result);
|
||||
EXPECT_EQ(expected, result);
|
||||
}
|
||||
}
|
||||
|
||||
@ -376,7 +376,7 @@ TEST_F(BitmapFunctionsTest, bitmap_and) {
|
||||
BigIntVal result = BitmapFunctions::bitmap_count(ctx, bitmap_str);
|
||||
|
||||
BigIntVal expected(1);
|
||||
ASSERT_EQ(expected, result);
|
||||
EXPECT_EQ(expected, result);
|
||||
}
|
||||
|
||||
TEST_F(BitmapFunctionsTest, bitmap_and_variable) {
|
||||
@ -393,14 +393,14 @@ TEST_F(BitmapFunctionsTest, bitmap_and_variable) {
|
||||
StringVal bitmap_result = BitmapFunctions::bitmap_and(ctx, bitmap_src1, 2, bitmap_strs);
|
||||
BigIntVal result = BitmapFunctions::bitmap_count(ctx, bitmap_result);
|
||||
|
||||
BigIntVal expected(1);//0
|
||||
ASSERT_EQ(expected, result);
|
||||
BigIntVal expected(1); //0
|
||||
EXPECT_EQ(expected, result);
|
||||
}
|
||||
{
|
||||
BitmapValue bitmap1({1024, 1, 2019});
|
||||
BitmapValue bitmap2({0, 33, std::numeric_limits<uint64_t>::min()});
|
||||
BitmapValue bitmap3({33, 5, std::numeric_limits<uint64_t>::max()});
|
||||
BitmapValue bitmap_empty; //test empty
|
||||
BitmapValue bitmap_empty; //test empty
|
||||
|
||||
StringVal bitmap_src1 = convert_bitmap_to_string(ctx, bitmap1);
|
||||
StringVal bitmap_src2 = convert_bitmap_to_string(ctx, bitmap2);
|
||||
@ -412,7 +412,7 @@ TEST_F(BitmapFunctionsTest, bitmap_and_variable) {
|
||||
BigIntVal result = BitmapFunctions::bitmap_count(ctx, bitmap_result);
|
||||
|
||||
BigIntVal expected(0);
|
||||
ASSERT_EQ(expected, result);
|
||||
EXPECT_EQ(expected, result);
|
||||
}
|
||||
{
|
||||
BitmapValue bitmap1({1024, 1, 2019});
|
||||
@ -428,7 +428,7 @@ TEST_F(BitmapFunctionsTest, bitmap_and_variable) {
|
||||
BigIntVal result = BitmapFunctions::bitmap_count(ctx, bitmap_result);
|
||||
|
||||
BigIntVal expected(0);
|
||||
ASSERT_EQ(expected, result);
|
||||
EXPECT_EQ(expected, result);
|
||||
}
|
||||
}
|
||||
|
||||
@ -443,7 +443,7 @@ TEST_F(BitmapFunctionsTest, bitmap_xor) {
|
||||
BigIntVal result = BitmapFunctions::bitmap_count(ctx, bitmap_str);
|
||||
|
||||
BigIntVal expected(4);
|
||||
ASSERT_EQ(expected, result);
|
||||
EXPECT_EQ(expected, result);
|
||||
}
|
||||
|
||||
TEST_F(BitmapFunctionsTest, bitmap_xor_variable) {
|
||||
@ -459,15 +459,15 @@ TEST_F(BitmapFunctionsTest, bitmap_xor_variable) {
|
||||
|
||||
StringVal bitmap_result = BitmapFunctions::bitmap_xor(ctx, bitmap_src1, 2, bitmap_strs);
|
||||
BigIntVal result = BitmapFunctions::bitmap_count(ctx, bitmap_result);
|
||||
|
||||
|
||||
BigIntVal expected(5); //0,1,5,1024,18446744073709551615
|
||||
ASSERT_EQ(expected, result);
|
||||
EXPECT_EQ(expected, result);
|
||||
}
|
||||
{
|
||||
BitmapValue bitmap1({1024, 1, 2019});
|
||||
BitmapValue bitmap2({0, 33, std::numeric_limits<uint64_t>::min()});
|
||||
BitmapValue bitmap3({33, 5, std::numeric_limits<uint64_t>::max()});
|
||||
BitmapValue bitmap_empty; //test empty
|
||||
BitmapValue bitmap_empty; //test empty
|
||||
|
||||
StringVal bitmap_src1 = convert_bitmap_to_string(ctx, bitmap1);
|
||||
StringVal bitmap_src2 = convert_bitmap_to_string(ctx, bitmap2);
|
||||
@ -477,9 +477,9 @@ TEST_F(BitmapFunctionsTest, bitmap_xor_variable) {
|
||||
|
||||
StringVal bitmap_result = BitmapFunctions::bitmap_xor(ctx, bitmap_src1, 3, bitmap_strs);
|
||||
BigIntVal result = BitmapFunctions::bitmap_count(ctx, bitmap_result);
|
||||
|
||||
|
||||
BigIntVal expected(6); //0,1,5,1024,2019,18446744073709551615
|
||||
ASSERT_EQ(expected, result);
|
||||
EXPECT_EQ(expected, result);
|
||||
}
|
||||
{
|
||||
BitmapValue bitmap1({1024, 1, 2019});
|
||||
@ -495,7 +495,7 @@ TEST_F(BitmapFunctionsTest, bitmap_xor_variable) {
|
||||
BigIntVal result = BitmapFunctions::bitmap_count(ctx, bitmap_result);
|
||||
|
||||
BigIntVal expected(0);
|
||||
ASSERT_EQ(expected, result);
|
||||
EXPECT_EQ(expected, result);
|
||||
}
|
||||
}
|
||||
|
||||
@ -510,7 +510,7 @@ TEST_F(BitmapFunctionsTest, bitmap_xor_count) {
|
||||
BigIntVal result = BitmapFunctions::bitmap_xor_count(ctx, bitmap_src, bitmap_dst);
|
||||
|
||||
BigIntVal expected(4);
|
||||
ASSERT_EQ(expected.val, result.val);
|
||||
EXPECT_EQ(expected.val, result.val);
|
||||
}
|
||||
{
|
||||
BitmapValue bitmap1({1, 2, 3});
|
||||
@ -522,7 +522,7 @@ TEST_F(BitmapFunctionsTest, bitmap_xor_count) {
|
||||
BigIntVal result = BitmapFunctions::bitmap_xor_count(ctx, bitmap_src, bitmap_dst);
|
||||
|
||||
BigIntVal expected(0);
|
||||
ASSERT_EQ(expected.val, result.val);
|
||||
EXPECT_EQ(expected.val, result.val);
|
||||
}
|
||||
{
|
||||
BitmapValue bitmap1({1, 2, 3});
|
||||
@ -534,7 +534,7 @@ TEST_F(BitmapFunctionsTest, bitmap_xor_count) {
|
||||
BigIntVal result = BitmapFunctions::bitmap_xor_count(ctx, bitmap_src, bitmap_dst);
|
||||
|
||||
BigIntVal expected(6);
|
||||
ASSERT_EQ(expected.val, result.val);
|
||||
EXPECT_EQ(expected.val, result.val);
|
||||
}
|
||||
}
|
||||
|
||||
@ -550,15 +550,15 @@ TEST_F(BitmapFunctionsTest, bitmap_xor_count_variable) {
|
||||
StringVal bitmap_strs[2] = {bitmap_src2, bitmap_src3};
|
||||
|
||||
BigIntVal result = BitmapFunctions::bitmap_xor_count(ctx, bitmap_src1, 2, bitmap_strs);
|
||||
|
||||
|
||||
BigIntVal expected(5); //0,1,5,1024,18446744073709551615
|
||||
ASSERT_EQ(expected, result);
|
||||
EXPECT_EQ(expected, result);
|
||||
}
|
||||
{
|
||||
BitmapValue bitmap1({1024, 1, 2019});
|
||||
BitmapValue bitmap2({0, 33, std::numeric_limits<uint64_t>::min()});
|
||||
BitmapValue bitmap3({33, 5, std::numeric_limits<uint64_t>::max()});
|
||||
BitmapValue bitmap_empty; //test empty
|
||||
BitmapValue bitmap_empty; //test empty
|
||||
|
||||
StringVal bitmap_src1 = convert_bitmap_to_string(ctx, bitmap1);
|
||||
StringVal bitmap_src2 = convert_bitmap_to_string(ctx, bitmap2);
|
||||
@ -567,9 +567,9 @@ TEST_F(BitmapFunctionsTest, bitmap_xor_count_variable) {
|
||||
StringVal bitmap_strs[3] = {bitmap_src2, bitmap_src3, bitmap_src4};
|
||||
|
||||
BigIntVal result = BitmapFunctions::bitmap_xor_count(ctx, bitmap_src1, 3, bitmap_strs);
|
||||
|
||||
|
||||
BigIntVal expected(6); //0,1,5,1024,2019,18446744073709551615
|
||||
ASSERT_EQ(expected, result);
|
||||
EXPECT_EQ(expected, result);
|
||||
}
|
||||
{
|
||||
BitmapValue bitmap1({1024, 1, 2019});
|
||||
@ -582,7 +582,7 @@ TEST_F(BitmapFunctionsTest, bitmap_xor_count_variable) {
|
||||
StringVal bitmap_strs[3] = {bitmap_src2, bitmap_src3, StringVal::null()}; //test null
|
||||
|
||||
BigIntVal result = BitmapFunctions::bitmap_xor_count(ctx, bitmap_src1, 3, bitmap_strs);
|
||||
ASSERT_EQ(BigIntVal::null(), result);
|
||||
EXPECT_EQ(BigIntVal::null(), result);
|
||||
}
|
||||
}
|
||||
|
||||
@ -597,7 +597,7 @@ TEST_F(BitmapFunctionsTest, bitmap_xor_count_64) {
|
||||
BigIntVal result = BitmapFunctions::bitmap_xor_count(ctx, bitmap_src, bitmap_dst);
|
||||
|
||||
BigIntVal expected(4);
|
||||
ASSERT_EQ(expected.val, result.val);
|
||||
EXPECT_EQ(expected.val, result.val);
|
||||
}
|
||||
{
|
||||
BitmapValue bitmap1({14123400000000000501ull, 2, 1498760000000000503ull});
|
||||
@ -609,7 +609,7 @@ TEST_F(BitmapFunctionsTest, bitmap_xor_count_64) {
|
||||
BigIntVal result = BitmapFunctions::bitmap_xor_count(ctx, bitmap_src, bitmap_dst);
|
||||
|
||||
BigIntVal expected(0);
|
||||
ASSERT_EQ(expected.val, result.val);
|
||||
EXPECT_EQ(expected.val, result.val);
|
||||
}
|
||||
{
|
||||
BitmapValue bitmap1({15000000000000000501ull, 2, 1200000000000000503ull});
|
||||
@ -621,7 +621,7 @@ TEST_F(BitmapFunctionsTest, bitmap_xor_count_64) {
|
||||
BigIntVal result = BitmapFunctions::bitmap_xor_count(ctx, bitmap_src, bitmap_dst);
|
||||
|
||||
BigIntVal expected(6);
|
||||
ASSERT_EQ(expected.val, result.val);
|
||||
EXPECT_EQ(expected.val, result.val);
|
||||
}
|
||||
}
|
||||
|
||||
@ -631,24 +631,24 @@ TEST_F(BitmapFunctionsTest, bitmap_and_count) {
|
||||
StringVal bitmap_src1 = convert_bitmap_to_string(ctx, bitmap1);
|
||||
StringVal bitmap_src2 = convert_bitmap_to_string(ctx, bitmap2);
|
||||
BigIntVal result = BitmapFunctions::bitmap_and_count(ctx, bitmap_src1, bitmap_src2);
|
||||
ASSERT_EQ(0, result.val);
|
||||
EXPECT_EQ(0, result.val);
|
||||
|
||||
result = BitmapFunctions::bitmap_and_count(ctx, bitmap_src1, StringVal::null());
|
||||
ASSERT_EQ(0, result.val);
|
||||
EXPECT_EQ(0, result.val);
|
||||
|
||||
bitmap1 = BitmapValue({0, 1, 2, std::numeric_limits<uint64_t>::min()});
|
||||
bitmap2 = BitmapValue({0, 1, 2, std::numeric_limits<uint64_t>::max()});
|
||||
bitmap_src1 = convert_bitmap_to_string(ctx, bitmap1);
|
||||
bitmap_src2 = convert_bitmap_to_string(ctx, bitmap2);
|
||||
result = BitmapFunctions::bitmap_and_count(ctx, bitmap_src1, bitmap_src2);
|
||||
ASSERT_EQ(3, result.val);
|
||||
EXPECT_EQ(3, result.val);
|
||||
|
||||
bitmap1 = BitmapValue({1, 2, 3});
|
||||
bitmap2 = BitmapValue({3, 4, 5});
|
||||
bitmap_src1 = convert_bitmap_to_string(ctx, bitmap1);
|
||||
bitmap_src2 = convert_bitmap_to_string(ctx, bitmap2);
|
||||
result = BitmapFunctions::bitmap_and_count(ctx, bitmap_src1, bitmap_src2);
|
||||
ASSERT_EQ(1, result.val);
|
||||
EXPECT_EQ(1, result.val);
|
||||
}
|
||||
|
||||
TEST_F(BitmapFunctionsTest, bitmap_and_count_variable) {
|
||||
@ -663,14 +663,14 @@ TEST_F(BitmapFunctionsTest, bitmap_and_count_variable) {
|
||||
StringVal bitmap_strs[2] = {bitmap_src2, bitmap_src3};
|
||||
|
||||
BigIntVal result = BitmapFunctions::bitmap_and_count(ctx, bitmap_src1, 2, bitmap_strs);
|
||||
BigIntVal expected(1);//0
|
||||
ASSERT_EQ(expected, result);
|
||||
BigIntVal expected(1); //0
|
||||
EXPECT_EQ(expected, result);
|
||||
}
|
||||
{
|
||||
BitmapValue bitmap1({1024, 1, 2019});
|
||||
BitmapValue bitmap2({0, 33, std::numeric_limits<uint64_t>::min()});
|
||||
BitmapValue bitmap3({33, 5, std::numeric_limits<uint64_t>::max()});
|
||||
BitmapValue bitmap_empty; //test empty
|
||||
BitmapValue bitmap_empty; //test empty
|
||||
|
||||
StringVal bitmap_src1 = convert_bitmap_to_string(ctx, bitmap1);
|
||||
StringVal bitmap_src2 = convert_bitmap_to_string(ctx, bitmap2);
|
||||
@ -680,7 +680,7 @@ TEST_F(BitmapFunctionsTest, bitmap_and_count_variable) {
|
||||
|
||||
BigIntVal result = BitmapFunctions::bitmap_and_count(ctx, bitmap_src1, 3, bitmap_strs);
|
||||
BigIntVal expected(0);
|
||||
ASSERT_EQ(expected, result);
|
||||
EXPECT_EQ(expected, result);
|
||||
}
|
||||
{
|
||||
BitmapValue bitmap1({1024, 1, 2019});
|
||||
@ -693,7 +693,7 @@ TEST_F(BitmapFunctionsTest, bitmap_and_count_variable) {
|
||||
StringVal bitmap_strs[3] = {bitmap_src2, bitmap_src3, StringVal::null()}; //test null
|
||||
|
||||
BigIntVal result = BitmapFunctions::bitmap_and_count(ctx, bitmap_src1, 3, bitmap_strs);
|
||||
ASSERT_EQ(BigIntVal::null(), result);
|
||||
EXPECT_EQ(BigIntVal::null(), result);
|
||||
}
|
||||
}
|
||||
|
||||
@ -703,10 +703,10 @@ TEST_F(BitmapFunctionsTest, bitmap_and_count_64) {
|
||||
StringVal bitmap_src1 = convert_bitmap_to_string(ctx, bitmap1);
|
||||
StringVal bitmap_src2 = convert_bitmap_to_string(ctx, bitmap2);
|
||||
BigIntVal result = BitmapFunctions::bitmap_and_count(ctx, bitmap_src1, bitmap_src2);
|
||||
ASSERT_EQ(0, result.val);
|
||||
EXPECT_EQ(0, result.val);
|
||||
|
||||
result = BitmapFunctions::bitmap_and_count(ctx, bitmap_src1, StringVal::null());
|
||||
ASSERT_EQ(0, result.val);
|
||||
EXPECT_EQ(0, result.val);
|
||||
|
||||
bitmap1 = BitmapValue({11598000000000000501ull, 2, 1923400000000000503ull,
|
||||
std::numeric_limits<uint64_t>::min()});
|
||||
@ -715,14 +715,14 @@ TEST_F(BitmapFunctionsTest, bitmap_and_count_64) {
|
||||
bitmap_src1 = convert_bitmap_to_string(ctx, bitmap1);
|
||||
bitmap_src2 = convert_bitmap_to_string(ctx, bitmap2);
|
||||
result = BitmapFunctions::bitmap_and_count(ctx, bitmap_src1, bitmap_src2);
|
||||
ASSERT_EQ(3, result.val);
|
||||
EXPECT_EQ(3, result.val);
|
||||
|
||||
bitmap1 = BitmapValue({15555500000000000501ull, 2, 1400000000000000503ull});
|
||||
bitmap2 = BitmapValue({1400000000000000503ull, 5, 1400324000000000506ull});
|
||||
bitmap_src1 = convert_bitmap_to_string(ctx, bitmap1);
|
||||
bitmap_src2 = convert_bitmap_to_string(ctx, bitmap2);
|
||||
result = BitmapFunctions::bitmap_and_count(ctx, bitmap_src1, bitmap_src2);
|
||||
ASSERT_EQ(1, result.val);
|
||||
EXPECT_EQ(1, result.val);
|
||||
}
|
||||
|
||||
TEST_F(BitmapFunctionsTest, bitmap_or_count) {
|
||||
@ -731,24 +731,24 @@ TEST_F(BitmapFunctionsTest, bitmap_or_count) {
|
||||
StringVal bitmap_src1 = convert_bitmap_to_string(ctx, bitmap1);
|
||||
StringVal bitmap_src2 = convert_bitmap_to_string(ctx, bitmap2);
|
||||
BigIntVal result = BitmapFunctions::bitmap_or_count(ctx, bitmap_src1, bitmap_src2);
|
||||
ASSERT_EQ(3, result.val);
|
||||
EXPECT_EQ(3, result.val);
|
||||
|
||||
result = BitmapFunctions::bitmap_or_count(ctx, bitmap_src1, StringVal::null());
|
||||
ASSERT_EQ(0, result.val);
|
||||
EXPECT_EQ(0, result.val);
|
||||
|
||||
bitmap1 = BitmapValue({0, 1, 2, std::numeric_limits<uint64_t>::min()});
|
||||
bitmap2 = BitmapValue({0, 1, 2, std::numeric_limits<uint64_t>::max()});
|
||||
bitmap_src1 = convert_bitmap_to_string(ctx, bitmap1);
|
||||
bitmap_src2 = convert_bitmap_to_string(ctx, bitmap2);
|
||||
result = BitmapFunctions::bitmap_or_count(ctx, bitmap_src1, bitmap_src2);
|
||||
ASSERT_EQ(4, result.val);
|
||||
EXPECT_EQ(4, result.val);
|
||||
|
||||
bitmap1 = BitmapValue({1, 2, 3});
|
||||
bitmap2 = BitmapValue({3, 4, 5});
|
||||
bitmap_src1 = convert_bitmap_to_string(ctx, bitmap1);
|
||||
bitmap_src2 = convert_bitmap_to_string(ctx, bitmap2);
|
||||
result = BitmapFunctions::bitmap_or_count(ctx, bitmap_src1, bitmap_src2);
|
||||
ASSERT_EQ(5, result.val);
|
||||
EXPECT_EQ(5, result.val);
|
||||
}
|
||||
|
||||
TEST_F(BitmapFunctionsTest, bitmap_or_count_variable) {
|
||||
@ -756,7 +756,7 @@ TEST_F(BitmapFunctionsTest, bitmap_or_count_variable) {
|
||||
BitmapValue bitmap1({1024, 1, 2019});
|
||||
BitmapValue bitmap2({0, 33, std::numeric_limits<uint64_t>::min()});
|
||||
BitmapValue bitmap3({33, 5, std::numeric_limits<uint64_t>::max()});
|
||||
BitmapValue bitmap_empty; //test empty
|
||||
BitmapValue bitmap_empty; //test empty
|
||||
|
||||
StringVal bitmap_src1 = convert_bitmap_to_string(ctx, bitmap1);
|
||||
StringVal bitmap_src2 = convert_bitmap_to_string(ctx, bitmap2);
|
||||
@ -766,8 +766,8 @@ TEST_F(BitmapFunctionsTest, bitmap_or_count_variable) {
|
||||
|
||||
BigIntVal result = BitmapFunctions::bitmap_or_count(ctx, bitmap_src1, 3, bitmap_strs);
|
||||
|
||||
BigIntVal expected(7);//0,1,5,33,1024,2019,18446744073709551615
|
||||
ASSERT_EQ(expected, result);
|
||||
BigIntVal expected(7); //0,1,5,33,1024,2019,18446744073709551615
|
||||
EXPECT_EQ(expected, result);
|
||||
}
|
||||
{
|
||||
BitmapValue bitmap1({1024, 1, 2019});
|
||||
@ -780,7 +780,7 @@ TEST_F(BitmapFunctionsTest, bitmap_or_count_variable) {
|
||||
StringVal bitmap_strs[3] = {bitmap_src2, bitmap_src3, StringVal::null()}; //test null
|
||||
|
||||
BigIntVal result = BitmapFunctions::bitmap_or_count(ctx, bitmap_src1, 3, bitmap_strs);
|
||||
ASSERT_EQ(BigIntVal::null(), result);
|
||||
EXPECT_EQ(BigIntVal::null(), result);
|
||||
}
|
||||
}
|
||||
|
||||
@ -790,10 +790,10 @@ TEST_F(BitmapFunctionsTest, bitmap_or_count_64) {
|
||||
StringVal bitmap_src1 = convert_bitmap_to_string(ctx, bitmap1);
|
||||
StringVal bitmap_src2 = convert_bitmap_to_string(ctx, bitmap2);
|
||||
BigIntVal result = BitmapFunctions::bitmap_or_count(ctx, bitmap_src1, bitmap_src2);
|
||||
ASSERT_EQ(3, result.val);
|
||||
EXPECT_EQ(3, result.val);
|
||||
|
||||
result = BitmapFunctions::bitmap_or_count(ctx, bitmap_src1, StringVal::null());
|
||||
ASSERT_EQ(0, result.val);
|
||||
EXPECT_EQ(0, result.val);
|
||||
|
||||
bitmap1 = BitmapValue({11870000000000000501ull, 2, 1378900000000000503ull,
|
||||
std::numeric_limits<uint64_t>::min()});
|
||||
@ -802,14 +802,14 @@ TEST_F(BitmapFunctionsTest, bitmap_or_count_64) {
|
||||
bitmap_src1 = convert_bitmap_to_string(ctx, bitmap1);
|
||||
bitmap_src2 = convert_bitmap_to_string(ctx, bitmap2);
|
||||
result = BitmapFunctions::bitmap_or_count(ctx, bitmap_src1, bitmap_src2);
|
||||
ASSERT_EQ(5, result.val);
|
||||
EXPECT_EQ(5, result.val);
|
||||
|
||||
bitmap1 = BitmapValue({17870000000000000501ull, 2, 1400000000000000503ull});
|
||||
bitmap2 = BitmapValue({1400000000000000503ull, 5, 1678900000000000503ull});
|
||||
bitmap_src1 = convert_bitmap_to_string(ctx, bitmap1);
|
||||
bitmap_src2 = convert_bitmap_to_string(ctx, bitmap2);
|
||||
result = BitmapFunctions::bitmap_or_count(ctx, bitmap_src1, bitmap_src2);
|
||||
ASSERT_EQ(5, result.val);
|
||||
EXPECT_EQ(5, result.val);
|
||||
}
|
||||
|
||||
TEST_F(BitmapFunctionsTest, bitmap_not) {
|
||||
@ -823,7 +823,7 @@ TEST_F(BitmapFunctionsTest, bitmap_not) {
|
||||
StringVal bitmap_str = BitmapFunctions::bitmap_not(ctx, bitmap_src, bitmap_dst);
|
||||
BigIntVal result = BitmapFunctions::bitmap_count(ctx, bitmap_str);
|
||||
BigIntVal expected(2);
|
||||
ASSERT_EQ(expected, result);
|
||||
EXPECT_EQ(expected, result);
|
||||
|
||||
// result is single
|
||||
bitmap1 = BitmapValue({1024, 1, 2019});
|
||||
@ -835,7 +835,7 @@ TEST_F(BitmapFunctionsTest, bitmap_not) {
|
||||
bitmap_str = BitmapFunctions::bitmap_not(ctx, bitmap_src, bitmap_dst);
|
||||
result = BitmapFunctions::bitmap_count(ctx, bitmap_str);
|
||||
expected = BigIntVal(1);
|
||||
ASSERT_EQ(expected, result);
|
||||
EXPECT_EQ(expected, result);
|
||||
|
||||
// result is empty
|
||||
bitmap1 = BitmapValue({1024, 1, 2019});
|
||||
@ -847,7 +847,7 @@ TEST_F(BitmapFunctionsTest, bitmap_not) {
|
||||
bitmap_str = BitmapFunctions::bitmap_not(ctx, bitmap_src, bitmap_dst);
|
||||
result = BitmapFunctions::bitmap_count(ctx, bitmap_str);
|
||||
expected = BigIntVal(0);
|
||||
ASSERT_EQ(expected, result);
|
||||
EXPECT_EQ(expected, result);
|
||||
|
||||
bitmap1 = BitmapValue(1);
|
||||
bitmap2 = BitmapValue({2, 1});
|
||||
@ -856,7 +856,7 @@ TEST_F(BitmapFunctionsTest, bitmap_not) {
|
||||
bitmap_dst = convert_bitmap_to_string(ctx, bitmap2);
|
||||
bitmap_str = BitmapFunctions::bitmap_not(ctx, bitmap_src, bitmap_dst);
|
||||
result = BitmapFunctions::bitmap_count(ctx, bitmap_str);
|
||||
ASSERT_EQ(expected, result);
|
||||
EXPECT_EQ(expected, result);
|
||||
}
|
||||
|
||||
TEST_F(BitmapFunctionsTest, bitmap_and_not) {
|
||||
@ -871,7 +871,7 @@ TEST_F(BitmapFunctionsTest, bitmap_and_not) {
|
||||
BigIntVal result = BitmapFunctions::bitmap_count(ctx, bitmap_str);
|
||||
|
||||
BigIntVal expected(2);
|
||||
ASSERT_EQ(expected, result);
|
||||
EXPECT_EQ(expected, result);
|
||||
}
|
||||
{
|
||||
BitmapValue bitmap1({1, 2, 3});
|
||||
@ -884,7 +884,7 @@ TEST_F(BitmapFunctionsTest, bitmap_and_not) {
|
||||
BigIntVal result = BitmapFunctions::bitmap_count(ctx, bitmap_str);
|
||||
|
||||
BigIntVal expected(0);
|
||||
ASSERT_EQ(expected, result);
|
||||
EXPECT_EQ(expected, result);
|
||||
}
|
||||
{
|
||||
BitmapValue bitmap1({1, 2, 3});
|
||||
@ -897,7 +897,7 @@ TEST_F(BitmapFunctionsTest, bitmap_and_not) {
|
||||
BigIntVal result = BitmapFunctions::bitmap_count(ctx, bitmap_str);
|
||||
|
||||
BigIntVal expected(3);
|
||||
ASSERT_EQ(expected, result);
|
||||
EXPECT_EQ(expected, result);
|
||||
}
|
||||
}
|
||||
|
||||
@ -912,7 +912,7 @@ TEST_F(BitmapFunctionsTest, bitmap_and_not_count) {
|
||||
BigIntVal result = BitmapFunctions::bitmap_and_not_count(ctx, bitmap_src, bitmap_dst);
|
||||
|
||||
BigIntVal expected(2);
|
||||
ASSERT_EQ(expected.val, result.val);
|
||||
EXPECT_EQ(expected.val, result.val);
|
||||
}
|
||||
{
|
||||
BitmapValue bitmap1({1, 2, 3});
|
||||
@ -924,7 +924,7 @@ TEST_F(BitmapFunctionsTest, bitmap_and_not_count) {
|
||||
BigIntVal result = BitmapFunctions::bitmap_and_not_count(ctx, bitmap_src, bitmap_dst);
|
||||
|
||||
BigIntVal expected(0);
|
||||
ASSERT_EQ(expected.val, result.val);
|
||||
EXPECT_EQ(expected.val, result.val);
|
||||
}
|
||||
{
|
||||
BitmapValue bitmap1({1, 2, 3});
|
||||
@ -936,7 +936,7 @@ TEST_F(BitmapFunctionsTest, bitmap_and_not_count) {
|
||||
BigIntVal result = BitmapFunctions::bitmap_and_not_count(ctx, bitmap_src, bitmap_dst);
|
||||
|
||||
BigIntVal expected(3);
|
||||
ASSERT_EQ(expected.val, result.val);
|
||||
EXPECT_EQ(expected.val, result.val);
|
||||
}
|
||||
}
|
||||
|
||||
@ -945,11 +945,11 @@ TEST_F(BitmapFunctionsTest, bitmap_contains) {
|
||||
StringVal bitmap_str = convert_bitmap_to_string(ctx, bitmap);
|
||||
BooleanVal result = BitmapFunctions::bitmap_contains(ctx, bitmap_str, 5);
|
||||
BooleanVal expected(true);
|
||||
ASSERT_EQ(expected, result);
|
||||
EXPECT_EQ(expected, result);
|
||||
|
||||
BooleanVal result2 = BitmapFunctions::bitmap_contains(ctx, bitmap_str, 10);
|
||||
BooleanVal expected2(false);
|
||||
ASSERT_EQ(expected2, result2);
|
||||
EXPECT_EQ(expected2, result2);
|
||||
}
|
||||
|
||||
TEST_F(BitmapFunctionsTest, bitmap_has_any) {
|
||||
@ -960,13 +960,13 @@ TEST_F(BitmapFunctionsTest, bitmap_has_any) {
|
||||
StringVal rhs = convert_bitmap_to_string(ctx, bitmap2);
|
||||
BooleanVal result = BitmapFunctions::bitmap_has_any(ctx, lhs, rhs);
|
||||
BooleanVal expected(true);
|
||||
ASSERT_EQ(expected, result);
|
||||
EXPECT_EQ(expected, result);
|
||||
|
||||
BitmapValue bitmap3(10);
|
||||
StringVal r3 = convert_bitmap_to_string(ctx, bitmap3);
|
||||
BooleanVal result1 = BitmapFunctions::bitmap_has_any(ctx, lhs, r3);
|
||||
BooleanVal expected2(false);
|
||||
ASSERT_EQ(expected2, result1);
|
||||
EXPECT_EQ(expected2, result1);
|
||||
}
|
||||
|
||||
TEST_F(BitmapFunctionsTest, bitmap_has_all) {
|
||||
@ -977,33 +977,33 @@ TEST_F(BitmapFunctionsTest, bitmap_has_all) {
|
||||
StringVal string_val1 = convert_bitmap_to_string(ctx, bitmap1);
|
||||
StringVal string_val2 = convert_bitmap_to_string(ctx, bitmap2);
|
||||
BooleanVal result = BitmapFunctions::bitmap_has_all(ctx, string_val1, string_val2);
|
||||
ASSERT_EQ(BooleanVal {true}, result);
|
||||
EXPECT_EQ(BooleanVal {true}, result);
|
||||
|
||||
bitmap1 = BitmapValue({0, 1, 2});
|
||||
bitmap2 = BitmapValue({0, 1, 2, std::numeric_limits<uint64_t>::max()});
|
||||
string_val1 = convert_bitmap_to_string(ctx, bitmap1);
|
||||
string_val2 = convert_bitmap_to_string(ctx, bitmap2);
|
||||
result = BitmapFunctions::bitmap_has_all(ctx, string_val1, string_val2);
|
||||
ASSERT_EQ(BooleanVal {false}, result);
|
||||
EXPECT_EQ(BooleanVal {false}, result);
|
||||
|
||||
bitmap1 = BitmapValue();
|
||||
bitmap2 = BitmapValue({0, 1, 2});
|
||||
string_val1 = convert_bitmap_to_string(ctx, bitmap1);
|
||||
string_val2 = convert_bitmap_to_string(ctx, bitmap2);
|
||||
result = BitmapFunctions::bitmap_has_all(ctx, string_val1, string_val2);
|
||||
ASSERT_EQ(BooleanVal {false}, result);
|
||||
EXPECT_EQ(BooleanVal {false}, result);
|
||||
|
||||
bitmap1 = BitmapValue();
|
||||
bitmap2 = BitmapValue();
|
||||
string_val1 = convert_bitmap_to_string(ctx, bitmap1);
|
||||
string_val2 = convert_bitmap_to_string(ctx, bitmap2);
|
||||
result = BitmapFunctions::bitmap_has_all(ctx, string_val1, string_val2);
|
||||
ASSERT_EQ(BooleanVal {true}, result);
|
||||
EXPECT_EQ(BooleanVal {true}, result);
|
||||
|
||||
bitmap1 = BitmapValue();
|
||||
string_val1 = convert_bitmap_to_string(ctx, bitmap1);
|
||||
result = BitmapFunctions::bitmap_has_all(ctx, string_val1, StringVal::null());
|
||||
ASSERT_TRUE(result.is_null);
|
||||
EXPECT_TRUE(result.is_null);
|
||||
}
|
||||
|
||||
TEST_F(BitmapFunctionsTest, bitmap_from_string) {
|
||||
@ -1011,61 +1011,61 @@ TEST_F(BitmapFunctionsTest, bitmap_from_string) {
|
||||
{
|
||||
StringVal val = StringVal("0,1,2");
|
||||
auto bitmap_str = BitmapFunctions::bitmap_from_string(utils.get_fn_ctx(), val);
|
||||
ASSERT_FALSE(bitmap_str.is_null);
|
||||
EXPECT_FALSE(bitmap_str.is_null);
|
||||
BitmapValue bitmap((const char*)bitmap_str.ptr);
|
||||
ASSERT_TRUE(bitmap.contains(0));
|
||||
ASSERT_TRUE(bitmap.contains(1));
|
||||
ASSERT_TRUE(bitmap.contains(2));
|
||||
EXPECT_TRUE(bitmap.contains(0));
|
||||
EXPECT_TRUE(bitmap.contains(1));
|
||||
EXPECT_TRUE(bitmap.contains(2));
|
||||
}
|
||||
{
|
||||
StringVal val = StringVal("a,b,1,2");
|
||||
auto bitmap_str = BitmapFunctions::bitmap_from_string(utils.get_fn_ctx(), val);
|
||||
ASSERT_TRUE(bitmap_str.is_null);
|
||||
EXPECT_TRUE(bitmap_str.is_null);
|
||||
}
|
||||
{
|
||||
StringVal val = StringVal("-1,1,2");
|
||||
auto bitmap_str = BitmapFunctions::bitmap_from_string(utils.get_fn_ctx(), val);
|
||||
ASSERT_TRUE(bitmap_str.is_null);
|
||||
EXPECT_TRUE(bitmap_str.is_null);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(BitmapFunctionsTest, bitmap_max) {
|
||||
BigIntVal result = BitmapFunctions::bitmap_max(ctx, StringVal::null());
|
||||
ASSERT_TRUE(result.is_null);
|
||||
EXPECT_TRUE(result.is_null);
|
||||
|
||||
BitmapValue bitmap1;
|
||||
StringVal empty_str = convert_bitmap_to_string(ctx, bitmap1);
|
||||
result = BitmapFunctions::bitmap_max(ctx, empty_str);
|
||||
ASSERT_TRUE(result.is_null);
|
||||
EXPECT_TRUE(result.is_null);
|
||||
|
||||
BitmapValue bitmap2 = BitmapValue(1024);
|
||||
StringVal bitmap_str = convert_bitmap_to_string(ctx, bitmap2);
|
||||
result = BitmapFunctions::bitmap_max(ctx, bitmap_str);
|
||||
ASSERT_EQ(BigIntVal(1024), result);
|
||||
EXPECT_EQ(BigIntVal(1024), result);
|
||||
|
||||
BitmapValue bitmap3 = BitmapValue({1024, 1});
|
||||
bitmap_str = convert_bitmap_to_string(ctx, bitmap3);
|
||||
result = BitmapFunctions::bitmap_max(ctx, bitmap_str);
|
||||
ASSERT_EQ(BigIntVal(1024), result);
|
||||
EXPECT_EQ(BigIntVal(1024), result);
|
||||
|
||||
BitmapValue bitmap4 = BitmapValue({1024, 3, 2});
|
||||
bitmap_str = convert_bitmap_to_string(ctx, bitmap4);
|
||||
result = BitmapFunctions::bitmap_max(ctx, bitmap_str);
|
||||
ASSERT_EQ(BigIntVal(1024), result);
|
||||
EXPECT_EQ(BigIntVal(1024), result);
|
||||
}
|
||||
|
||||
TEST_F(BitmapFunctionsTest, bitmap_subset_in_range) {
|
||||
// null
|
||||
StringVal res = BitmapFunctions::bitmap_subset_in_range(ctx, StringVal::null(), BigIntVal(1),
|
||||
BigIntVal(3));
|
||||
ASSERT_TRUE(res.is_null);
|
||||
EXPECT_TRUE(res.is_null);
|
||||
|
||||
// empty
|
||||
BitmapValue bitmap0;
|
||||
StringVal empty_str = convert_bitmap_to_string(ctx, bitmap0);
|
||||
res = BitmapFunctions::bitmap_subset_in_range(ctx, empty_str, BigIntVal(1), BigIntVal(3));
|
||||
BigIntVal result = BitmapFunctions::bitmap_count(ctx, res);
|
||||
ASSERT_EQ(BigIntVal(0), result);
|
||||
EXPECT_EQ(BigIntVal(0), result);
|
||||
|
||||
// normal
|
||||
BitmapValue bitmap1({0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
|
||||
@ -1075,51 +1075,51 @@ TEST_F(BitmapFunctionsTest, bitmap_subset_in_range) {
|
||||
StringVal bitmap_src = convert_bitmap_to_string(ctx, bitmap1);
|
||||
res = BitmapFunctions::bitmap_subset_in_range(ctx, bitmap_src, BigIntVal(30), BigIntVal(200));
|
||||
result = BitmapFunctions::bitmap_count(ctx, res);
|
||||
ASSERT_EQ(BigIntVal(5), result);
|
||||
EXPECT_EQ(BigIntVal(5), result);
|
||||
|
||||
res = BitmapFunctions::bitmap_subset_in_range(ctx, bitmap_src, BigIntVal(0), BigIntVal(1));
|
||||
result = BitmapFunctions::bitmap_count(ctx, res);
|
||||
ASSERT_EQ(BigIntVal(1), result);
|
||||
EXPECT_EQ(BigIntVal(1), result);
|
||||
|
||||
res = BitmapFunctions::bitmap_subset_in_range(ctx, bitmap_src, BigIntVal(11), BigIntVal(15));
|
||||
result = BitmapFunctions::bitmap_count(ctx, res);
|
||||
ASSERT_EQ(BigIntVal(4), result);
|
||||
EXPECT_EQ(BigIntVal(4), result);
|
||||
|
||||
res = BitmapFunctions::bitmap_subset_in_range(ctx, bitmap_src, BigIntVal(11),
|
||||
DecimalV2Value::MAX_INT64);
|
||||
result = BitmapFunctions::bitmap_count(ctx, res);
|
||||
ASSERT_EQ(BigIntVal(27), result);
|
||||
EXPECT_EQ(BigIntVal(27), result);
|
||||
|
||||
// innormal
|
||||
// start >= end
|
||||
res = BitmapFunctions::bitmap_subset_in_range(ctx, bitmap_src, BigIntVal(30), BigIntVal(20));
|
||||
ASSERT_TRUE(res.is_null);
|
||||
EXPECT_TRUE(res.is_null);
|
||||
|
||||
res = BitmapFunctions::bitmap_subset_in_range(ctx, bitmap_src, BigIntVal(20), BigIntVal(20));
|
||||
ASSERT_TRUE(res.is_null);
|
||||
EXPECT_TRUE(res.is_null);
|
||||
|
||||
// negative range
|
||||
res = BitmapFunctions::bitmap_subset_in_range(ctx, bitmap_src, BigIntVal(-10), BigIntVal(20));
|
||||
ASSERT_TRUE(res.is_null);
|
||||
EXPECT_TRUE(res.is_null);
|
||||
|
||||
res = BitmapFunctions::bitmap_subset_in_range(ctx, bitmap_src, BigIntVal(10), BigIntVal(-20));
|
||||
ASSERT_TRUE(res.is_null);
|
||||
EXPECT_TRUE(res.is_null);
|
||||
|
||||
res = BitmapFunctions::bitmap_subset_in_range(ctx, bitmap_src, BigIntVal(-10), BigIntVal(-20));
|
||||
ASSERT_TRUE(res.is_null);
|
||||
EXPECT_TRUE(res.is_null);
|
||||
|
||||
// null range
|
||||
res = BitmapFunctions::bitmap_subset_in_range(ctx, bitmap_src, BigIntVal::null(),
|
||||
BigIntVal(20));
|
||||
ASSERT_TRUE(res.is_null);
|
||||
EXPECT_TRUE(res.is_null);
|
||||
|
||||
res = BitmapFunctions::bitmap_subset_in_range(ctx, bitmap_src, BigIntVal(10),
|
||||
BigIntVal::null());
|
||||
ASSERT_TRUE(res.is_null);
|
||||
EXPECT_TRUE(res.is_null);
|
||||
|
||||
res = BitmapFunctions::bitmap_subset_in_range(ctx, bitmap_src, BigIntVal::null(),
|
||||
BigIntVal::null());
|
||||
ASSERT_TRUE(res.is_null);
|
||||
EXPECT_TRUE(res.is_null);
|
||||
}
|
||||
|
||||
TEST_F(BitmapFunctionsTest, sub_bitmap) {
|
||||
@ -1131,69 +1131,69 @@ TEST_F(BitmapFunctionsTest, sub_bitmap) {
|
||||
|
||||
StringVal res = BitmapFunctions::sub_bitmap(ctx, bitmap_src, BigIntVal(30), BigIntVal(6));
|
||||
BitmapValue bitmap2({30, 31, 32, 33, 100, 200});
|
||||
ASSERT_EQ(res, convert_bitmap_to_string(ctx, bitmap2));
|
||||
EXPECT_EQ(res, convert_bitmap_to_string(ctx, bitmap2));
|
||||
|
||||
res = BitmapFunctions::sub_bitmap(ctx, bitmap_src, BigIntVal(30), BigIntVal(100));
|
||||
BitmapValue bitmap3({30, 31, 32, 33, 100, 200, 500});
|
||||
ASSERT_EQ(res, convert_bitmap_to_string(ctx, bitmap3));
|
||||
EXPECT_EQ(res, convert_bitmap_to_string(ctx, bitmap3));
|
||||
|
||||
res = BitmapFunctions::sub_bitmap(ctx, bitmap_src, BigIntVal(30), BigIntVal(INT64_MAX));
|
||||
BitmapValue bitmap4({30, 31, 32, 33, 100, 200, 500});
|
||||
ASSERT_EQ(res, convert_bitmap_to_string(ctx, bitmap4));
|
||||
EXPECT_EQ(res, convert_bitmap_to_string(ctx, bitmap4));
|
||||
|
||||
res = BitmapFunctions::sub_bitmap(ctx, bitmap_src, BigIntVal(0), BigIntVal(2));
|
||||
BitmapValue bitmap5({0, 1});
|
||||
ASSERT_EQ(res, convert_bitmap_to_string(ctx, bitmap5));
|
||||
EXPECT_EQ(res, convert_bitmap_to_string(ctx, bitmap5));
|
||||
|
||||
res = BitmapFunctions::sub_bitmap(ctx, bitmap_src, BigIntVal(-1), BigIntVal(2));
|
||||
BitmapValue bitmap6(500);
|
||||
ASSERT_EQ(res, convert_bitmap_to_string(ctx, bitmap6));
|
||||
EXPECT_EQ(res, convert_bitmap_to_string(ctx, bitmap6));
|
||||
|
||||
res = BitmapFunctions::sub_bitmap(ctx, bitmap_src, BigIntVal(-7), BigIntVal(6));
|
||||
BitmapValue bitmap7({30, 31, 32, 33, 100, 200});
|
||||
ASSERT_EQ(res, convert_bitmap_to_string(ctx, bitmap7));
|
||||
EXPECT_EQ(res, convert_bitmap_to_string(ctx, bitmap7));
|
||||
|
||||
// null
|
||||
res = BitmapFunctions::sub_bitmap(ctx, bitmap_src, BigIntVal(0), BigIntVal(0));
|
||||
ASSERT_TRUE(res.is_null);
|
||||
EXPECT_TRUE(res.is_null);
|
||||
|
||||
res = BitmapFunctions::sub_bitmap(ctx, bitmap_src, BigIntVal(100), BigIntVal(6));
|
||||
ASSERT_TRUE(res.is_null);
|
||||
EXPECT_TRUE(res.is_null);
|
||||
|
||||
res = BitmapFunctions::sub_bitmap(ctx, bitmap_src, BigIntVal(-100), BigIntVal(6));
|
||||
ASSERT_TRUE(res.is_null);
|
||||
EXPECT_TRUE(res.is_null);
|
||||
|
||||
res = BitmapFunctions::sub_bitmap(ctx, bitmap_src, BigIntVal(30), BigIntVal(INT64_MIN));
|
||||
ASSERT_TRUE(res.is_null);
|
||||
EXPECT_TRUE(res.is_null);
|
||||
|
||||
res = BitmapFunctions::sub_bitmap(ctx, StringVal::null(), BigIntVal(1), BigIntVal(3));
|
||||
ASSERT_TRUE(res.is_null);
|
||||
EXPECT_TRUE(res.is_null);
|
||||
|
||||
res = BitmapFunctions::sub_bitmap(ctx, bitmap_src, BigIntVal::null(), BigIntVal(20));
|
||||
ASSERT_TRUE(res.is_null);
|
||||
EXPECT_TRUE(res.is_null);
|
||||
|
||||
res = BitmapFunctions::sub_bitmap(ctx, bitmap_src, BigIntVal(10), BigIntVal::null());
|
||||
ASSERT_TRUE(res.is_null);
|
||||
EXPECT_TRUE(res.is_null);
|
||||
|
||||
// empty
|
||||
BitmapValue bitmap0;
|
||||
StringVal empty_str = convert_bitmap_to_string(ctx, bitmap0);
|
||||
res = BitmapFunctions::sub_bitmap(ctx, empty_str, BigIntVal(0), BigIntVal(3));
|
||||
ASSERT_TRUE(res.is_null);
|
||||
EXPECT_TRUE(res.is_null);
|
||||
}
|
||||
|
||||
TEST_F(BitmapFunctionsTest, bitmap_subset_limit) {
|
||||
// null
|
||||
StringVal res = BitmapFunctions::bitmap_subset_limit(ctx, StringVal::null(), BigIntVal(1),
|
||||
BigIntVal(3));
|
||||
ASSERT_TRUE(res.is_null);
|
||||
EXPECT_TRUE(res.is_null);
|
||||
|
||||
// empty
|
||||
BitmapValue bitmap0;
|
||||
StringVal empty_str = convert_bitmap_to_string(ctx, bitmap0);
|
||||
res = BitmapFunctions::bitmap_subset_limit(ctx, empty_str, BigIntVal(10), BigIntVal(20));
|
||||
BigIntVal result = BitmapFunctions::bitmap_count(ctx, res);
|
||||
ASSERT_EQ(BigIntVal(0), result);
|
||||
EXPECT_EQ(BigIntVal(0), result);
|
||||
|
||||
// normal
|
||||
BitmapValue bitmap1({0, 1, 2, 3, 4, 5, 6, 7, 45, 47, 49, 43, 8, 9,
|
||||
@ -1203,47 +1203,42 @@ TEST_F(BitmapFunctionsTest, bitmap_subset_limit) {
|
||||
StringVal bitmap_src = convert_bitmap_to_string(ctx, bitmap1);
|
||||
res = BitmapFunctions::bitmap_subset_limit(ctx, bitmap_src, BigIntVal(4), BigIntVal(10));
|
||||
result = BitmapFunctions::bitmap_count(ctx, res);
|
||||
ASSERT_EQ(BigIntVal(10), result);
|
||||
EXPECT_EQ(BigIntVal(10), result);
|
||||
|
||||
res = BitmapFunctions::bitmap_subset_limit(ctx, bitmap_src, BigIntVal(0), BigIntVal(1));
|
||||
result = BitmapFunctions::bitmap_count(ctx, res);
|
||||
ASSERT_EQ(BigIntVal(1), result);
|
||||
EXPECT_EQ(BigIntVal(1), result);
|
||||
|
||||
res = BitmapFunctions::bitmap_subset_limit(ctx, bitmap_src, BigIntVal(35), BigIntVal(10));
|
||||
result = BitmapFunctions::bitmap_count(ctx, res);
|
||||
ASSERT_EQ(BigIntVal(7), result);
|
||||
EXPECT_EQ(BigIntVal(7), result);
|
||||
|
||||
res = BitmapFunctions::bitmap_subset_limit(ctx, bitmap_src, BigIntVal(31),
|
||||
DecimalV2Value::MAX_INT64);
|
||||
result = BitmapFunctions::bitmap_count(ctx, res);
|
||||
ASSERT_EQ(BigIntVal(10), result);
|
||||
EXPECT_EQ(BigIntVal(10), result);
|
||||
|
||||
// abnormal
|
||||
// negative range_start and cardinality_limit
|
||||
res = BitmapFunctions::bitmap_subset_limit(ctx, bitmap_src, BigIntVal(-10), BigIntVal(20));
|
||||
ASSERT_TRUE(res.is_null);
|
||||
EXPECT_TRUE(res.is_null);
|
||||
|
||||
res = BitmapFunctions::bitmap_subset_limit(ctx, bitmap_src, BigIntVal(10), BigIntVal(-20));
|
||||
ASSERT_TRUE(res.is_null);
|
||||
EXPECT_TRUE(res.is_null);
|
||||
|
||||
res = BitmapFunctions::bitmap_subset_limit(ctx, bitmap_src, BigIntVal(-10), BigIntVal(-20));
|
||||
ASSERT_TRUE(res.is_null);
|
||||
EXPECT_TRUE(res.is_null);
|
||||
|
||||
// null range
|
||||
res = BitmapFunctions::bitmap_subset_limit(ctx, bitmap_src, BigIntVal::null(), BigIntVal(20));
|
||||
ASSERT_TRUE(res.is_null);
|
||||
EXPECT_TRUE(res.is_null);
|
||||
|
||||
res = BitmapFunctions::bitmap_subset_limit(ctx, bitmap_src, BigIntVal(10), BigIntVal::null());
|
||||
ASSERT_TRUE(res.is_null);
|
||||
EXPECT_TRUE(res.is_null);
|
||||
|
||||
res = BitmapFunctions::bitmap_subset_limit(ctx, bitmap_src, BigIntVal::null(),
|
||||
BigIntVal::null());
|
||||
ASSERT_TRUE(res.is_null);
|
||||
EXPECT_TRUE(res.is_null);
|
||||
}
|
||||
|
||||
} // namespace doris
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user