nastra commented on code in PR #19279:
URL: https://github.com/apache/iceberg/pull/19279#discussion_r4797391601
##########
core/src/test/java/org/apache/iceberg/TestSingleValueParser.java:
##########
@@ -113,6 +113,60 @@ public void testValidDefaults() throws IOException {
}
}
+ @Test
+ public void testFloatAndDoubleValues() {
+ Type floatType = Types.FloatType.get();
+ assertThat(SingleValueParser.fromJson(floatType, "0")).isEqualTo(0.0f);
+ assertThat(SingleValueParser.fromJson(floatType, "-1")).isEqualTo(-1.0f);
+ assertThat(SingleValueParser.fromJson(floatType,
"2147483648")).isEqualTo(2147483648.0f);
+ assertThat(SingleValueParser.fromJson(floatType, "9223372036854775808"))
+ .isEqualTo(9223372036854775808.0f);
+ assertThat(SingleValueParser.fromJson(floatType,
"16777217")).isEqualTo(16777216.0f);
+ assertThat(SingleValueParser.fromJson(floatType,
"3.4028235e38")).isEqualTo(Float.MAX_VALUE);
+
+ Type doubleType = Types.DoubleType.get();
+ assertThat(SingleValueParser.fromJson(doubleType, "0")).isEqualTo(0.0d);
+ assertThat(SingleValueParser.fromJson(doubleType, "-1")).isEqualTo(-1.0d);
+ assertThat(SingleValueParser.fromJson(doubleType,
"2147483648")).isEqualTo(2147483648.0d);
+ assertThat(SingleValueParser.fromJson(doubleType, "9223372036854775808"))
+ .isEqualTo(9223372036854775808.0d);
+ assertThat(SingleValueParser.fromJson(doubleType, "9007199254740993"))
+ .isEqualTo(9007199254740992.0d);
+ assertThat(SingleValueParser.fromJson(doubleType, "1" +
"0".repeat(39))).isEqualTo(1.0e39d);
+
+ assertThat(SingleValueParser.toJson(floatType,
SingleValueParser.fromJson(floatType, "1")))
Review Comment:
if you want to test the full roundtrip, then this should go into its own
test method and also cover edge cases
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]