From 859518ad4538580e1ac51ef480aaf8d68ead1016 Mon Sep 17 00:00:00 2001 From: xinri Date: Sun, 16 Nov 2025 23:57:04 +0100 Subject: [PATCH 1/2] sync the variable-length-quantity as they had been implemented but not sync --- .../variable-length-quantity/.meta/tests.toml | 80 ++++++++++++------- 1 file changed, 51 insertions(+), 29 deletions(-) diff --git a/exercises/practice/variable-length-quantity/.meta/tests.toml b/exercises/practice/variable-length-quantity/.meta/tests.toml index 923fa0c1a..53be789a3 100644 --- a/exercises/practice/variable-length-quantity/.meta/tests.toml +++ b/exercises/practice/variable-length-quantity/.meta/tests.toml @@ -1,81 +1,103 @@ -# This is an auto-generated file. Regular comments will be removed when this -# file is regenerated. Regenerating will not touch any manually added keys, -# so comments can be added in a "comment" key. +# This is an auto-generated file. +# +# Regenerating this file via `configlet sync` will: +# - Recreate every `description` key/value pair +# - Recreate every `reimplements` key/value pair, where they exist in problem-specifications +# - Remove any `include = true` key/value pair (an omitted `include` key implies inclusion) +# - Preserve any other key/value pair +# +# As user-added comments (using the # character) will be removed when this file +# is regenerated, comments can be added via a `comment` key. [35c9db2e-f781-4c52-b73b-8e76427defd0] -description = "zero" +description = "Encode a series of integers, producing a series of bytes. -> zero" [be44d299-a151-4604-a10e-d4b867f41540] -description = "arbitrary single byte" +description = "Encode a series of integers, producing a series of bytes. -> arbitrary single byte" + +[890bc344-cb80-45af-b316-6806a6971e81] +description = "Encode a series of integers, producing a series of bytes. -> asymmetric single byte" [ea399615-d274-4af6-bbef-a1c23c9e1346] -description = "largest single byte" +description = "Encode a series of integers, producing a series of bytes. -> largest single byte" [77b07086-bd3f-4882-8476-8dcafee79b1c] -description = "smallest double byte" +description = "Encode a series of integers, producing a series of bytes. -> smallest double byte" [63955a49-2690-4e22-a556-0040648d6b2d] -description = "arbitrary double byte" +description = "Encode a series of integers, producing a series of bytes. -> arbitrary double byte" + +[4977d113-251b-4d10-a3ad-2f5a7756bb58] +description = "Encode a series of integers, producing a series of bytes. -> asymmetric double byte" [29da7031-0067-43d3-83a7-4f14b29ed97a] -description = "largest double byte" +description = "Encode a series of integers, producing a series of bytes. -> largest double byte" [3345d2e3-79a9-4999-869e-d4856e3a8e01] -description = "smallest triple byte" +description = "Encode a series of integers, producing a series of bytes. -> smallest triple byte" [5df0bc2d-2a57-4300-a653-a75ee4bd0bee] -description = "arbitrary triple byte" +description = "Encode a series of integers, producing a series of bytes. -> arbitrary triple byte" + +[6731045f-1e00-4192-b5ae-98b22e17e9f7] +description = "Encode a series of integers, producing a series of bytes. -> asymmetric triple byte" [f51d8539-312d-4db1-945c-250222c6aa22] -description = "largest triple byte" +description = "Encode a series of integers, producing a series of bytes. -> largest triple byte" [da78228b-544f-47b7-8bfe-d16b35bbe570] -description = "smallest quadruple byte" +description = "Encode a series of integers, producing a series of bytes. -> smallest quadruple byte" [11ed3469-a933-46f1-996f-2231e05d7bb6] -description = "arbitrary quadruple byte" +description = "Encode a series of integers, producing a series of bytes. -> arbitrary quadruple byte" + +[b45ef770-cbba-48c2-bd3c-c6362679516e] +description = "Encode a series of integers, producing a series of bytes. -> asymmetric quadruple byte" [d5f3f3c3-e0f1-4e7f-aad0-18a44f223d1c] -description = "largest quadruple byte" +description = "Encode a series of integers, producing a series of bytes. -> largest quadruple byte" [91a18b33-24e7-4bfb-bbca-eca78ff4fc47] -description = "smallest quintuple byte" +description = "Encode a series of integers, producing a series of bytes. -> smallest quintuple byte" [5f34ff12-2952-4669-95fe-2d11b693d331] -description = "arbitrary quintuple byte" +description = "Encode a series of integers, producing a series of bytes. -> arbitrary quintuple byte" + +[9be46731-7cd5-415c-b960-48061cbc1154] +description = "Encode a series of integers, producing a series of bytes. -> asymmetric quintuple byte" [7489694b-88c3-4078-9864-6fe802411009] -description = "maximum 32-bit integer input" +description = "Encode a series of integers, producing a series of bytes. -> maximum 32-bit integer input" [f9b91821-cada-4a73-9421-3c81d6ff3661] -description = "two single-byte values" +description = "Encode a series of integers, producing a series of bytes. -> two single-byte values" [68694449-25d2-4974-ba75-fa7bb36db212] -description = "two multi-byte values" +description = "Encode a series of integers, producing a series of bytes. -> two multi-byte values" [51a06b5c-de1b-4487-9a50-9db1b8930d85] -description = "many multi-byte values" +description = "Encode a series of integers, producing a series of bytes. -> many multi-byte values" [baa73993-4514-4915-bac0-f7f585e0e59a] -description = "one byte" +description = "Decode a series of bytes, producing a series of integers. -> one byte" [72e94369-29f9-46f2-8c95-6c5b7a595aee] -description = "two bytes" +description = "Decode a series of bytes, producing a series of integers. -> two bytes" [df5a44c4-56f7-464e-a997-1db5f63ce691] -description = "three bytes" +description = "Decode a series of bytes, producing a series of integers. -> three bytes" [1bb58684-f2dc-450a-8406-1f3452aa1947] -description = "four bytes" +description = "Decode a series of bytes, producing a series of integers. -> four bytes" [cecd5233-49f1-4dd1-a41a-9840a40f09cd] -description = "maximum 32-bit integer" +description = "Decode a series of bytes, producing a series of integers. -> maximum 32-bit integer" [e7d74ba3-8b8e-4bcb-858d-d08302e15695] -description = "incomplete sequence causes error" +description = "Decode a series of bytes, producing a series of integers. -> incomplete sequence causes error" [aa378291-9043-4724-bc53-aca1b4a3fcb6] -description = "incomplete sequence causes error, even if value is zero" +description = "Decode a series of bytes, producing a series of integers. -> incomplete sequence causes error, even if value is zero" [a91e6f5a-c64a-48e3-8a75-ce1a81e0ebee] -description = "multiple values" +description = "Decode a series of bytes, producing a series of integers. -> multiple values" From 059e7db868792af967084d84831d363430a3c51d Mon Sep 17 00:00:00 2001 From: xinri Date: Mon, 17 Nov 2025 23:31:02 +0100 Subject: [PATCH 2/2] add / fix unit tests for variable length quantity feature --- .../.meta/config.json | 3 +- .../test/java/VariableLengthQuantityTest.java | 77 +++++++++++++++++++ 2 files changed, 79 insertions(+), 1 deletion(-) diff --git a/exercises/practice/variable-length-quantity/.meta/config.json b/exercises/practice/variable-length-quantity/.meta/config.json index 1949d7e7b..331713ee2 100644 --- a/exercises/practice/variable-length-quantity/.meta/config.json +++ b/exercises/practice/variable-length-quantity/.meta/config.json @@ -12,7 +12,8 @@ "muzimuzhi", "SleeplessByte", "sshine", - "vpondala" + "vpondala", + "Xinri" ], "files": { "solution": [ diff --git a/exercises/practice/variable-length-quantity/src/test/java/VariableLengthQuantityTest.java b/exercises/practice/variable-length-quantity/src/test/java/VariableLengthQuantityTest.java index 5b25441e7..5e3059937 100644 --- a/exercises/practice/variable-length-quantity/src/test/java/VariableLengthQuantityTest.java +++ b/exercises/practice/variable-length-quantity/src/test/java/VariableLengthQuantityTest.java @@ -1,4 +1,5 @@ import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import java.util.Arrays; @@ -13,6 +14,7 @@ public class VariableLengthQuantityTest { new VariableLengthQuantity(); @Test + @DisplayName("zero") public void testZero() { List expected = Arrays.asList("0x0"); List numbers = Arrays.asList(0x0L); @@ -22,6 +24,7 @@ public void testZero() { @Disabled("Remove to run test") @Test + @DisplayName("arbitrary single byte") public void testArbitrarySingleByte() { List expected = Arrays.asList("0x40"); List numbers = Arrays.asList(0x40L); @@ -31,6 +34,17 @@ public void testArbitrarySingleByte() { @Disabled("Remove to run test") @Test + @DisplayName("asymmetric single byte") + public void testAsymmetricSingleByte() { + List expected = Arrays.asList("0x53"); + List numbers = Arrays.asList(0x53L); + + assertThat(variableLengthQuantity.encode(numbers)).isEqualTo(expected); + } + + @Disabled("Remove to run test") + @Test + @DisplayName("largest single byte") public void testLargestSingleByte() { List expected = Arrays.asList("0x7f"); List numbers = Arrays.asList(0x7fL); @@ -40,6 +54,7 @@ public void testLargestSingleByte() { @Disabled("Remove to run test") @Test + @DisplayName("smallest double byte") public void testSmallestDoubleByte() { List expected = Arrays.asList("0x81", "0x0"); List numbers = Arrays.asList(0x80L); @@ -49,6 +64,7 @@ public void testSmallestDoubleByte() { @Disabled("Remove to run test") @Test + @DisplayName("arbitrary double byte") public void testArbitraryDoubleByte() { List expected = Arrays.asList("0xc0", "0x0"); List numbers = Arrays.asList(0x2000L); @@ -58,6 +74,17 @@ public void testArbitraryDoubleByte() { @Disabled("Remove to run test") @Test + @DisplayName("asymmetric double byte") + public void testAsymmetricDoubleByte() { + List expected = Arrays.asList("0x81", "0x2d"); + List numbers = Arrays.asList(0xadL); + + assertThat(variableLengthQuantity.encode(numbers)).isEqualTo(expected); + } + + @Disabled("Remove to run test") + @Test + @DisplayName("largest double byte") public void testLargestDoubleByte() { List expected = Arrays.asList("0xff", "0x7f"); List numbers = Arrays.asList(0x3fffL); @@ -67,6 +94,7 @@ public void testLargestDoubleByte() { @Disabled("Remove to run test") @Test + @DisplayName("smallest triple byte") public void testSmallestTripleByte() { List expected = Arrays.asList("0x81", "0x80", "0x0"); List numbers = Arrays.asList(0x4000L); @@ -76,6 +104,7 @@ public void testSmallestTripleByte() { @Disabled("Remove to run test") @Test + @DisplayName("arbitrary triple byte") public void testArbitraryTripleByte() { List expected = Arrays.asList("0xc0", "0x80", "0x0"); List numbers = Arrays.asList(0x100000L); @@ -85,6 +114,17 @@ public void testArbitraryTripleByte() { @Disabled("Remove to run test") @Test + @DisplayName("asymmetric triple byte") + public void testAsymmetricTripleByte() { + List expected = Arrays.asList("0x87", "0xab", "0x1c"); + List numbers = Arrays.asList(0x1d59cL); + + assertThat(variableLengthQuantity.encode(numbers)).isEqualTo(expected); + } + + @Disabled("Remove to run test") + @Test + @DisplayName("largest triple byte") public void testLargestTripleByte() { List expected = Arrays.asList("0xff", "0xff", "0x7f"); List numbers = Arrays.asList(0x1fffffL); @@ -94,6 +134,7 @@ public void testLargestTripleByte() { @Disabled("Remove to run test") @Test + @DisplayName("smallest quadruple byte") public void testSmallestQuadrupleByte() { List expected = Arrays.asList("0x81", "0x80", "0x80", "0x0"); List numbers = Arrays.asList(0x200000L); @@ -103,6 +144,7 @@ public void testSmallestQuadrupleByte() { @Disabled("Remove to run test") @Test + @DisplayName("arbitrary quadruple byte") public void testArbitraryQuadrupleByte() { List expected = Arrays.asList("0xc0", "0x80", "0x80", "0x0"); List numbers = Arrays.asList(0x8000000L); @@ -112,6 +154,17 @@ public void testArbitraryQuadrupleByte() { @Disabled("Remove to run test") @Test + @DisplayName("asymmetric quadruple byte") + public void testAsymmetricQuadrupleByte() { + List expected = Arrays.asList("0x81", "0xd5", "0xee", "0x4"); + List numbers = Arrays.asList(0x357704L); + + assertThat(variableLengthQuantity.encode(numbers)).isEqualTo(expected); + } + + @Disabled("Remove to run test") + @Test + @DisplayName("largest quadruple byte") public void testLargestQuadrupleByte() { List expected = Arrays.asList("0xff", "0xff", "0xff", "0x7f"); List numbers = Arrays.asList(0xfffffffL); @@ -121,6 +174,7 @@ public void testLargestQuadrupleByte() { @Disabled("Remove to run test") @Test + @DisplayName("smallest quintuple byte") public void testSmallestQuintupleByte() { List expected = Arrays.asList("0x81", "0x80", "0x80", "0x80", "0x0"); List numbers = Arrays.asList(0x10000000L); @@ -130,6 +184,7 @@ public void testSmallestQuintupleByte() { @Disabled("Remove to run test") @Test + @DisplayName("arbitrary quintuple byte") public void testArbitraryQuintupleByte() { List expected = Arrays.asList("0x8f", "0xf8", "0x80", "0x80", "0x0"); List numbers = Arrays.asList(0xff000000L); @@ -139,6 +194,17 @@ public void testArbitraryQuintupleByte() { @Disabled("Remove to run test") @Test + @DisplayName("asymmetric quintuple byte") + public void testAsymmetricQuintupleByte() { + List expected = Arrays.asList("0x88", "0xb3", "0x95", "0xc2", "0x5"); + List numbers = Arrays.asList(0x86656105L); + + assertThat(variableLengthQuantity.encode(numbers)).isEqualTo(expected); + } + + @Disabled("Remove to run test") + @Test + @DisplayName("maximum 32-bit integer input") public void testMaximum32BitIntegerInput() { List expected = Arrays.asList("0x8f", "0xff", "0xff", "0xff", "0x7f"); List numbers = Arrays.asList(0xffffffffL); @@ -148,6 +214,7 @@ public void testMaximum32BitIntegerInput() { @Disabled("Remove to run test") @Test + @DisplayName("two single-byte values") public void testTwoSingleByteValues() { List expected = Arrays.asList("0x40", "0x7f"); List numbers = Arrays.asList(0x40L, 0x7fL); @@ -157,6 +224,7 @@ public void testTwoSingleByteValues() { @Disabled("Remove to run test") @Test + @DisplayName("two multi-byte values") public void testTwoMultiByteValues() { List expected = Arrays.asList("0x81", "0x80", "0x0", "0xc8", "0xe8", "0x56"); List numbers = Arrays.asList(0x4000L, 0x123456L); @@ -166,6 +234,7 @@ public void testTwoMultiByteValues() { @Disabled("Remove to run test") @Test + @DisplayName("many multi-byte values") public void testManyMultiByteValues() { List expected = Arrays.asList("0xc0", "0x0", "0xc8", "0xe8", "0x56", "0xff", "0xff", "0xff", @@ -179,6 +248,7 @@ public void testManyMultiByteValues() { @Disabled("Remove to run test") @Test + @DisplayName("one byte") public void testDecodeOneByte() { List expected = Arrays.asList("0x7f"); List bytes = Arrays.asList(0x7fL); @@ -188,6 +258,7 @@ public void testDecodeOneByte() { @Disabled("Remove to run test") @Test + @DisplayName("two bytes") public void testDecodeTwoBytes() { List expected = Arrays.asList("0x2000"); List bytes = Arrays.asList(0xc0L, 0x0L); @@ -197,6 +268,7 @@ public void testDecodeTwoBytes() { @Disabled("Remove to run test") @Test + @DisplayName("three bytes") public void testDecodeThreeBytes() { List expected = Arrays.asList("0x1fffff"); List bytes = Arrays.asList(0xffL, 0xffL, 0x7fL); @@ -206,6 +278,7 @@ public void testDecodeThreeBytes() { @Disabled("Remove to run test") @Test + @DisplayName("four bytes") public void testDecodeFourBytes() { List expected = Arrays.asList("0x200000"); List bytes = Arrays.asList(0x81L, 0x80L, 0x80L, 0x0L); @@ -215,6 +288,7 @@ public void testDecodeFourBytes() { @Disabled("Remove to run test") @Test + @DisplayName("maximum 32-bit integer") public void testDecodeMaximum32BitInteger() { List expected = Arrays.asList("0xffffffff"); List bytes = Arrays.asList(0x8fL, 0xffL, 0xffL, 0xffL, 0x7fL); @@ -224,6 +298,7 @@ public void testDecodeMaximum32BitInteger() { @Disabled("Remove to run test") @Test + @DisplayName("incomplete sequence causes error") public void testCannotDecodeIncompleteSequence() { List bytes = Arrays.asList(0xffL); @@ -234,6 +309,7 @@ public void testCannotDecodeIncompleteSequence() { @Disabled("Remove to run test") @Test + @DisplayName("incomplete sequence causes error, even if value is zero") public void testCannotDecodeIncompleteSequenceEvenIfValueIsZero() { List bytes = Arrays.asList(0x80L); @@ -244,6 +320,7 @@ public void testCannotDecodeIncompleteSequenceEvenIfValueIsZero() { @Disabled("Remove to run test") @Test + @DisplayName("multiple values") public void testDecodeMultipleBytes() { List expected = Arrays.asList("0x2000", "0x123456", "0xfffffff", "0x0", "0x3fff",