// Path: src/test/java/com/github/jinahya/bit/io/BitIoTests.java
// static int randomSizeForByte(final boolean unsigned) {
//     return requireValidSizeByte(unsigned, current().nextInt(1, Byte.SIZE + (unsigned ? 0 : 1)));
// }
// 
// Path: src/test/java/com/github/jinahya/bit/io/BitIoTests.java
// static int randomSizeForChar() {
//     return requireValidSizeChar(current().nextInt(1, Character.SIZE));
// }
// 
// Path: src/test/java/com/github/jinahya/bit/io/BitIoTests.java
// static int randomSizeForInt(final boolean unsigned) {
//     return requireValidSizeInt(unsigned, current().nextInt(1, Integer.SIZE + (unsigned ? 0 : 1)));
// }
// 
// Path: src/test/java/com/github/jinahya/bit/io/BitIoTests.java
// static int randomSizeForLong(final boolean unsigned) {
//     return requireValidSizeLong(unsigned, current().nextInt(1, Long.SIZE + (unsigned ? 0 : 1)));
// }
// 
// Path: src/test/java/com/github/jinahya/bit/io/BitIoTests.java
// static int randomSizeForShort(final boolean unsigned) {
//     return requireValidSizeShort(unsigned, current().nextInt(1, Short.SIZE + (unsigned ? 0 : 1)));
// }
// 
// Path: src/test/java/com/github/jinahya/bit/io/BitIoTests.java
// static byte randomValueForByte(final boolean unsigned, final int size) {
//     final byte value;
//     if (unsigned) {
//         value = (byte) (current().nextInt() >>> (Integer.SIZE - size));
//         assertTrue(value >= 0);
//     } else {
//         value = (byte) (current().nextInt() >> (Integer.SIZE - size));
//         assertEquals(value >> size, value >= 0 ? 0 : -1);
//     }
//     return value;
// }
// 
// Path: src/test/java/com/github/jinahya/bit/io/BitIoTests.java
// static char randomValueForChar(final int size) {
//     return (char) (current().nextInt(Character.MAX_VALUE + 1) >> (Integer.SIZE - size));
// }
// 
// Path: src/test/java/com/github/jinahya/bit/io/BitIoTests.java
// static int randomValueForInt(final boolean unsigned, final int size) {
//     final int value;
//     if (unsigned) {
//         value = current().nextInt() >>> (Integer.SIZE - size);
//         assertTrue(value >= 0);
//     } else {
//         value = current().nextInt() >> (Integer.SIZE - size);
//         if (size < Integer.SIZE) {
//             assertEquals(value >> size, value >= 0 ? 0 : -1);
//         }
//     }
//     return value;
// }
// 
// Path: src/test/java/com/github/jinahya/bit/io/BitIoTests.java
// static long randomValueForLong(final boolean unsigned, final int size) {
//     final long value;
//     if (unsigned) {
//         value = current().nextLong() >>> (Long.SIZE - size);
//         assertTrue(value >= 0);
//     } else {
//         value = current().nextLong() >> (Long.SIZE - size);
//         if (size < Long.SIZE) {
//             assertEquals(value >> size, value >= 0L ? 0L : -1L);
//         }
//     }
//     return value;
// }
// 
// Path: src/test/java/com/github/jinahya/bit/io/BitIoTests.java
// static short randomValueForShort(final boolean unsigned, final int size) {
//     final short value;
//     if (unsigned) {
//         value = (short) (current().nextInt() >>> (Integer.SIZE - size));
//         assertTrue(value >= 0);
//     } else {
//         value = (short) (current().nextInt() >> (Integer.SIZE - size));
//         assertEquals(value >> size, value >= 0 ? 0 : -1);
//     }
//     return value;
// }


