public void testFromByteArray_withNullInputThrowsNullPointerException() { try { Stats.fromByteArray(null); fail("Expected NullPointerException"); } catch (NullPointerException expected) { } }
public void testFromByteArray_withEmptyArrayInputThrowsIllegalArgumentException() { try { Stats.fromByteArray(new byte[0]); fail("Expected IllegalArgumentException"); } catch (IllegalArgumentException expected) { } }
public void testFromByteArrayWithTooShortArrayInputThrowsIllegalArgumentException() { byte[] buffer = MANY_VALUES_STATS_VARARGS.toByteArray(); byte[] tooShortByteArray = ByteBuffer.allocate(buffer.length - 1) .order(ByteOrder.LITTLE_ENDIAN) .put(buffer, 0, Stats.BYTES - 1) .array(); try { Stats.fromByteArray(tooShortByteArray); fail("Expected IllegalArgumentException"); } catch (IllegalArgumentException expected) { } }
public void testFromByteArray_withTooLongArrayInputThrowsIllegalArgumentException() { byte[] buffer = MANY_VALUES_STATS_VARARGS.toByteArray(); byte[] tooLongByteArray = ByteBuffer.allocate(buffer.length + 2) .order(ByteOrder.LITTLE_ENDIAN) .put(buffer) .putChar('.') .array(); try { Stats.fromByteArray(tooLongByteArray); fail("Expected IllegalArgumentException"); } catch (IllegalArgumentException expected) { } }
public void testToByteArrayAndFromByteArrayRoundTrip() { for (Stats stats : ALL_STATS) { byte[] statsByteArray = stats.toByteArray(); // Round trip to byte array and back assertThat(Stats.fromByteArray(statsByteArray)).isEqualTo(stats); } }
public void testFromByteArray_withNullInputThrowsNullPointerException() { try { Stats.fromByteArray(null); fail("Expected NullPointerException"); } catch (NullPointerException expected) { } }
public void testFromByteArray_withEmptyArrayInputThrowsIllegalArgumentException() { try { Stats.fromByteArray(new byte[0]); fail("Expected IllegalArgumentException"); } catch (IllegalArgumentException expected) { } }
public void testFromByteArray_withTooLongArrayInputThrowsIllegalArgumentException() { byte[] buffer = MANY_VALUES_STATS_VARARGS.toByteArray(); byte[] tooLongByteArray = ByteBuffer.allocate(buffer.length + 2).order(ByteOrder.LITTLE_ENDIAN) .put(buffer).putChar('.').array(); try { Stats.fromByteArray(tooLongByteArray); fail("Expected IllegalArgumentException"); } catch (IllegalArgumentException expected) { } }
public void testFromByteArrayWithTooShortArrayInputThrowsIllegalArgumentException() { byte[] buffer = MANY_VALUES_STATS_VARARGS.toByteArray(); byte[] tooShortByteArray = ByteBuffer.allocate(buffer.length - 1).order(ByteOrder.LITTLE_ENDIAN) .put(buffer, 0, Stats.BYTES - 1).array(); try { Stats.fromByteArray(tooShortByteArray); fail("Expected IllegalArgumentException"); } catch (IllegalArgumentException expected) { } }
public void testToByteArrayAndFromByteArrayRoundTrip() { for (Stats stats : ALL_STATS) { byte[] statsByteArray = stats.toByteArray(); // Round trip to byte array and back assertThat(Stats.fromByteArray(statsByteArray)).isEqualTo(stats); } }