// Path: src/main/java/javafixes/collection/CollectionUtil.java
// @SafeVarargs
// public static <T> ArrayList<T> newList(T... values) {
//     ArrayList<T> list = new ArrayList<T>(values.length);
//     Collections.addAll(list, values);
//     return list;
// }
// 
// Path: src/test/java/javafixes/test/Condition.java
// @FunctionalInterface
// public interface Condition<T> extends Function<T, Boolean> {
// 
//     BigInteger MIN_LONG_AS_BIG_INTEGER = BigInteger.valueOf(Long.MIN_VALUE);
//     BigInteger MAX_LONG_AS_BIG_INTEGER = BigInteger.valueOf(Long.MAX_VALUE);
// 
//     @SafeVarargs
//     static <T> Condition<T> otherThan(T... values) {
//         Set<T> exclusions = newSet(values);
//         return value -> !exclusions.contains(value);
//     }
// 
//     static <T extends Number> Condition<T> notDivisibleBy10() {
//         return value -> mod(value, 10) != 0;
//     }
// 
//     static <T extends Number> Condition<T> notZero() {
//         return value -> signum(value) != 0;
//     }
// 
//     static <T extends Number> Condition<T> positive() {
//         return value -> signum(value) == 1;
//     }
// 
//     static <T extends Number> Condition<T> negative() {
//         return value -> signum(value) == -1;
//     }
// 
//     static Condition<BigInteger> fitsIntoLong() {
//         return value -> value.compareTo(MIN_LONG_AS_BIG_INTEGER) >= 0 && value.compareTo(MAX_LONG_AS_BIG_INTEGER) <= 0;
//     }
// 
//     static Condition<BigInteger> notFitIntoLong() {
//         return value -> value.compareTo(MIN_LONG_AS_BIG_INTEGER) < 0 || value.compareTo(MIN_LONG_AS_BIG_INTEGER) > 0;
//     }
// 
//     static int signum(Number value) {
//         if (value instanceof Integer) {
//             return Integer.signum((Integer) value);
//         } else if (value instanceof Long) {
//             return Long.signum((Long) value);
//         } else if (value instanceof BigInteger) {
//             return ((BigInteger) value).signum();
//         } else if (value instanceof BigDecimal) {
//             return ((BigDecimal) value).signum();
//         } else {
//             throw new IllegalArgumentException("Unsupported number type: " + value.getClass());
//         }
//     }
// 
//     static int mod(Number value, int divisor) {
//         if (value instanceof Integer) {
//             return ((Integer) value) % divisor;
//         } else if (value instanceof Long) {
//             return (int) (((Long) value) % divisor);
//         } else if (value instanceof BigInteger) {
//             return ((BigInteger) value).mod(BigInteger.valueOf(divisor)).intValue();
//         } else {
//             throw new IllegalArgumentException("Unsupported number type: " + value.getClass());
//         }
// 
//     }
// }
// 
// Path: src/test/java/javafixes/test/Random.java
// public static BigInteger randomBigInteger() {
//     boolean positive = randomBoolean();
//     return (positive ? BIG_PLUS_INTEGER : BIG_MINUS_INTEGER)
//             .multiply(BigInteger.valueOf(randomLong(0, 100)))
//             .add(BigInteger.valueOf(positive ? randomLong(0, Long.MAX_VALUE) : randomLong(Long.MIN_VALUE + 1, 0)));
// }
// 
// Path: src/test/java/javafixes/test/Random.java
//     @SafeVarargs
//     public static long randomLong(long from, long to, Function<Long, Boolean>... validityConditions) {
//         return generateValidValue(
// //                () -> new RandomDataGenerator().nextLong(from, to),
//                 () -> ThreadLocalRandom.current().nextLong(from, to) + (long) randomInt(0, 1),
//                 validityConditions
//         );
//     }


import org.junit.Test;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.List;
import static javafixes.collection.CollectionUtil.newList;
import static javafixes.test.Condition.*;
import static javafixes.test.Random.randomBigInteger;
import static javafixes.test.Random.randomLong;
import static org.hamcrest.Matchers.equalTo;
import static org.junit.Assert.assertThat;
package javafixes.math;




public class DecimalNumberConversionTest {

