rakesh-das08 commented on code in PR #7757:
URL: https://github.com/apache/iceberg/pull/7757#discussion_r1215518735
##########
api/src/test/java/org/apache/iceberg/transforms/TestBucketing.java:
##########
@@ -54,80 +55,88 @@ public static void getUUIDConstructor() {
private Random testRandom = null;
- @Before
+ @BeforeEach
public void initRandom() {
// reinitialize random for each test to avoid dependence on run order
this.testRandom = new Random(314358);
}
@Test
public void testSpecValues() {
- Assert.assertEquals("Spec example: hash(true) = 1392991556", 1392991556,
BucketUtil.hash(1));
- Assert.assertEquals("Spec example: hash(34) = 2017239379", 2017239379,
BucketUtil.hash(34));
- Assert.assertEquals("Spec example: hash(34L) = 2017239379", 2017239379,
BucketUtil.hash(34L));
-
- Assert.assertEquals(
- "Spec example: hash(17.11F) = -142385009", -142385009,
BucketUtil.hash(1.0F));
- Assert.assertEquals(
- "Spec example: hash(17.11D) = -142385009", -142385009,
BucketUtil.hash(1.0D));
- Assert.assertEquals("Spec example: hash(0.0F) = 1669671676", 1669671676,
BucketUtil.hash(0.0F));
- Assert.assertEquals(
- "Spec example: hash(-0.0F) = 1669671676", 1669671676,
BucketUtil.hash(-0.0F));
- Assert.assertEquals("Spec example: hash(0.0) = 1669671676", 1669671676,
BucketUtil.hash(0.0));
- Assert.assertEquals("Spec example: hash(-0.0) = 1669671676", 1669671676,
BucketUtil.hash(-0.0));
-
- Assert.assertEquals(
- "Spec example: hash(decimal2(14.20)) = -500754589",
- -500754589,
- BucketUtil.hash(new BigDecimal("14.20")));
- Assert.assertEquals(
- "Spec example: hash(decimal2(14.20)) = -500754589",
- -500754589,
- BucketUtil.hash(new BigDecimal("14.20")));
+ assertThat(BucketUtil.hash(1))
+ .as("Spec example: hash(true) = 1392991556")
+ .isEqualTo(1392991556);
+ assertThat(BucketUtil.hash(34)).as("Spec example: hash(34) =
2017239379").isEqualTo(2017239379);
+ assertThat(BucketUtil.hash(34L))
+ .as("Spec example: hash(34L) = 2017239379")
+ .isEqualTo(2017239379);
+
+ assertThat(BucketUtil.hash(1.0F))
+ .as("Spec example: hash(17.11F) = -142385009")
+ .isEqualTo(-142385009);
+ assertThat(BucketUtil.hash(1.0D))
+ .as("Spec example: hash(17.11D) = -142385009")
+ .isEqualTo(-142385009);
+ assertThat(BucketUtil.hash(0.0F))
+ .as("Spec example: hash(0.0F) = 1669671676")
+ .isEqualTo(1669671676);
+ assertThat(BucketUtil.hash(-0.0F))
+ .as("Spec example: hash(-0.0F) = 1669671676")
+ .isEqualTo(1669671676);
+ assertThat(BucketUtil.hash(0.0))
+ .as("Spec example: hash(0.0) = 1669671676")
+ .isEqualTo(1669671676);
+ assertThat(BucketUtil.hash(-0.0))
+ .as("Spec example: hash(-0.0) = 1669671676")
+ .isEqualTo(1669671676);
+
+ assertThat(BucketUtil.hash(new BigDecimal("14.20")))
+ .as("Spec example: hash(decimal2(14.20)) = -500754589")
+ .isEqualTo(-500754589)
+ .as("Spec example: hash(decimal2(14.20)) = -500754589")
+ .isEqualTo(-500754589);
Literal<Integer> date = Literal.of("2017-11-16").to(Types.DateType.get());
- Assert.assertEquals(
- "Spec example: hash(2017-11-16) = -653330422", -653330422,
BucketUtil.hash(date.value()));
+ assertThat(BucketUtil.hash(date.value()))
+ .as("Spec example: hash(2017-11-16) = -653330422")
+ .isEqualTo(-653330422);
Literal<Long> timeValue = Literal.of("22:31:08").to(Types.TimeType.get());
- Assert.assertEquals(
- "Spec example: hash(22:31:08) = -662762989",
- -662762989,
- BucketUtil.hash(timeValue.value()));
+ assertThat(BucketUtil.hash(timeValue.value()))
+ .as("Spec example: hash(22:31:08) = -662762989")
+ .isEqualTo(-662762989);
Literal<Long> timestampVal =
Literal.of("2017-11-16T22:31:08").to(Types.TimestampType.withoutZone());
- Assert.assertEquals(
- "Spec example: hash(2017-11-16T22:31:08) = -2047944441",
- -2047944441,
- BucketUtil.hash(timestampVal.value()));
+ assertThat(BucketUtil.hash(timestampVal.value()))
+ .as("Spec example: hash(2017-11-16T22:31:08) = -2047944441")
+ .isEqualTo(-2047944441);
Literal<Long> timestamptzVal =
Literal.of("2017-11-16T14:31:08-08:00").to(Types.TimestampType.withZone());
- Assert.assertEquals(
- "Spec example: hash(2017-11-16T14:31:08-08:00) = -2047944441",
- -2047944441,
- BucketUtil.hash(timestamptzVal.value()));
-
- Assert.assertEquals(
- "Spec example: hash(\"iceberg\") = 1210000089", 1210000089,
BucketUtil.hash("iceberg"));
- Assert.assertEquals(
- "Spec example: hash(\"iceberg\") = 1210000089",
- 1210000089,
- BucketUtil.hash(new Utf8("iceberg")));
+ assertThat(BucketUtil.hash(timestamptzVal.value()))
+ .as("Spec example: hash(2017-11-16T14:31:08-08:00) = -2047944441")
+ .isEqualTo(-2047944441);
+
+ assertThat(BucketUtil.hash("iceberg"))
+ .as("Spec example: hash(\"iceberg\") = 1210000089")
+ .isEqualTo(1210000089);
+ assertThat(BucketUtil.hash(new Utf8("iceberg")))
+ .as("Spec example: hash(\"iceberg\") = 1210000089")
+ .isEqualTo(1210000089);
Literal<UUID> uuid =
Literal.of("f79c3e09-677c-4bbd-a479-3f349cb785e7").to(Types.UUIDType.get());
- Assert.assertEquals(
- "Spec example: hash(f79c3e09-677c-4bbd-a479-3f349cb785e7) =
1488055340",
- 1488055340,
- BucketUtil.hash(uuid.value()));
+ assertThat(BucketUtil.hash(uuid.value()))
+ .as("Spec example: hash(f79c3e09-677c-4bbd-a479-3f349cb785e7) =
1488055340")
+ .isEqualTo(1488055340);
ByteBuffer bytes = ByteBuffer.wrap(new byte[] {0, 1, 2, 3});
- Assert.assertEquals(
- "Spec example: hash([00 01 02 03]) = -188683207", -188683207,
BucketUtil.hash(bytes));
- Assert.assertEquals(
- "Spec example: hash([00 01 02 03]) = -188683207", -188683207,
BucketUtil.hash(bytes));
+ assertThat(BucketUtil.hash(bytes))
+ .as("Spec example: hash([00 01 02 03]) = -188683207")
+ .isEqualTo(-188683207)
+ .as("Spec example: hash([00 01 02 03]) = -188683207")
Review Comment:
Would add a comment explaining the need for 2 separate assertions.
--
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]