From b8502a7a6e1c1ae8774c34427bdab4fbe9e7dc0b Mon Sep 17 00:00:00 2001 From: Abdelhak Zaaim Date: Mon, 4 Nov 2024 13:16:44 +0100 Subject: [PATCH] Expand XxHash64Test to cover additional test cases --- .../apache/webbeans/hash/XxHash64Test.java | 29 +++++++++++++++++-- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/webbeans-impl/src/test/java/org/apache/webbeans/hash/XxHash64Test.java b/webbeans-impl/src/test/java/org/apache/webbeans/hash/XxHash64Test.java index 53e490a7c..507ea9952 100644 --- a/webbeans-impl/src/test/java/org/apache/webbeans/hash/XxHash64Test.java +++ b/webbeans-impl/src/test/java/org/apache/webbeans/hash/XxHash64Test.java @@ -18,15 +18,38 @@ */ package org.apache.webbeans.hash; +import static org.junit.Assert.assertEquals; + import org.junit.Test; -import static org.junit.Assert.assertEquals; +import java.nio.ByteBuffer; +import java.nio.charset.StandardCharsets; public class XxHash64Test { @Test - public void sanityCheck() + public void testApplyWithString() { assertEquals(3728699739546630719L, XxHash64.apply("foo")); } -} + + @Test + public void testApplyWithByteBuffer() + { + ByteBuffer buffer = ByteBuffer.wrap("foo".getBytes(StandardCharsets.UTF_8)); + assertEquals(3728699739546630719L, XxHash64.apply(buffer)); + } + + @Test + public void testApplyWithEmptyString() + { + assertEquals(-1205034819632174695L, XxHash64.apply("")); + } + + @Test + public void testApplyWithEmptyByteBuffer() + { + ByteBuffer buffer = ByteBuffer.wrap(new byte[0]); + assertEquals(-1205034819632174695L, XxHash64.apply(buffer)); + } +} \ No newline at end of file