This is an automated email from the ASF dual-hosted git repository.

aherbert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-rng.git

commit a702a1fd40b3b2f8b9ad71758fb5134f6ad4be1f
Author: Alex Herbert <[email protected]>
AuthorDate: Thu Mar 17 21:54:45 2022 +0000

    RNG-169: Move array size conversions to Conversions class
---
 .../rng/simple/internal/ByteArray2IntArray.java    |  2 +-
 .../rng/simple/internal/ByteArray2LongArray.java   |  2 +-
 .../commons/rng/simple/internal/Conversions.java   | 61 ++++++++++++++++++++++
 .../rng/simple/internal/IntArray2LongArray.java    |  2 +-
 .../rng/simple/internal/LongArray2IntArray.java    |  2 +-
 .../rng/simple/internal/NativeSeedType.java        |  8 +--
 .../commons/rng/simple/internal/SeedUtils.java     | 61 ----------------------
 .../simple/internal/ArrayConverterEndianTest.java  |  6 +--
 .../rng/simple/internal/ConversionsTest.java       | 41 ++++++++++++---
 .../rng/simple/internal/NativeSeedTypeTest.java    | 24 ++++-----
 .../commons/rng/simple/internal/SeedUtilsTest.java | 26 ---------
 11 files changed, 117 insertions(+), 118 deletions(-)

diff --git 
a/commons-rng-simple/src/main/java/org/apache/commons/rng/simple/internal/ByteArray2IntArray.java
 
