@@ -136,7 +136,6 @@ TEST(LiteralTest, LongCastTo) {
136136 EXPECT_EQ (double_result->type ()->type_id (), TypeId::kDouble );
137137}
138138
139- // Test overflow cases
140139TEST (LiteralTest, LongCastToIntOverflow) {
141140 auto max_long =
142141 Literal::Long (static_cast <int64_t >(std::numeric_limits<int32_t >::max ()) + 1 );
@@ -495,23 +494,22 @@ INSTANTIATE_TEST_SUITE_P(
495494 // Fixed type
496495 LiteralRoundTripParam{" FixedLength4" ,
497496 {0x01 , 0x02 , 0x03 , 0x04 },
498- Literal::Fixed ({0x01 , 0x02 , 0x03 , 0x04 }, 4 ),
497+ Literal::Fixed ({0x01 , 0x02 , 0x03 , 0x04 }),
499498 fixed (4 )},
500499 LiteralRoundTripParam{
501500 " FixedLength8" ,
502501 {0xAA , 0xBB , 0xCC , 0xDD , 0xEE , 0xFF , 0x00 , 0x11 },
503- Literal::Fixed ({0xAA , 0xBB , 0xCC , 0xDD , 0xEE , 0xFF , 0x00 , 0x11 }, 8 ),
502+ Literal::Fixed ({0xAA , 0xBB , 0xCC , 0xDD , 0xEE , 0xFF , 0x00 , 0x11 }),
504503 fixed (8 )},
505504 LiteralRoundTripParam{
506505 " FixedLength16" ,
507506 {0x00 , 0x01 , 0x02 , 0x03 , 0x04 , 0x05 , 0x06 , 0x07 , 0x08 , 0x09 , 0x0A , 0x0B , 0x0C ,
508507 0x0D , 0x0E , 0x0F },
509508 Literal::Fixed ({0x00 , 0x01 , 0x02 , 0x03 , 0x04 , 0x05 , 0x06 , 0x07 , 0x08 , 0x09 ,
510- 0x0A , 0x0B , 0x0C , 0x0D , 0x0E , 0x0F },
511- 16 ),
509+ 0x0A , 0x0B , 0x0C , 0x0D , 0x0E , 0x0F }),
512510 fixed (16 )},
513511 LiteralRoundTripParam{
514- " FixedSingleByte" , {0xFF }, Literal::Fixed ({0xFF }, 1 ), fixed (1 )},
512+ " FixedSingleByte" , {0xFF }, Literal::Fixed ({0xFF }), fixed (1 )},
515513
516514 // Temporal types
517515 LiteralRoundTripParam{" DateEpoch" , {0 , 0 , 0 , 0 }, Literal::Date (0 ), date ()},
@@ -562,7 +560,19 @@ TEST(LiteralSerializationTest, EmptyString) {
562560 EXPECT_TRUE (empty_bytes->empty ());
563561
564562 auto deserialize_result = Literal::Deserialize (*empty_bytes, string ());
565- EXPECT_THAT (deserialize_result, IsError (ErrorKind::kInvalidArgument ));
563+ ASSERT_THAT (deserialize_result, IsOk ());
564+ EXPECT_TRUE (std::get<std::string>(deserialize_result->value ()).empty ());
565+ }
566+
567+ TEST (LiteralSerializationTest, EmptyBinary) {
568+ auto empty_binary = Literal::Binary ({});
569+ auto empty_bytes = empty_binary.Serialize ();
570+ ASSERT_TRUE (empty_bytes.has_value ());
571+ EXPECT_TRUE (empty_bytes->empty ());
572+
573+ auto deserialize_result = Literal::Deserialize (*empty_bytes, binary ());
574+ ASSERT_THAT (deserialize_result, IsOk ());
575+ EXPECT_TRUE (std::get<std::vector<uint8_t >>(deserialize_result->value ()).empty ());
566576}
567577
568578// Type promotion tests
@@ -574,20 +584,12 @@ TEST(LiteralSerializationTest, TypePromotion) {
574584 EXPECT_EQ (long_result->type ()->type_id (), TypeId::kLong );
575585 EXPECT_EQ (std::get<int64_t >(long_result->value ()), 32L );
576586
577- auto long_bytes = long_result->Serialize ();
578- ASSERT_TRUE (long_bytes.has_value ());
579- EXPECT_EQ (long_bytes->size (), 8 );
580-
581587 // 4-byte float data can be deserialized as double
582588 std::vector<uint8_t > float_data = {0 , 0 , 128 , 63 };
583589 auto double_result = Literal::Deserialize (float_data, float64 ());
584590 ASSERT_TRUE (double_result.has_value ());
585591 EXPECT_EQ (double_result->type ()->type_id (), TypeId::kDouble );
586- EXPECT_EQ (std::get<double >(double_result->value ()), 1.0 );
587-
588- auto double_bytes = double_result->Serialize ();
589- ASSERT_TRUE (double_bytes.has_value ());
590- EXPECT_EQ (double_bytes->size (), 8 );
592+ EXPECT_DOUBLE_EQ (std::get<double >(double_result->value ()), 1.0 );
591593}
592594
593595} // namespace iceberg
0 commit comments