This is an automated email from the ASF dual-hosted git repository.
jinsongzhou pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/amoro.git
The following commit(s) were added to refs/heads/master by this push:
new 0cc8160ad [Improvement]: Refactored test testToHumanReadableString of
MemorySizeTest to paramerterized (#3454)
0cc8160ad is described below
commit 0cc8160add5709db429c08469c2b360739f8adb5
Author: Monil <[email protected]>
AuthorDate: Wed Mar 5 04:15:54 2025 -0800
[Improvement]: Refactored test testToHumanReadableString of MemorySizeTest
to paramerterized (#3454)
* refactored test testToHumanReadableString to paramerterized
* fixed checkstyle
---
.../org/apache/amoro/utils/MemorySizeTest.java | 34 ++++++++++++----------
1 file changed, 18 insertions(+), 16 deletions(-)
diff --git
a/amoro-common/src/test/java/org/apache/amoro/utils/MemorySizeTest.java
b/amoro-common/src/test/java/org/apache/amoro/utils/MemorySizeTest.java
index 276cf94d6..d3b9bef65 100644
--- a/amoro-common/src/test/java/org/apache/amoro/utils/MemorySizeTest.java
+++ b/amoro-common/src/test/java/org/apache/amoro/utils/MemorySizeTest.java
@@ -27,6 +27,7 @@ import static org.junit.Assert.fail;
import org.junit.Test;
import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
import java.util.stream.Stream;
@@ -223,21 +224,22 @@ public class MemorySizeTest {
memory.divide(-23L);
}
- @Test
- public void testToHumanReadableString() {
- assertThat(new MemorySize(0L).toHumanReadableString(), is("0 bytes"));
- assertThat(new MemorySize(1L).toHumanReadableString(), is("1 bytes"));
- assertThat(new MemorySize(1024L).toHumanReadableString(), is("1024
bytes"));
- assertThat(new MemorySize(1025L).toHumanReadableString(), is("1.001kb
(1025 bytes)"));
- assertThat(new MemorySize(1536L).toHumanReadableString(), is("1.500kb
(1536 bytes)"));
- assertThat(new MemorySize(1_000_000L).toHumanReadableString(),
is("976.563kb (1000000 bytes)"));
- assertThat(
- new MemorySize(1_000_000_000L).toHumanReadableString(), is("953.674mb
(1000000000 bytes)"));
- assertThat(
- new MemorySize(1_000_000_000_000L).toHumanReadableString(),
- is("931.323gb (1000000000000 bytes)"));
- assertThat(
- new MemorySize(1_000_000_000_000_000L).toHumanReadableString(),
- is("909.495tb (1000000000000000 bytes)"));
+ static Stream<Arguments> testToHumanReadableStringProvider() {
+ return Stream.of(
+ Arguments.of(0L, "0 bytes"),
+ Arguments.of(1L, "1 bytes"),
+ Arguments.of(1024L, "1024 bytes"),
+ Arguments.of(1025L, "1.001kb (1025 bytes)"),
+ Arguments.of(1536L, "1.500kb (1536 bytes)"),
+ Arguments.of(1_000_000L, "976.563kb (1000000 bytes)"),
+ Arguments.of(1_000_000_000L, "953.674mb (1000000000 bytes)"),
+ Arguments.of(1_000_000_000_000L, "931.323gb (1000000000000 bytes)"),
+ Arguments.of(1_000_000_000_000_000L, "909.495tb (1000000000000000
bytes)"));
+ }
+
+ @ParameterizedTest
+ @MethodSource("testToHumanReadableStringProvider")
+ public void testToHumanReadableString(long bytes, String expected) {
+ assertThat(new MemorySize(bytes).toHumanReadableString(), is(expected));
}
}