b/commons-rng-simple/src/main/java/org/apache/commons/rng/simple/internal/ByteArray2IntArray.java
index 68f1bdf..7c11a2b 100644
--- 
a/commons-rng-simple/src/main/java/org/apache/commons/rng/simple/internal/ByteArray2IntArray.java
+++ 
b/commons-rng-simple/src/main/java/org/apache/commons/rng/simple/internal/ByteArray2IntArray.java
@@ -26,7 +26,7 @@ public class ByteArray2IntArray implements 
Seed2ArrayConverter<byte[], int[]> {
     @Override
     public int[] convert(byte[] seed) {
         // Full length conversion
-        return Conversions.byteArray2IntArray(seed, 
SeedUtils.intSizeFromByteSize(seed.length));
+        return Conversions.byteArray2IntArray(seed, 
Conversions.intSizeFromByteSize(seed.length));
     }
 
     /**
diff --git 
a/commons-rng-simple/src/main/java/org/apache/commons/rng/simple/internal/ByteArray2LongArray.java
 
b/commons-rng-simple/src/main/java/org/apache/commons/rng/simple/internal/ByteArray2LongArray.java
index 4f2957d..e5a68e1 100644
--- 
a/commons-rng-simple/src/main/java/org/apache/commons/rng/simple/internal/ByteArray2LongArray.java
+++ 
b/commons-rng-simple/src/main/java/org/apache/commons/rng/simple/internal/ByteArray2LongArray.java
@@ -26,7 +26,7 @@ public class ByteArray2LongArray implements 
Seed2ArrayConverter<byte[], long[]>
     @Override
     public long[] convert(byte[] seed) {
         // Full length conversion
-        return Conversions.byteArray2LongArray(seed, 
SeedUtils.longSizeFromByteSize(seed.length));
+        return Conversions.byteArray2LongArray(seed, 
Conversions.longSizeFromByteSize(seed.length));
     }
 
     /**
diff --git 
a/commons-rng-simple/src/main/java/org/apache/commons/rng/simple/internal/Conversions.java
 
b/commons-rng-simple/src/main/java/org/apache/commons/rng/simple/internal/Conversions.java
index 6a82627..4f2ea9d 100644
--- 
a/commons-rng-simple/src/main/java/org/apache/commons/rng/simple/internal/Conversions.java
+++ 
b/commons-rng-simple/src/main/java/org/apache/commons/rng/simple/internal/Conversions.java
@@ -40,6 +40,67 @@ final class Conversions {
     private Conversions() {}
 
     /**
+     * Compute the size of an {@code int} array required to hold the specified 
number of bytes.
+     * Allows space for any remaining bytes that do not fit exactly in a 4 
byte integer.
+     * <pre>
+     * n = ceil(size / 4)
+     * </pre>
+     *
+     * @param size the size in bytes (assumed to be positive)
+     * @return the size in ints
+     */
+    static int intSizeFromByteSize(int size) {
+        return (size + 3) >>> 2;
+    }
+
+    /**
+     * Compute the size of an {@code long} array required to hold the 
specified number of bytes.
+     * Allows space for any remaining bytes that do not fit exactly in an 8 
byte long.
+     * <pre>
+     * n = ceil(size / 8)
+     * </pre>
+     *
+     * @param size the size in bytes (assumed to be positive)
+     * @return the size in longs
+     */
+    static int longSizeFromByteSize(int size) {
+        return (size + 7) >>> 3;
+    }
+
+    /**
+     * Compute the size of an {@code int} array required to hold the specified 
number of longs.
+     * Prevents overflow to a negative number when doubling the size.
+     * <pre>
+     * n = min(size * 2, 2^31 - 1)
+     * </pre>
+     *
+     * @param size the size in longs (assumed to be positive)
+     * @return the size in ints
+     */
+    static int intSizeFromLongSize(int size) {
+        // Avoid overflow when doubling the length.
+        // If n is negative the signed shift creates a mask with all bits set;
+        // otherwise it is zero and n is unchanged after the or operation.
+        // The final mask clears the sign bit in the event n did overflow.
+        final int n = size << 1;
+        return (n | (n >> 31)) & Integer.MAX_VALUE;
+    }
+
+    /**
+     * Compute the size of an {@code long} array required to hold the 
specified number of ints.
+     * Allows space for an odd int.
+     * <pre>
+     * n = ceil(size / 2)
+     * </pre>
+     *
+     * @param size the size in ints (assumed to be positive)
+     * @return the size in longs
+     */
+    static int longSizeFromIntSize(int size) {
+        return (size + 1) >>> 1;
+    }
+
+    /**
      * Perform variant 13 of David Stafford's 64-bit mix function.
      * This is the mix function used in the {@link SplitMix64} RNG.
      *
diff --git 
a/commons-rng-simple/src/main/java/org/apache/commons/rng/simple/internal/IntArray2LongArray.java
 
b/commons-rng-simple/src/main/java/org/apache/commons/rng/simple/internal/IntArray2LongArray.java
index 46fbe6e..237da1a 100644
--- 
a/commons-rng-simple/src/main/java/org/apache/commons/rng/simple/internal/IntArray2LongArray.java
+++ 
b/commons-rng-simple/src/main/java/org/apache/commons/rng/simple/internal/IntArray2LongArray.java
@@ -30,7 +30,7 @@ public class IntArray2LongArray implements 
Seed2ArrayConverter<int[], long[]> {
     @Override
     public long[] convert(int[] seed) {
         // Full length conversion
-        return Conversions.intArray2LongArray(seed, 
SeedUtils.longSizeFromIntSize(seed.length));
+        return Conversions.intArray2LongArray(seed, 
Conversions.longSizeFromIntSize(seed.length));
     }
 
     /**
diff --git 
a/commons-rng-simple/src/main/java/org/apache/commons/rng/simple/internal/LongArray2IntArray.java
 
b/commons-rng-simple/src/main/java/org/apache/commons/rng/simple/internal/LongArray2IntArray.java
index c35e10b..4beab1c 100644
--- 
a/commons-rng-simple/src/main/java/org/apache/commons/rng/simple/internal/LongArray2IntArray.java
+++ 
b/commons-rng-simple/src/main/java/org/apache/commons/rng/simple/internal/LongArray2IntArray.java
@@ -29,7 +29,7 @@ public class LongArray2IntArray implements 
Seed2ArrayConverter<long[], int[]> {
     @Override
     public int[] convert(long[] seed) {
         // Full length conversion
-        return Conversions.longArray2IntArray(seed, 
SeedUtils.intSizeFromLongSize(seed.length));
+        return Conversions.longArray2IntArray(seed, 
Conversions.intSizeFromLongSize(seed.length));
     }
 
     /**
diff --git 
a/commons-rng-simple/src/main/java/org/apache/commons/rng/simple/internal/NativeSeedType.java
 
b/commons-rng-simple/src/main/java/org/apache/commons/rng/simple/internal/NativeSeedType.java
index 494ff1c..8639b4d 100644
--- 
a/commons-rng-simple/src/main/java/org/apache/commons/rng/simple/internal/NativeSeedType.java
+++ 
b/commons-rng-simple/src/main/java/org/apache/commons/rng/simple/internal/NativeSeedType.java
@@ -120,13 +120,13 @@ public enum NativeSeedType {
         protected int[] convert(long[] seed, int size) {
             // Avoid zero filling seeds that are too short
             return Conversions.longArray2IntArray(seed,
-                Math.min(size, SeedUtils.intSizeFromLongSize(seed.length)));
+                Math.min(size, Conversions.intSizeFromLongSize(seed.length)));
         }
         @Override
         protected int[] convert(byte[] seed, int size) {
             // Avoid zero filling seeds that are too short
             return Conversions.byteArray2IntArray(seed,
-                Math.min(size, SeedUtils.intSizeFromByteSize(seed.length)));
+                Math.min(size, Conversions.intSizeFromByteSize(seed.length)));
         }
     },
     /** The seed type is {@code long[]}. */
@@ -149,7 +149,7 @@ public enum NativeSeedType {
         protected long[] convert(int[] seed, int size) {
             // Avoid zero filling seeds that are too short
             return Conversions.intArray2LongArray(seed,
-                Math.min(size, SeedUtils.longSizeFromIntSize(seed.length)));
+                Math.min(size, Conversions.longSizeFromIntSize(seed.length)));
         }
         @Override
         protected long[] convert(long[] seed, int size) {
@@ -159,7 +159,7 @@ public enum NativeSeedType {
         protected long[] convert(byte[] seed, int size) {
             // Avoid zero filling seeds that are too short
             return Conversions.byteArray2LongArray(seed,
-                Math.min(size, SeedUtils.longSizeFromByteSize(seed.length)));
+                Math.min(size, Conversions.longSizeFromByteSize(seed.length)));
         }
     };
 
diff --git 
a/commons-rng-simple/src/main/java/org/apache/commons/rng/simple/internal/SeedUtils.java
 
b/commons-rng-simple/src/main/java/org/apache/commons/rng/simple/internal/SeedUtils.java
index 5612ada..5d6aa14 100644
--- 
a/commons-rng-simple/src/main/java/org/apache/commons/rng/simple/internal/SeedUtils.java
+++ 
b/commons-rng-simple/src/main/java/org/apache/commons/rng/simple/internal/SeedUtils.java
@@ -210,65 +210,4 @@ final class SeedUtils {
         digits[lower] = digits[upper];
         return newbits;
     }
-
-    /**
-     * Compute the size of an {@code int} array required to hold the specified 
number of bytes.
-     * Allows space for any remaining bytes that do not fit exactly in a 4 
byte integer.
-     * <pre>
-     * n = ceil(size / 4)
-     * </pre>
-     *
-     * @param size the size in bytes (assumed to be positive)
-     * @return the size in ints
-     */
-    static int intSizeFromByteSize(int size) {
-        return (size + 3) >>> 2;
-    }
-
-    /**
-     * Compute the size of an {@code long} array required to hold the 
specified number of bytes.
-     * Allows space for any remaining bytes that do not fit exactly in an 8 
byte long.
-     * <pre>
-     * n = ceil(size / 8)
-     * </pre>
-     *
-     * @param size the size in bytes (assumed to be positive)
-     * @return the size in longs
-     */
-    static int longSizeFromByteSize(int size) {
-        return (size + 7) >>> 3;
-    }
-
-    /**
-     * Compute the size of an {@code int} array required to hold the specified 
number of longs.
-     * Prevents overflow to a negative number when doubling the size.
-     * <pre>
-     * n = min(size * 2, 2^31 - 1)
-     * </pre>
-     *
-     * @param size the size in longs (assumed to be positive)
-     * @return the size in ints
-     */
-    static int intSizeFromLongSize(int size) {
-        // Avoid overflow when doubling the length.
-        // If n is negative the signed shift creates a mask with all bits set;
-        // otherwise it is zero and n is unchanged after the or operation.
-        // The final mask clears the sign bit in the event n did overflow.
-        final int n = size << 1;
-        return (n | (n >> 31)) & Integer.MAX_VALUE;
-    }
-
-    /**
-     * Compute the size of an {@code long} array required to hold the 
specified number of ints.
-     * Allows space for an odd int.
-     * <pre>
-     * n = ceil(size / 2)
-     * </pre>
-     *
-     * @param size the size in ints (assumed to be positive)
-     * @return the size in longs
-     */
-    static int longSizeFromIntSize(int size) {
-        return (size + 1) >>> 1;
-    }
 }
