HeartLinked commented on code in PR #206:
URL: https://github.com/apache/iceberg-cpp/pull/206#discussion_r2342823502


##########
test/literal_test.cc:
##########
@@ -254,6 +431,214 @@ TEST(LiteralTest, BinaryComparison) {
   EXPECT_EQ(binary2 <=> binary1, std::partial_ordering::greater);
 }
 
+// Fixed type tests
+TEST(LiteralTest, FixedBasics) {
+  std::vector<uint8_t> data = {0x01, 0x02, 0x03, 0xFF};
+  auto fixed_literal = Literal::Fixed(data);
+  auto empty_fixed = Literal::Fixed({});
+
+  EXPECT_EQ(fixed_literal.type()->type_id(), TypeId::kFixed);
+  EXPECT_EQ(empty_fixed.type()->type_id(), TypeId::kFixed);
+
+  EXPECT_EQ(fixed_literal.ToString(), "X'010203FF'");
+  EXPECT_EQ(empty_fixed.ToString(), "X''");
+}
+
+TEST(LiteralTest, FixedComparison) {
+  std::vector<uint8_t> data1 = {0x01, 0x02};
+  std::vector<uint8_t> data2 = {0x01, 0x03};
+  std::vector<uint8_t> data3 = {0x01, 0x02};
+
+  auto fixed1 = Literal::Fixed(data1);
+  auto fixed2 = Literal::Fixed(data2);
+  auto fixed3 = Literal::Fixed(data3);
+
+  EXPECT_EQ(fixed1 <=> fixed3, std::partial_ordering::equivalent);
+  EXPECT_EQ(fixed1 <=> fixed2, std::partial_ordering::less);
+  EXPECT_EQ(fixed2 <=> fixed1, std::partial_ordering::greater);
+}
+
+// Date type tests
+TEST(LiteralTest, DateBasics) {
+  auto date_literal = Literal::Date(19489);  // May 15, 2023
+  auto negative_date = Literal::Date(-1);    // December 31, 1969
+
+  EXPECT_EQ(date_literal.type()->type_id(), TypeId::kDate);
+  EXPECT_EQ(negative_date.type()->type_id(), TypeId::kDate);
+
+  EXPECT_EQ(date_literal.ToString(), "19489");

Review Comment:
   I've verified the Java reference implementation, and its 
DateLiteral(19489).toString() also returns the string "19489". So my current 
implementation is consistent with the reference behavior.
   ```
   // In org.apache.iceberg.expressions.Literal
   @Override
   public String toString() {
     return String.valueOf(value);
   }
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org
For additional commands, e-mail: issues-h...@iceberg.apache.org

Reply via email to