    @Test
    public void shouldTransformDecimalIntoPrimitiveType() {
        List<BigInteger> unscaledValues = newList(
                bi(0L),
                bi(-1L),
                bi(1L),
                bi(Long.MIN_VALUE),
                bi(Long.MAX_VALUE),
                bi(randomLong(Long.MIN_VALUE + 1, -2L, notDivisibleBy10())),
                bi(randomLong(2L, Long.MAX_VALUE -1L, notDivisibleBy10())),
                randomBigInteger(positive(), notFitIntoLong(), notDivisibleBy10()),
                randomBigInteger(negative(), notFitIntoLong(), notDivisibleBy10())
        );

        for (BigInteger unscaledValue : unscaledValues) {
            assertThat(Decimal.decimal(unscaledValue, 0).intValue(), equalTo(unscaledValue.intValue()));
            assertThat(Decimal.decimal(unscaledValue, 0).longValue(), equalTo(unscaledValue.longValue()));
            assertThat(Decimal.decimal(unscaledValue, 0).floatValue(), equalTo(new BigDecimal(unscaledValue, 0).floatValue()));
// Path: src/main/java/javafixes/collection/CollectionUtil.java
// @SafeVarargs
// public static <T> ArrayList<T> newList(T... values) {
//     ArrayList<T> list = new ArrayList<T>(values.length);
//     Collections.addAll(list, values);
//     return list;
// }
// 
// Path: src/test/java/javafixes/test/Condition.java
// @FunctionalInterface
// public interface Condition<T> extends Function<T, Boolean> {
// 
//     BigInteger MIN_LONG_AS_BIG_INTEGER = BigInteger.valueOf(Long.MIN_VALUE);
//     BigInteger MAX_LONG_AS_BIG_INTEGER = BigInteger.valueOf(Long.MAX_VALUE);
// 
//     @SafeVarargs
//     static <T> Condition<T> otherThan(T... values) {
//         Set<T> exclusions = newSet(values);
//         return value -> !exclusions.contains(value);
//     }
// 
//     static <T extends Number> Condition<T> notDivisibleBy10() {
//         return value -> mod(value, 10) != 0;
//     }
// 
//     static <T extends Number> Condition<T> notZero() {
//         return value -> signum(value) != 0;
//     }
// 
//     static <T extends Number> Condition<T> positive() {
//         return value -> signum(value) == 1;
//     }
// 
//     static <T extends Number> Condition<T> negative() {
//         return value -> signum(value) == -1;
//     }
// 
//     static Condition<BigInteger> fitsIntoLong() {
//         return value -> value.compareTo(MIN_LONG_AS_BIG_INTEGER) >= 0 && value.compareTo(MAX_LONG_AS_BIG_INTEGER) <= 0;
//     }
// 
//     static Condition<BigInteger> notFitIntoLong() {
//         return value -> value.compareTo(MIN_LONG_AS_BIG_INTEGER) < 0 || value.compareTo(MIN_LONG_AS_BIG_INTEGER) > 0;
//     }
// 
//     static int signum(Number value) {
//         if (value instanceof Integer) {
//             return Integer.signum((Integer) value);
//         } else if (value instanceof Long) {
//             return Long.signum((Long) value);
//         } else if (value instanceof BigInteger) {
//             return ((BigInteger) value).signum();
//         } else if (value instanceof BigDecimal) {
//             return ((BigDecimal) value).signum();
//         } else {
//             throw new IllegalArgumentException("Unsupported number type: " + value.getClass());
//         }
//     }
// 
//     static int mod(Number value, int divisor) {
//         if (value instanceof Integer) {
//             return ((Integer) value) % divisor;
//         } else if (value instanceof Long) {
//             return (int) (((Long) value) % divisor);
//         } else if (value instanceof BigInteger) {
//             return ((BigInteger) value).mod(BigInteger.valueOf(divisor)).intValue();
//         } else {
//             throw new IllegalArgumentException("Unsupported number type: " + value.getClass());
//         }
// 
//     }
// }
// 
// Path: src/test/java/javafixes/test/Random.java
// public static BigInteger randomBigInteger() {
//     boolean positive = randomBoolean();
//     return (positive ? BIG_PLUS_INTEGER : BIG_MINUS_INTEGER)
//             .multiply(BigInteger.valueOf(randomLong(0, 100)))
//             .add(BigInteger.valueOf(positive ? randomLong(0, Long.MAX_VALUE) : randomLong(Long.MIN_VALUE + 1, 0)));
// }
// 
// Path: src/test/java/javafixes/test/Random.java
//     @SafeVarargs
//     public static long randomLong(long from, long to, Function<Long, Boolean>... validityConditions) {
//         return generateValidValue(
// //                () -> new RandomDataGenerator().nextLong(from, to),
//                 () -> ThreadLocalRandom.current().nextLong(from, to) + (long) randomInt(0, 1),
//                 validityConditions
//         );
//     }


// Path: src/test/java/javafixes/math/DecimalNumberConversionTest.java
import org.junit.Test;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.List;
import static javafixes.collection.CollectionUtil.newList;
import static javafixes.test.Condition.*;
import static javafixes.test.Random.randomBigInteger;
import static javafixes.test.Random.randomLong;
import static org.hamcrest.Matchers.equalTo;
import static org.junit.Assert.assertThat;

package javafixes.math;




public class DecimalNumberConversionTest {

    @Test
    public void shouldTransformDecimalIntoPrimitiveType() {
        List<BigInteger> unscaledValues = newList(
                bi(0L),
                bi(-1L),
                bi(1L),
                bi(Long.MIN_VALUE),
                bi(Long.MAX_VALUE),
                bi(randomLong(Long.MIN_VALUE + 1, -2L, notDivisibleBy10())),
                bi(randomLong(2L, Long.MAX_VALUE -1L, notDivisibleBy10())),
                randomBigInteger(positive(), notFitIntoLong(), notDivisibleBy10()),
                randomBigInteger(negative(), notFitIntoLong(), notDivisibleBy10())
        );

        for (BigInteger unscaledValue : unscaledValues) {
            assertThat(Decimal.decimal(unscaledValue, 0).intValue(), equalTo(unscaledValue.intValue()));
            assertThat(Decimal.decimal(unscaledValue, 0).longValue(), equalTo(unscaledValue.longValue()));
            assertThat(Decimal.decimal(unscaledValue, 0).floatValue(), equalTo(new BigDecimal(unscaledValue, 0).floatValue()));
            assertThat(Decimal.decimal(unscaledValue, 0).doubleValue(), equalTo(new BigDecimal(unscaledValue, 0).doubleValue()));