diff --git 
a/commons-rng-simple/src/test/java/org/apache/commons/rng/simple/internal/ArrayConverterEndianTest.java
 
b/commons-rng-simple/src/test/java/org/apache/commons/rng/simple/internal/ArrayConverterEndianTest.java
index fe141f6..8c80c56 100644
--- 
a/commons-rng-simple/src/test/java/org/apache/commons/rng/simple/internal/ArrayConverterEndianTest.java
+++ 
b/commons-rng-simple/src/test/java/org/apache/commons/rng/simple/internal/ArrayConverterEndianTest.java
@@ -46,11 +46,11 @@ class ArrayConverterEndianTest {
 
         // Reference implementation using a ByteBuffer
         final ByteBuffer bb = ByteBuffer.wrap(
-            Arrays.copyOf(seedBytes, SeedUtils.longSizeFromByteSize(bytes) * 
Long.BYTES))
+            Arrays.copyOf(seedBytes, Conversions.longSizeFromByteSize(bytes) * 
Long.BYTES))
             .order(ByteOrder.LITTLE_ENDIAN);
 
         // byte[] -> int[]
-        final int[] expectedInt = new 
int[SeedUtils.intSizeFromByteSize(bytes)];
+        final int[] expectedInt = new 
int[Conversions.intSizeFromByteSize(bytes)];
         for (int i = 0; i < expectedInt.length; i++) {
             expectedInt[i] = bb.getInt();
         }
