### Question:
BigendianEncoding { static void longToByteArray(long value, byte[] dest, int destOffset) { Utils.checkArgument(dest.length >= destOffset + LONG_BYTES, "array too small"); dest[destOffset + 7] = (byte) (value & 0xFFL); dest[destOffset + 6] = (byte) (value >> 8 & 0xFFL); dest[destOffset + 5] = (byte) (value >> 16 & 0xFFL); dest[destOffset + 4] = (byte) (value >> 24 & 0xFFL); dest[destOffset + 3] = (byte) (value >> 32 & 0xFFL); dest[destOffset + 2] = (byte) (value >> 40 & 0xFFL); dest[destOffset + 1] = (byte) (value >> 48 & 0xFFL); dest[destOffset] = (byte) (value >> 56 & 0xFFL); } private  BigendianEncoding();   }### Answer:
@Test void longToByteArray_Fails() { assertThrows( IllegalArgumentException.class, () -> BigendianEncoding.longToByteArray(123, new byte[LONG_BYTES], 1), "array too small"); }
@Test void longToByteArray() { byte[] result1 = new byte[BigendianEncoding.LONG_BYTES]; BigendianEncoding.longToByteArray(FIRST_LONG, result1, 0); assertThat(result1).isEqualTo(FIRST_BYTE_ARRAY); byte[] result2 = new byte[BigendianEncoding.LONG_BYTES]; BigendianEncoding.longToByteArray(SECOND_LONG, result2, 0); assertThat(result2).isEqualTo(SECOND_BYTE_ARRAY); byte[] result3 = new byte[2 * BigendianEncoding.LONG_BYTES]; BigendianEncoding.longToByteArray(FIRST_LONG, result3, 0); BigendianEncoding.longToByteArray(SECOND_LONG, result3, BigendianEncoding.LONG_BYTES); assertThat(result3).isEqualTo(BOTH_BYTE_ARRAY); }
@Test public void longToByteArray_Fails() { thrown.expect(IllegalArgumentException.class); thrown.expectMessage("array too small"); BigendianEncoding.longToByteArray(123, new byte[BigendianEncoding.LONG_BYTES], 1); }
@Test public void longToByteArray() { byte[] result1 = new byte[BigendianEncoding.LONG_BYTES]; BigendianEncoding.longToByteArray(FIRST_LONG, result1, 0); assertThat(result1).isEqualTo(FIRST_BYTE_ARRAY); byte[] result2 = new byte[BigendianEncoding.LONG_BYTES]; BigendianEncoding.longToByteArray(SECOND_LONG, result2, 0); assertThat(result2).isEqualTo(SECOND_BYTE_ARRAY); byte[] result3 = new byte[2 * BigendianEncoding.LONG_BYTES]; BigendianEncoding.longToByteArray(FIRST_LONG, result3, 0); BigendianEncoding.longToByteArray(SECOND_LONG, result3, BigendianEncoding.LONG_BYTES); assertThat(result3).isEqualTo(BOTH_BYTE_ARRAY); }