mirror of
https://github.com/TheAlgorithms/Java.git
synced 2025-07-25 13:34:54 +08:00
style: include BigIntegerInstantiation
(#5294)
This commit is contained in:
@ -22,7 +22,7 @@ public final class FibonacciJavaStreams {
|
||||
return Optional.of(BigDecimal.ZERO);
|
||||
}
|
||||
|
||||
if (index.compareTo(new BigDecimal(2)) < 0) {
|
||||
if (index.compareTo(BigDecimal.TWO) < 0) {
|
||||
return Optional.of(BigDecimal.ONE);
|
||||
}
|
||||
|
||||
|
@ -21,13 +21,13 @@ public class FibonacciJavaStreamsTest {
|
||||
public void testCheckTheFirst4SequenceElements() {
|
||||
checkElement(BigDecimal.ZERO, BigDecimal.ZERO);
|
||||
checkElement(BigDecimal.ONE, BigDecimal.ONE);
|
||||
checkElement(new BigDecimal(2), BigDecimal.ONE);
|
||||
checkElement(new BigDecimal(3), new BigDecimal(2));
|
||||
checkElement(BigDecimal.TWO, BigDecimal.ONE);
|
||||
checkElement(new BigDecimal(3), BigDecimal.TWO);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCheck10thSequenceElement() {
|
||||
checkElement(new BigDecimal(10), new BigDecimal(55));
|
||||
checkElement(BigDecimal.TEN, new BigDecimal(55));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -11,20 +11,20 @@ class MatrixUtilTest {
|
||||
@Test
|
||||
void add() {
|
||||
final BigDecimal[][] matrix1 = {
|
||||
{new BigDecimal(3), new BigDecimal(2)},
|
||||
{new BigDecimal(3), BigDecimal.TWO},
|
||||
{BigDecimal.ZERO, BigDecimal.ONE},
|
||||
};
|
||||
|
||||
final BigDecimal[][] matrix2 = {
|
||||
{BigDecimal.ONE, new BigDecimal(3)},
|
||||
{new BigDecimal(2), BigDecimal.ZERO},
|
||||
{BigDecimal.TWO, BigDecimal.ZERO},
|
||||
};
|
||||
|
||||
final BigDecimal[][] actual = MatrixUtil.add(matrix1, matrix2).orElseThrow(() -> new AssertionError("Could not compute matrix!"));
|
||||
|
||||
final BigDecimal[][] expected = {
|
||||
{new BigDecimal(4), new BigDecimal(5)},
|
||||
{new BigDecimal(2), BigDecimal.ONE},
|
||||
{BigDecimal.TWO, BigDecimal.ONE},
|
||||
};
|
||||
|
||||
assertTrue(Objects.deepEquals(actual, expected));
|
||||
@ -37,7 +37,7 @@ class MatrixUtilTest {
|
||||
};
|
||||
|
||||
final BigDecimal[][] matrix2 = {
|
||||
{new BigDecimal(2), BigDecimal.ZERO},
|
||||
{BigDecimal.TWO, BigDecimal.ZERO},
|
||||
{new BigDecimal(-2), new BigDecimal(-3)},
|
||||
};
|
||||
|
||||
@ -55,13 +55,13 @@ class MatrixUtilTest {
|
||||
void multiply() {
|
||||
|
||||
final BigDecimal[][] matrix1 = {
|
||||
{BigDecimal.ONE, new BigDecimal(2), new BigDecimal(3)},
|
||||
{BigDecimal.ONE, BigDecimal.TWO, new BigDecimal(3)},
|
||||
{new BigDecimal(4), new BigDecimal(5), new BigDecimal(6)},
|
||||
{new BigDecimal(7), new BigDecimal(8), new BigDecimal(9)},
|
||||
};
|
||||
|
||||
final BigDecimal[][] matrix2 = {
|
||||
{BigDecimal.ONE, new BigDecimal(2)},
|
||||
{BigDecimal.ONE, BigDecimal.TWO},
|
||||
{new BigDecimal(3), new BigDecimal(4)},
|
||||
{new BigDecimal(5), new BigDecimal(6)},
|
||||
};
|
||||
|
Reference in New Issue
Block a user