### Question:
ByteUtils { public static boolean readBooleanFromByte(byte containerByte, int bitOffset) { if (bitOffset < 0 || bitOffset > 31) throw new IllegalArgumentException("Bit offset must be between 0 and 7."); return isBitEnabled(containerByte, bitOffset); }  static byte[] readBytes(int numBytes, ByteArrayInputStream inputStream); static String readString(ByteArrayInputStream inputStream); static byte[] longToByteArray(long value); static long byteArrayToLong(byte[] byteArray); static byte[] intToByteArray(int value); static int byteArrayToInt(byte[] byteArray); static byte[] shortToByteArray(short value); static short byteArrayToShort(byte[] byteArray); static byte[] stringToByteArray(String value); static String byteArrayToString(byte[] value); static int byteToInt(byte b); static boolean isBitEnabled(int containerInteger, int bitPosition); static int readIntegerFromByte(byte containerByte, int bitOffset, int bitLength); static boolean readBooleanFromByte(byte containerByte, int bitOffset); static byte[] readUntilCR(ByteArrayInputStream inputStream); static byte[] newByteArray(byte[] data, int finalSize); static byte[] swapByteArray(byte[] source);  }### Answer:
@Test public final void testReadBooleanFromByteOffsetNegative() { exception.expect(IllegalArgumentException.class); exception.expectMessage(is(equalTo("Bit offset must be between 0 and 7."))); ByteUtils.readBooleanFromByte((byte)25, -9); }
@Test public final void testReadBooleanFromByteOffsetBiggerThan7() { exception.expect(IllegalArgumentException.class); exception.expectMessage(is(equalTo("Bit offset must be between 0 and 7."))); ByteUtils.readBooleanFromByte((byte)25, 100); }
@Test public final void testReadBooleanFromByteTrue() { byte n = (byte)0x08; boolean expectedResult = true; boolean result = ByteUtils.readBooleanFromByte(n, 3); assertThat("Read boolean must be true", result, is(equalTo(expectedResult))); }
@Test public final void testReadBooleanFromByteFalse() { byte n = (byte)0xEF; boolean expectedResult = false; boolean result = ByteUtils.readBooleanFromByte(n, 4); assertThat("Read boolean must be false", result, is(equalTo(expectedResult))); }