MCPcopy Create free account
hub / github.com/apache/arrow / ASSERT_OK_AND_ASSIGN

Function ASSERT_OK_AND_ASSIGN

cpp/src/arrow/array/array_union_test.cc:626–723  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

624 auto expected_offsets = ArrayFromJSON(int32(), "[0, 1, 0, 1, 2, 2, 0, 1, 2]");
625
626 ASSERT_OK_AND_ASSIGN(auto expected,
627 DenseUnionArray::Make(*expected_types, *expected_offsets,
628 {expected_i8, expected_str, expected_dbl},
629 {"i8", "str", "dbl"}, {I8, STR, DBL}));
630
631 ASSERT_EQ(expected->type()->ToString(), actual->type()->ToString());
632 ASSERT_ARRAYS_EQUAL(*expected, *actual);
633}
634
635TEST_F(DenseUnionBuilderTest, ListOfInferredType) {
636 std::shared_ptr<ListArray> actual;
637 AppendListOfInferred(&actual);
638
639 auto expected_type = list(
640 dense_union({field("i8", int8()), field("str", utf8()), field("dbl", float64())},
641 {I8, STR, DBL}));
642 ASSERT_EQ(expected_type->ToString(), actual->type()->ToString());
643}
644
645TEST_F(SparseUnionBuilderTest, Basics) {
646 union_builder.reset(new SparseUnionBuilder(
647 default_memory_pool(), {i8_builder, str_builder, dbl_builder},
648 sparse_union({field("i8", int8()), field("str", utf8()), field("dbl", float64())},
649 {I8, STR, DBL})));
650
651 AppendBasics();
652
653 auto expected_i8 =
654 ArrayFromJSON(int8(), "[33, null, null, null, null, 10, null, -10, null]");
655 auto expected_str =
656 ArrayFromJSON(utf8(), R"([null, "abc", null, null, "", null, "def", null, null])");
657 auto expected_dbl =
658 ArrayFromJSON(float64(), "[null, null, 1.0, -1.0, null, null, null, null, 0.5]");
659
660 ASSERT_OK_AND_ASSIGN(
661 auto expected,
662 SparseUnionArray::Make(*expected_types, {expected_i8, expected_str, expected_dbl},
663 {"i8", "str", "dbl"}, {I8, STR, DBL}));
664
665 ASSERT_EQ(expected->type()->ToString(), actual->type()->ToString());
666 ASSERT_ARRAYS_EQUAL(*expected, *actual);
667}
668
669TEST_F(SparseUnionBuilderTest, NullsAndEmptyValues) {
670 union_builder.reset(new SparseUnionBuilder(
671 default_memory_pool(), {i8_builder, str_builder, dbl_builder},
672 sparse_union({field("i8", int8()), field("str", utf8()), field("dbl", float64())},
673 {I8, STR, DBL})));
674 AppendNullsAndEmptyValues();
675
676 // "abc", null, 0, 42, null, null, 0, 0
677 // (note that getting 0 for empty values is implementation-defined)
678 auto expected_i8 = ArrayFromJSON(int8(), "[0, null, 0, 42, null, null, 0, 0]");
679 auto expected_str = ArrayFromJSON(utf8(), R"(["abc", "", "", "", "", "", "", ""])");
680 auto expected_dbl = ArrayFromJSON(float64(), "[0, 0, 0, 0, 0, 0, 0, 0]");
681
682 ASSERT_OK_AND_ASSIGN(
683 auto expected,

Callers 15

MakeArrayMethod · 0.70
TEST_FFunction · 0.70
TESTFunction · 0.70
TEST_FFunction · 0.70
TEST_FFunction · 0.70
TEST_FFunction · 0.70
CheckMethod · 0.70
array_test.ccFile · 0.70
TEST_PFunction · 0.70
TEST_FFunction · 0.70

Calls 15

listFunction · 0.85
dense_unionFunction · 0.85
default_memory_poolFunction · 0.85
sparse_unionFunction · 0.85
ArrayFromJSONFunction · 0.85
struct_Function · 0.85
AppendChildMethod · 0.80
TEST_FFunction · 0.70
MakeFunction · 0.70
fieldFunction · 0.50
ToStringMethod · 0.45
typeMethod · 0.45

Tested by

no test coverage detected