### Question:
VariableLengthQuantity { List<String> decode(List<Long> bytes) { throw new UnsupportedOperationException("Delete this statement and write your own implementation."); }    }### Answer:
@Ignore("Remove to run test") @Test public void testDecodeOneByte() { List<String> expected = Arrays.asList("0x7f"); List<Long> bytes = Arrays.asList(0x7fL); assertEquals(expected, variableLengthQuantity.decode(bytes)); }
@Ignore("Remove to run test") @Test public void testDecodeTwoBytes() { List<String> expected = Arrays.asList("0x2000"); List<Long> bytes = Arrays.asList(0xc0L, 0x0L); assertEquals(expected, variableLengthQuantity.decode(bytes)); }
@Ignore("Remove to run test") @Test public void testDecodeThreeBytes() { List<String> expected = Arrays.asList("0x1fffff"); List<Long> bytes = Arrays.asList(0xffL, 0xffL, 0x7fL); assertEquals(expected, variableLengthQuantity.decode(bytes)); }
@Ignore("Remove to run test") @Test public void testDecodeFourBytes() { List<String> expected = Arrays.asList("0x200000"); List<Long> bytes = Arrays.asList(0x81L, 0x80L, 0x80L, 0x0L); assertEquals(expected, variableLengthQuantity.decode(bytes)); }
@Ignore("Remove to run test") @Test public void testDecodeMaximum32BitInteger() { List<String> expected = Arrays.asList("0xffffffff"); List<Long> bytes = Arrays.asList(0x8fL, 0xffL, 0xffL, 0xffL, 0x7fL); assertEquals(expected, variableLengthQuantity.decode(bytes)); }
@Ignore("Remove to run test") @Test public void testCannotDecodeIncompleteSequence() { List<Long> bytes = Arrays.asList(0xffL); IllegalArgumentException expected = assertThrows( IllegalArgumentException.class, () -> variableLengthQuantity.decode(bytes)); assertThat(expected) .hasMessage("Invalid variable-length quantity encoding"); }
@Ignore("Remove to run test") @Test public void testCannotDecodeIncompleteSequenceEvenIfValueIsZero() { List<Long> bytes = Arrays.asList(0x80L); IllegalArgumentException expected = assertThrows( IllegalArgumentException.class, () -> variableLengthQuantity.decode(bytes)); assertThat(expected) .hasMessage("Invalid variable-length quantity encoding"); }
@Ignore("Remove to run test") @Test public void testDecodeMultipleBytes() { List<String> expected = Arrays.asList("0x2000", "0x123456", "0xfffffff", "0x0", "0x3fff", "0x4000"); List<Long> bytes = Arrays.asList(0xc0L, 0x0L, 0xc8L, 0xe8L, 0x56L, 0xffL, 0xffL, 0xffL, 0x7fL, 0x0L, 0xffL, 0x7fL, 0x81L, 0x80L, 0x0L); assertEquals(expected, variableLengthQuantity.decode(bytes)); }