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:581–678  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

579 auto expected_offsets = ArrayFromJSON(int32(), "[0, 1, 0, 1, 2, 2, 0, 1, 2]");
580
581 ASSERT_OK_AND_ASSIGN(auto expected,
582 DenseUnionArray::Make(*expected_types, *expected_offsets,
583 {expected_i8, expected_str, expected_dbl},
584 {"i8", "str", "dbl"}, {I8, STR, DBL}));
585
586 ASSERT_EQ(expected->type()->ToString(), actual->type()->ToString());
587 ASSERT_ARRAYS_EQUAL(*expected, *actual);
588}
589
590TEST_F(DenseUnionBuilderTest, ListOfInferredType) {
591 std::shared_ptr<ListArray> actual;
592 AppendListOfInferred(&actual);
593
594 auto expected_type = list(
595 dense_union({field("i8", int8()), field("str", utf8()), field("dbl", float64())},
596 {I8, STR, DBL}));
597 ASSERT_EQ(expected_type->ToString(), actual->type()->ToString());
598}
599
600TEST_F(SparseUnionBuilderTest, Basics) {
601 union_builder.reset(new SparseUnionBuilder(
602 default_memory_pool(), {i8_builder, str_builder, dbl_builder},
603 sparse_union({field("i8", int8()), field("str", utf8()), field("dbl", float64())},
604 {I8, STR, DBL})));
605
606 AppendBasics();
607
608 auto expected_i8 =
609 ArrayFromJSON(int8(), "[33, null, null, null, null, 10, null, -10, null]");
610 auto expected_str =
611 ArrayFromJSON(utf8(), R"([null, "abc", null, null, "", null, "def", null, null])");
612 auto expected_dbl =
613 ArrayFromJSON(float64(), "[null, null, 1.0, -1.0, null, null, null, null, 0.5]");
614
615 ASSERT_OK_AND_ASSIGN(
616 auto expected,
617 SparseUnionArray::Make(*expected_types, {expected_i8, expected_str, expected_dbl},
618 {"i8", "str", "dbl"}, {I8, STR, DBL}));
619
620 ASSERT_EQ(expected->type()->ToString(), actual->type()->ToString());
621 ASSERT_ARRAYS_EQUAL(*expected, *actual);
622}
623
624TEST_F(SparseUnionBuilderTest, NullsAndEmptyValues) {
625 union_builder.reset(new SparseUnionBuilder(
626 default_memory_pool(), {i8_builder, str_builder, dbl_builder},
627 sparse_union({field("i8", int8()), field("str", utf8()), field("dbl", float64())},
628 {I8, STR, DBL})));
629 AppendNullsAndEmptyValues();
630
631 // "abc", null, 0, 42, null, null, 0, 0
632 // (note that getting 0 for empty values is implementation-defined)
633 auto expected_i8 = ArrayFromJSON(int8(), "[0, null, 0, 42, null, null, 0, 0]");
634 auto expected_str = ArrayFromJSON(utf8(), R"(["abc", "", "", "", "", "", "", ""])");
635 auto expected_dbl = ArrayFromJSON(float64(), "[0, 0, 0, 0, 0, 0, 0, 0]");
636
637 ASSERT_OK_AND_ASSIGN(
638 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