import static com.github.jinahya.bit.io.BitIoTests.randomSizeForLong;
import static com.github.jinahya.bit.io.BitIoTests.randomSizeForShort;
import static com.github.jinahya.bit.io.BitIoTests.randomValueForByte;
import static com.github.jinahya.bit.io.BitIoTests.randomValueForChar;
import static com.github.jinahya.bit.io.BitIoTests.randomValueForInt;
import static com.github.jinahya.bit.io.BitIoTests.randomValueForLong;
import static com.github.jinahya.bit.io.BitIoTests.randomValueForShort;
import static java.util.concurrent.ThreadLocalRandom.current;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.converter.ConvertWith;
import org.junit.jupiter.params.provider.MethodSource;
import java.io.IOException;
import static com.github.jinahya.bit.io.BitIoTests.randomSizeForByte;
import static com.github.jinahya.bit.io.BitIoTests.randomSizeForChar;
import static com.github.jinahya.bit.io.BitIoTests.randomSizeForInt;
            throws IOException {
        final int expected = current().nextInt();
        output.writeInt32(expected);
        assertEquals(0L, output.align(Byte.BYTES));
        final int actual = input.readInt32();
        assertEquals(0L, input.align(Byte.BYTES));
        assertEquals(expected, actual);
    }

    @MethodSource({"com.github.jinahya.bit.io.ByteIoSource#sourceByteIo"})
    @ParameterizedTest
    void testInt32Le(@ConvertWith(BitOutputConverter.class) final BitOutput output,
                     @ConvertWith(BitInputConverter.class) final BitInput input)
            throws IOException {
        final int expected = current().nextInt();
        output.writeInt32Le(expected);
        assertEquals(0L, output.align(Byte.BYTES));
        final int actual = input.readInt32Le();
        assertEquals(0L, input.align(Byte.BYTES));
        assertEquals(expected, actual);
    }

    // ------------------------------------------------------------------------------------------------------------ long
    @MethodSource({"com.github.jinahya.bit.io.ByteIoSource#sourceByteIo"})
    @ParameterizedTest
    void testLong(@ConvertWith(BitOutputConverter.class) final BitOutput output,
                  @ConvertWith(BitInputConverter.class) final BitInput input)
            throws IOException {
        final boolean unsigned = current().nextBoolean();
        final int size = randomSizeForLong(unsigned);
// Path: src/test/java/com/github/jinahya/bit/io/BitIoTests.java
// static int randomSizeForByte(final boolean unsigned) {
//     return requireValidSizeByte(unsigned, current().nextInt(1, Byte.SIZE + (unsigned ? 0 : 1)));
// }
// 
// Path: src/test/java/com/github/jinahya/bit/io/BitIoTests.java
// static int randomSizeForChar() {
//     return requireValidSizeChar(current().nextInt(1, Character.SIZE));
// }
// 
// Path: src/test/java/com/github/jinahya/bit/io/BitIoTests.java
// static int randomSizeForInt(final boolean unsigned) {
//     return requireValidSizeInt(unsigned, current().nextInt(1, Integer.SIZE + (unsigned ? 0 : 1)));
// }
// 
// Path: src/test/java/com/github/jinahya/bit/io/BitIoTests.java
// static int randomSizeForLong(final boolean unsigned) {
//     return requireValidSizeLong(unsigned, current().nextInt(1, Long.SIZE + (unsigned ? 0 : 1)));
// }
// 
// Path: src/test/java/com/github/jinahya/bit/io/BitIoTests.java
// static int randomSizeForShort(final boolean unsigned) {
//     return requireValidSizeShort(unsigned, current().nextInt(1, Short.SIZE + (unsigned ? 0 : 1)));
// }
// 
// Path: src/test/java/com/github/jinahya/bit/io/BitIoTests.java
// static byte randomValueForByte(final boolean unsigned, final int size) {
//     final byte value;
//     if (unsigned) {
//         value = (byte) (current().nextInt() >>> (Integer.SIZE - size));
//         assertTrue(value >= 0);
//     } else {
//         value = (byte) (current().nextInt() >> (Integer.SIZE - size));
//         assertEquals(value >> size, value >= 0 ? 0 : -1);
//     }
//     return value;
// }
// 
// Path: src/test/java/com/github/jinahya/bit/io/BitIoTests.java
// static char randomValueForChar(final int size) {
//     return (char) (current().nextInt(Character.MAX_VALUE + 1) >> (Integer.SIZE - size));
// }
// 
// Path: src/test/java/com/github/jinahya/bit/io/BitIoTests.java
// static int randomValueForInt(final boolean unsigned, final int size) {
//     final int value;
//     if (unsigned) {
//         value = current().nextInt() >>> (Integer.SIZE - size);
//         assertTrue(value >= 0);
//     } else {
//         value = current().nextInt() >> (Integer.SIZE - size);
//         if (size < Integer.SIZE) {
//             assertEquals(value >> size, value >= 0 ? 0 : -1);
//         }
//     }
//     return value;
// }
// 
// Path: src/test/java/com/github/jinahya/bit/io/BitIoTests.java
// static long randomValueForLong(final boolean unsigned, final int size) {
//     final long value;
//     if (unsigned) {
//         value = current().nextLong() >>> (Long.SIZE - size);
//         assertTrue(value >= 0);
//     } else {
//         value = current().nextLong() >> (Long.SIZE - size);
//         if (size < Long.SIZE) {
//             assertEquals(value >> size, value >= 0L ? 0L : -1L);
//         }
//     }
//     return value;
// }
// 
// Path: src/test/java/com/github/jinahya/bit/io/BitIoTests.java
// static short randomValueForShort(final boolean unsigned, final int size) {
//     final short value;
//     if (unsigned) {
//         value = (short) (current().nextInt() >>> (Integer.SIZE - size));
//         assertTrue(value >= 0);
//     } else {
//         value = (short) (current().nextInt() >> (Integer.SIZE - size));
//         assertEquals(value >> size, value >= 0 ? 0 : -1);
//     }
//     return value;
// }


// Path: src/test/java/com/github/jinahya/bit/io/BitIoTest.java
import static com.github.jinahya.bit.io.BitIoTests.randomSizeForLong;
import static com.github.jinahya.bit.io.BitIoTests.randomSizeForShort;
import static com.github.jinahya.bit.io.BitIoTests.randomValueForByte;
import static com.github.jinahya.bit.io.BitIoTests.randomValueForChar;
import static com.github.jinahya.bit.io.BitIoTests.randomValueForInt;
import static com.github.jinahya.bit.io.BitIoTests.randomValueForLong;
import static com.github.jinahya.bit.io.BitIoTests.randomValueForShort;
import static java.util.concurrent.ThreadLocalRandom.current;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.converter.ConvertWith;
import org.junit.jupiter.params.provider.MethodSource;
import java.io.IOException;
import static com.github.jinahya.bit.io.BitIoTests.randomSizeForByte;
import static com.github.jinahya.bit.io.BitIoTests.randomSizeForChar;
import static com.github.jinahya.bit.io.BitIoTests.randomSizeForInt;

            throws IOException {
        final int expected = current().nextInt();
        output.writeInt32(expected);
        assertEquals(0L, output.align(Byte.BYTES));
        final int actual = input.readInt32();
        assertEquals(0L, input.align(Byte.BYTES));
        assertEquals(expected, actual);
    }

    @MethodSource({"com.github.jinahya.bit.io.ByteIoSource#sourceByteIo"})
    @ParameterizedTest
    void testInt32Le(@ConvertWith(BitOutputConverter.class) final BitOutput output,
                     @ConvertWith(BitInputConverter.class) final BitInput input)
            throws IOException {
        final int expected = current().nextInt();
        output.writeInt32Le(expected);
        assertEquals(0L, output.align(Byte.BYTES));
        final int actual = input.readInt32Le();
        assertEquals(0L, input.align(Byte.BYTES));
        assertEquals(expected, actual);
    }

    // ------------------------------------------------------------------------------------------------------------ long
    @MethodSource({"com.github.jinahya.bit.io.ByteIoSource#sourceByteIo"})
    @ParameterizedTest
    void testLong(@ConvertWith(BitOutputConverter.class) final BitOutput output,
                  @ConvertWith(BitInputConverter.class) final BitInput input)
            throws IOException {
        final boolean unsigned = current().nextBoolean();
        final int size = randomSizeForLong(unsigned);
        final long expected = randomValueForLong(unsigned, size);