@@ -59,7 +59,7 @@ class ArrayConverterEndianTest {
 
         // byte[] -> long[]
         bb.clear();
-        final long[] expectedLong = new 
long[SeedUtils.longSizeFromByteSize(bytes)];
+        final long[] expectedLong = new 
long[Conversions.longSizeFromByteSize(bytes)];
         for (int i = 0; i < expectedLong.length; i++) {
             expectedLong[i] = bb.getLong();
         }
diff --git 
a/commons-rng-simple/src/test/java/org/apache/commons/rng/simple/internal/ConversionsTest.java
 
b/commons-rng-simple/src/test/java/org/apache/commons/rng/simple/internal/ConversionsTest.java
index b2eef2c..62fcbf6 100644
--- 
a/commons-rng-simple/src/test/java/org/apache/commons/rng/simple/internal/ConversionsTest.java
+++ 
b/commons-rng-simple/src/test/java/org/apache/commons/rng/simple/internal/ConversionsTest.java
@@ -29,6 +29,7 @@ import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.RepeatedTest;
 import org.junit.jupiter.params.ParameterizedTest;
 import org.junit.jupiter.params.provider.MethodSource;
+import org.junit.jupiter.params.provider.ValueSource;
 
 /**
  * Tests for {@link Conversions}.
@@ -61,6 +62,30 @@ class ConversionsTest {
         return IntStream.rangeClosed(0, 2);
     }
 
+    @ParameterizedTest
+    @ValueSource(ints = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, Integer.MAX_VALUE})
+    void testIntSizeFromByteSize(int size) {
+        Assertions.assertEquals((int) Math.ceil((double) size / 
Integer.BYTES), Conversions.intSizeFromByteSize(size));
+    }
+
+    @ParameterizedTest
+    @ValueSource(ints = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 
16, 17, 18, 19, 20, Integer.MAX_VALUE})
+    void testLongSizeFromByteSize(int size) {
+        Assertions.assertEquals((int) Math.ceil((double) size / Long.BYTES), 
Conversions.longSizeFromByteSize(size));
+    }
+
+    @ParameterizedTest
+    @ValueSource(ints = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, Integer.MAX_VALUE})
+    void testIntSizeFromLongSize(int size) {
+        Assertions.assertEquals((int) Math.min(size * 2L, Integer.MAX_VALUE), 
Conversions.intSizeFromLongSize(size));
+    }
+
+    @ParameterizedTest
+    @ValueSource(ints = {0, 1, 2, 3, 4, 5, Integer.MAX_VALUE})
+    void testLongSizeFromIntSize(int size) {
+        Assertions.assertEquals((int) Math.ceil((double) size / 2), 
Conversions.longSizeFromIntSize(size));
+    }
+
     @RepeatedTest(value = 5)
     void testInt2Long() {
         final int v = ThreadLocalRandom.current().nextInt();
@@ -100,7 +125,7 @@ class ConversionsTest {
     void testLong2IntArray() {
         final long v = ThreadLocalRandom.current().nextLong();
         getIntLengths().forEach(len -> {
-            final int longs = SeedUtils.longSizeFromIntSize(len);
+            final int longs = Conversions.longSizeFromIntSize(len);
             // Little-endian conversion
             final ByteBuffer bb = ByteBuffer.allocate(longs * 
Long.BYTES).order(ByteOrder.LITTLE_ENDIAN);
             LongStream.generate(new 
SplitMix64(v)::nextLong).limit(longs).forEach(bb::putLong);
@@ -146,7 +171,7 @@ class ConversionsTest {
 
         // int[] -> long[] -> long
         // Concatenate all ints in little-endian order to bytes
-        final int outLength = SeedUtils.longSizeFromIntSize(ints);
+        final int outLength = Conversions.longSizeFromIntSize(ints);
         final int[] filledSeed = Arrays.copyOf(seed, outLength * 2);
         final ByteBuffer bb = ByteBuffer.allocate(filledSeed.length * 
Integer.BYTES)
                 .order(ByteOrder.LITTLE_ENDIAN);
@@ -176,7 +201,7 @@ class ConversionsTest {
         final int[] seed = ThreadLocalRandom.current().ints(ints).toArray();
 
         // Concatenate all bytes in little-endian order to bytes
-        final int outLength = SeedUtils.longSizeFromIntSize(ints);
+        final int outLength = Conversions.longSizeFromIntSize(ints);
         final ByteBuffer bb = ByteBuffer.allocate(outLength * Long.BYTES)
                 .order(ByteOrder.LITTLE_ENDIAN);
         Arrays.stream(seed).forEach(bb::putInt);
@@ -226,7 +251,7 @@ class ConversionsTest {
         final long[] seed = ThreadLocalRandom.current().longs(longs).toArray();
 
         // Concatenate all bytes in little-endian order to bytes
-        final int outLength = SeedUtils.intSizeFromLongSize(longs);
+        final int outLength = Conversions.intSizeFromLongSize(longs);
         final ByteBuffer bb = ByteBuffer.allocate(longs * Long.BYTES)
                 .order(ByteOrder.LITTLE_ENDIAN);
         Arrays.stream(seed).forEach(bb::putLong);
@@ -254,7 +279,7 @@ class ConversionsTest {
 
         // byte[] -> int[] -> int
         // Concatenate all bytes in little-endian order to bytes
-        final int outLength = SeedUtils.intSizeFromByteSize(bytes);
+        final int outLength = Conversions.intSizeFromByteSize(bytes);
         final byte[] filledSeed = Arrays.copyOf(seed, outLength * 
Integer.BYTES);
         final ByteBuffer bb = ByteBuffer.wrap(filledSeed)
                 .order(ByteOrder.LITTLE_ENDIAN);
@@ -284,7 +309,7 @@ class ConversionsTest {
         ThreadLocalRandom.current().nextBytes(seed);
 
         // Concatenate all bytes in little-endian order to bytes
-        final int outLength = SeedUtils.intSizeFromByteSize(bytes);
+        final int outLength = Conversions.intSizeFromByteSize(bytes);
         final byte[] filledSeed = Arrays.copyOf(seed, outLength * 
Integer.BYTES);
         final ByteBuffer bb = ByteBuffer.wrap(filledSeed)
                 .order(ByteOrder.LITTLE_ENDIAN);
@@ -311,7 +336,7 @@ class ConversionsTest {
 
         // byte[] -> long[] -> long
         // Concatenate all bytes in little-endian order to bytes
-        final int outLength = SeedUtils.longSizeFromByteSize(bytes);
+        final int outLength = Conversions.longSizeFromByteSize(bytes);
         final byte[] filledSeed = Arrays.copyOf(seed, outLength * Long.BYTES);
         final ByteBuffer bb = ByteBuffer.wrap(filledSeed)
                 .order(ByteOrder.LITTLE_ENDIAN);
@@ -341,7 +366,7 @@ class ConversionsTest {
         ThreadLocalRandom.current().nextBytes(seed);
 
         // Concatenate all bytes in little-endian order to bytes
-        final int outLength = SeedUtils.longSizeFromByteSize(bytes);
+        final int outLength = Conversions.longSizeFromByteSize(bytes);
         final byte[] filledSeed = Arrays.copyOf(seed, outLength * Long.BYTES);
         final ByteBuffer bb = ByteBuffer.wrap(filledSeed)
                 .order(ByteOrder.LITTLE_ENDIAN);
diff --git 
a/commons-rng-simple/src/test/java/org/apache/commons/rng/simple/internal/NativeSeedTypeTest.java
 
b/commons-rng-simple/src/test/java/org/apache/commons/rng/simple/internal/NativeSeedTypeTest.java
index 41ae3dc..428e5f3 100644
--- 
a/commons-rng-simple/src/test/java/org/apache/commons/rng/simple/internal/NativeSeedTypeTest.java
+++ 
b/commons-rng-simple/src/test/java/org/apache/commons/rng/simple/internal/NativeSeedTypeTest.java
@@ -187,7 +187,7 @@ class NativeSeedTypeTest {
     void testConvertByteArrayToIntArray(int byteSize, int intSize) {
         final byte[] bytes = new byte[byteSize];
         // Get the maximum number of ints to use all the bytes
-        final int size = SeedUtils.intSizeFromByteSize(byteSize);
+        final int size = Conversions.intSizeFromByteSize(byteSize);
         // If the size is too big, fill the remaining bytes with non-zero 
values.
         // These should not be used during conversion.
         if (size > intSize) {
@@ -216,7 +216,7 @@ class NativeSeedTypeTest {
     void testConvertByteArrayToLongArray(int byteSize, int longSize) {
         final byte[] bytes = new byte[byteSize];
         // Get the maximum number of longs to use all the bytes
-        final long size = SeedUtils.longSizeFromByteSize(byteSize);
+        final long size = Conversions.longSizeFromByteSize(byteSize);
         // If the size is too big, fill the remaining bytes with non-zero 
values.
         // These should not be used during conversion.
         if (size > longSize) {
@@ -245,7 +245,7 @@ class NativeSeedTypeTest {
     void testConvertIntArrayToLongArray(int intSize, int longSize) {
         final int[] ints = new int[intSize];
         // Get the maximum number of longs to use all the ints
-        final long size = SeedUtils.longSizeFromIntSize(intSize);
+        final long size = Conversions.longSizeFromIntSize(intSize);
         // If the size is too big, fill the remaining ints with non-zero 
values.
         // These should not be used during conversion.
         if (size > longSize) {
@@ -278,7 +278,7 @@ class NativeSeedTypeTest {
         // If the size is too big, fill the remaining longs with non-zero 
values.
         // These should not be used during conversion.
         if (size > intSize) {
-            Arrays.fill(longs, SeedUtils.longSizeFromIntSize(intSize), 
longs.length, -1);
+            Arrays.fill(longs, Conversions.longSizeFromIntSize(intSize), 
longs.length, -1);
         }
         final int expected = Math.min(size, intSize);
         final int[] ints = (int[]) NativeSeedType.INT_ARRAY.convert(longs, 
intSize);
@@ -397,8 +397,8 @@ class NativeSeedTypeTest {
         ThreadLocalRandom.current().nextBytes(byteSeed);
 
         // Get the bytes as each array type
-        final int longSize = SeedUtils.longSizeFromByteSize(bytes);
-        final int intSize = SeedUtils.intSizeFromByteSize(bytes);
+        final int longSize = Conversions.longSizeFromByteSize(bytes);
+        final int intSize = Conversions.intSizeFromByteSize(bytes);
         final ByteBuffer bb = ByteBuffer.wrap(
                 Arrays.copyOf(byteSeed, longSize * Long.BYTES))
                 .order(ByteOrder.LITTLE_ENDIAN);
@@ -449,8 +449,8 @@ class NativeSeedTypeTest {
         ThreadLocalRandom.current().nextBytes(byteSeed);
 
         // Get the bytes as each array type
-        final int longSize = SeedUtils.longSizeFromByteSize(bytes);
-        final int intSize = SeedUtils.intSizeFromByteSize(bytes);
+        final int longSize = Conversions.longSizeFromByteSize(bytes);
+        final int intSize = Conversions.intSizeFromByteSize(bytes);
         final ByteBuffer bb = ByteBuffer.wrap(
                 Arrays.copyOf(byteSeed, longSize * Long.BYTES))
                 .order(ByteOrder.LITTLE_ENDIAN);
@@ -502,8 +502,8 @@ class NativeSeedTypeTest {
         ThreadLocalRandom.current().nextBytes(byteSeed);
 
         // Get the bytes as each array type
-        final int longSize = SeedUtils.longSizeFromByteSize(bytes);
-        final int intSize = SeedUtils.intSizeFromByteSize(bytes);
+        final int longSize = Conversions.longSizeFromByteSize(bytes);
+        final int intSize = Conversions.intSizeFromByteSize(bytes);
         final ByteBuffer bb = ByteBuffer.wrap(
                 Arrays.copyOf(byteSeed, longSize * Long.BYTES))
                 .order(ByteOrder.LITTLE_ENDIAN);
@@ -565,8 +565,8 @@ class NativeSeedTypeTest {
         ThreadLocalRandom.current().nextBytes(byteSeed);
 
         // Get the bytes as each array type
-        final int longSize = SeedUtils.longSizeFromByteSize(bytes);
-        final int intSize = SeedUtils.intSizeFromByteSize(bytes);
+        final int longSize = Conversions.longSizeFromByteSize(bytes);
+        final int intSize = Conversions.intSizeFromByteSize(bytes);
         final ByteBuffer bb = ByteBuffer.wrap(
                 Arrays.copyOf(byteSeed, longSize * Long.BYTES))
                 .order(ByteOrder.LITTLE_ENDIAN);
diff --git 
a/commons-rng-simple/src/test/java/org/apache/commons/rng/simple/internal/SeedUtilsTest.java
 
b/commons-rng-simple/src/test/java/org/apache/commons/rng/simple/internal/SeedUtilsTest.java
index 1949c33..a7d2819 100644
--- 
a/commons-rng-simple/src/test/java/org/apache/commons/rng/simple/internal/SeedUtilsTest.java
+++ 
b/commons-rng-simple/src/test/java/org/apache/commons/rng/simple/internal/SeedUtilsTest.java
@@ -22,8 +22,6 @@ import org.apache.commons.rng.UniformRandomProvider;
 import org.apache.commons.rng.core.source64.SplitMix64;
 import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.Test;
-import org.junit.jupiter.params.ParameterizedTest;
-import org.junit.jupiter.params.provider.ValueSource;
 import java.util.Arrays;
 
 /**
@@ -102,28 +100,4 @@ class SeedUtilsTest {
                 "Not uniform in digit " + j);
         }
     }
-
-    @ParameterizedTest
-    @ValueSource(ints = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, Integer.MAX_VALUE})
-    void testIntSizeFromByteSize(int size) {
-        Assertions.assertEquals((int) Math.ceil((double) size / 
Integer.BYTES), SeedUtils.intSizeFromByteSize(size));
-    }
-
-    @ParameterizedTest
-    @ValueSource(ints = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 
16, 17, 18, 19, 20, Integer.MAX_VALUE})
-    void testLongSizeFromByteSize(int size) {
-        Assertions.assertEquals((int) Math.ceil((double) size / Long.BYTES), 
SeedUtils.longSizeFromByteSize(size));
-    }
-
-    @ParameterizedTest
-    @ValueSource(ints = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, Integer.MAX_VALUE})
-    void testIntSizeFromLongSize(int size) {
-        Assertions.assertEquals((int) Math.min(size * 2L, Integer.MAX_VALUE), 
SeedUtils.intSizeFromLongSize(size));
-    }
-
-    @ParameterizedTest
-    @ValueSource(ints = {0, 1, 2, 3, 4, 5, Integer.MAX_VALUE})
-    void testLongSizeFromIntSize(int size) {
-        Assertions.assertEquals((int) Math.ceil((double) size / 2), 
SeedUtils.longSizeFromIntSize(size));
-    }
 }

Reply via email to