Skip to content

Commit

Permalink
test: move BigDecimal.TEN.pow(131072) to a separate test to avoid tes…
Browse files Browse the repository at this point in the history
…t with too long name
  • Loading branch information
vlsi committed Jan 15, 2023
1 parent 59cbcb3 commit 5488595
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* Copyright (c) 2023, PostgreSQL Global Development Group
* See the LICENSE file in the project root for more information.
*/

package org.postgresql.util;

import org.junit.Test;

import java.math.BigDecimal;
import java.math.BigInteger;

/**
* This test is moved from {@link BigDecimalByteConverterTest} to prevent test with very long name.
*/
public class BigDecimalByteConverter2Test {
@Test
public void testBigDecimal10_pow_131072_minus_1() {
BigDecimalByteConverterTest.testBinary(
new BigDecimal(BigInteger.TEN.pow(131072).subtract(BigInteger.ONE))
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,15 @@ public static Iterable<Object[]> data() {
numbers.add(new Object[] {new BigDecimal("1000000").setScale(31)});
numbers.add(new Object[] {new BigDecimal("10000000000000000000000000000000000000").setScale(14)});
numbers.add(new Object[] {new BigDecimal("90000000000000000000000000000000000000")});
numbers.add(new Object[] {new BigDecimal(BigInteger.TEN.pow(131072).subtract(BigInteger.ONE))});
return numbers;
}

@Test
public void testBinary() {
testBinary(number);
}

static void testBinary(BigDecimal number) {
final byte[] bytes = ByteConverter.numeric(number);
final BigDecimal actual = (BigDecimal) ByteConverter.numeric(bytes);
if (number.scale() >= 0) {
Expand Down

0 comments on commit 5488595

Please sign in to comment.