@@ -2191,6 +2191,36 @@ TEST(TestUnionType, Basics) {
21912191 ASSERT_EQ (ty6->child_ids (), child_ids2);
21922192}
21932193
2194+ TEST (TestUnionType, MaxTypeCode) {
2195+ std::vector<std::shared_ptr<Field>> fields;
2196+ for (int32_t i = 0 ; i <= UnionType::kMaxTypeCode ; i++) {
2197+ fields.push_back (field (std::to_string (i), int32 ()));
2198+ }
2199+
2200+ std::vector<int8_t > type_codes (fields.size ());
2201+ std::iota (type_codes.begin (), type_codes.end (), 0 );
2202+
2203+ auto t1 = checked_pointer_cast<UnionType>(dense_union (fields, type_codes));
2204+ ASSERT_EQ (t1->type_codes ().size (), UnionType::kMaxTypeCode + 1 );
2205+ ASSERT_EQ (t1->child_ids ().size (), UnionType::kMaxTypeCode + 1 );
2206+
2207+ auto t2 = checked_pointer_cast<UnionType>(dense_union (fields));
2208+ ASSERT_EQ (t2->type_codes ().size (), UnionType::kMaxTypeCode + 1 );
2209+ ASSERT_EQ (t2->child_ids ().size (), UnionType::kMaxTypeCode + 1 );
2210+
2211+ AssertTypeEqual (*t1, *t2);
2212+
2213+ auto t3 = checked_pointer_cast<UnionType>(sparse_union (fields, type_codes));
2214+ ASSERT_EQ (t3->type_codes ().size (), UnionType::kMaxTypeCode + 1 );
2215+ ASSERT_EQ (t3->child_ids ().size (), UnionType::kMaxTypeCode + 1 );
2216+
2217+ auto t4 = checked_pointer_cast<UnionType>(sparse_union (fields));
2218+ ASSERT_EQ (t4->type_codes ().size (), UnionType::kMaxTypeCode + 1 );
2219+ ASSERT_EQ (t4->child_ids ().size (), UnionType::kMaxTypeCode + 1 );
2220+
2221+ AssertTypeEqual (*t3, *t4);
2222+ }
2223+
21942224TEST (TestDictionaryType, Basics) {
21952225 auto value_type = int32 ();
21962226
0 commit comments