|
1 | 1 | {
|
2 |
| - "#": [ |
| 2 | + "exercise": "variable-length-quantity", |
| 3 | + "version": "1.0.0", |
| 4 | + "comments": [ |
3 | 5 | "JSON doesn't allow hexadecimal literals.",
|
4 | 6 | "All numbers are given as decimal literals instead.",
|
5 | 7 | "It is highly recommended that your track's test generator display all numbers as hexadecimal literals."
|
6 | 8 | ],
|
7 |
| - "encode": { |
8 |
| - "description": ["Encode a series of integers, producing a series of bytes."], |
9 |
| - "cases": [ |
10 |
| - { |
11 |
| - "description": "zero", |
12 |
| - "input": [0], |
13 |
| - "expected": [0] |
14 |
| - }, |
15 |
| - { |
16 |
| - "description": "arbitrary single byte", |
17 |
| - "input": [64], |
18 |
| - "expected": [64] |
19 |
| - }, |
20 |
| - { |
21 |
| - "description": "largest single byte", |
22 |
| - "input": [127], |
23 |
| - "expected": [127] |
24 |
| - }, |
25 |
| - { |
26 |
| - "description": "smallest double byte", |
27 |
| - "input": [128], |
28 |
| - "expected": [129, 0] |
29 |
| - }, |
30 |
| - { |
31 |
| - "description": "arbitrary double byte", |
32 |
| - "input": [8192], |
33 |
| - "expected": [192, 0] |
34 |
| - }, |
35 |
| - { |
36 |
| - "description": "largest double byte", |
37 |
| - "input": [16383], |
38 |
| - "expected": [255, 127] |
39 |
| - }, |
40 |
| - { |
41 |
| - "description": "smallest triple byte", |
42 |
| - "input": [16384], |
43 |
| - "expected": [129, 128, 0] |
44 |
| - }, |
45 |
| - { |
46 |
| - "description": "arbitrary triple byte", |
47 |
| - "input": [1048576], |
48 |
| - "expected": [192, 128, 0] |
49 |
| - }, |
50 |
| - { |
51 |
| - "description": "largest triple byte", |
52 |
| - "input": [2097151], |
53 |
| - "expected": [255, 255, 127] |
54 |
| - }, |
55 |
| - { |
56 |
| - "description": "smallest quadruple byte", |
57 |
| - "input": [2097152], |
58 |
| - "expected": [129, 128, 128, 0] |
59 |
| - }, |
60 |
| - { |
61 |
| - "description": "arbitrary quadruple byte", |
62 |
| - "input": [134217728], |
63 |
| - "expected": [192, 128, 128, 0] |
64 |
| - }, |
65 |
| - { |
66 |
| - "description": "largest quadruple byte", |
67 |
| - "input": [268435455], |
68 |
| - "expected": [255, 255, 255, 127] |
69 |
| - }, |
70 |
| - { |
71 |
| - "description": "smallest quintuple byte", |
72 |
| - "input": [268435456], |
73 |
| - "expected": [129, 128, 128, 128, 0] |
74 |
| - }, |
75 |
| - { |
76 |
| - "description": "arbitrary quintuple byte", |
77 |
| - "input": [4278190080], |
78 |
| - "expected": [143, 248, 128, 128, 0] |
79 |
| - }, |
80 |
| - { |
81 |
| - "description": "maximum 32-bit integer input", |
82 |
| - "input": [4294967295], |
83 |
| - "expected": [143, 255, 255, 255, 127] |
84 |
| - }, |
85 |
| - { |
86 |
| - "description": "two single-byte values", |
87 |
| - "input": [64, 127], |
88 |
| - "expected": [64, 127] |
89 |
| - }, |
90 |
| - { |
91 |
| - "description": "two multi-byte values", |
92 |
| - "input": [16384, 1193046], |
93 |
| - "expected": [129, 128, 0, 200, 232, 86] |
94 |
| - }, |
95 |
| - { |
96 |
| - "description": "many multi-byte values", |
97 |
| - "input": [8192, 1193046, 268435455, 0, 16383, 16384], |
98 |
| - "expected": [192, 0, 200, 232, 86, 255, 255, 255, 127, 0, 255, 127, 129, 128, 0] |
99 |
| - } |
100 |
| - ] |
101 |
| - }, |
102 |
| - "decode": { |
103 |
| - "description": ["Decode a series of bytes, producing a series of integers."], |
104 |
| - "cases": [ |
105 |
| - { |
106 |
| - "description": "one byte", |
107 |
| - "input": [127], |
108 |
| - "expected": [127] |
109 |
| - }, |
110 |
| - { |
111 |
| - "description": "two bytes", |
112 |
| - "input": [192, 0], |
113 |
| - "expected": [8192] |
114 |
| - }, |
115 |
| - { |
116 |
| - "description": "three bytes", |
117 |
| - "input": [255, 255, 127], |
118 |
| - "expected": [2097151] |
119 |
| - }, |
120 |
| - { |
121 |
| - "description": "four bytes", |
122 |
| - "input": [129, 128, 128, 0], |
123 |
| - "expected": [2097152] |
124 |
| - }, |
125 |
| - { |
126 |
| - "description": "maximum 32-bit integer", |
127 |
| - "input": [143, 255, 255, 255, 127], |
128 |
| - "expected": [4294967295] |
129 |
| - }, |
130 |
| - { |
131 |
| - "description": "incomplete sequence causes error", |
132 |
| - "input": [255], |
133 |
| - "expected": null |
134 |
| - }, |
135 |
| - { |
136 |
| - "description": "incomplete sequence causes error, even if value is zero", |
137 |
| - "input": [128], |
138 |
| - "expected": null |
139 |
| - }, |
140 |
| - { |
141 |
| - "description": "multiple values", |
142 |
| - "input": [192, 0, 200, 232, 86, 255, 255, 255, 127, 0, 255, 127, 129, 128, 0], |
143 |
| - "expected": [8192, 1193046, 268435455, 0, 16383, 16384] |
144 |
| - } |
145 |
| - ] |
146 |
| - } |
| 9 | + "cases": [ |
| 10 | + { |
| 11 | + "description": "Encode a series of integers, producing a series of bytes.", |
| 12 | + "cases": [ |
| 13 | + { |
| 14 | + "description": "zero", |
| 15 | + "property": "encode", |
| 16 | + "input": [0], |
| 17 | + "expected": [0] |
| 18 | + }, |
| 19 | + { |
| 20 | + "description": "arbitrary single byte", |
| 21 | + "property": "encode", |
| 22 | + "input": [64], |
| 23 | + "expected": [64] |
| 24 | + }, |
| 25 | + { |
| 26 | + "description": "largest single byte", |
| 27 | + "property": "encode", |
| 28 | + "input": [127], |
| 29 | + "expected": [127] |
| 30 | + }, |
| 31 | + { |
| 32 | + "description": "smallest double byte", |
| 33 | + "property": "encode", |
| 34 | + "input": [128], |
| 35 | + "expected": [129,0] |
| 36 | + }, |
| 37 | + { |
| 38 | + "description": "arbitrary double byte", |
| 39 | + "property": "encode", |
| 40 | + "input": [8192], |
| 41 | + "expected": [192, 0] |
| 42 | + }, |
| 43 | + { |
| 44 | + "description": "largest double byte", |
| 45 | + "property": "encode", |
| 46 | + "input": [16383], |
| 47 | + "expected": [255, 127] |
| 48 | + }, |
| 49 | + { |
| 50 | + "description": "smallest triple byte", |
| 51 | + "property": "encode", |
| 52 | + "input": [16384], |
| 53 | + "expected": [129, 128, 0] |
| 54 | + }, |
| 55 | + { |
| 56 | + "description": "arbitrary triple byte", |
| 57 | + "property": "encode", |
| 58 | + "input": [1048576], |
| 59 | + "expected": [192, 128, 0] |
| 60 | + }, |
| 61 | + { |
| 62 | + "description": "largest triple byte", |
| 63 | + "property": "encode", |
| 64 | + "input": [2097151], |
| 65 | + "expected": [255, 255, 127] |
| 66 | + }, |
| 67 | + { |
| 68 | + "description": "smallest quadruple byte", |
| 69 | + "property": "encode", |
| 70 | + "input": [2097152], |
| 71 | + "expected": [129, 128, 128, 0] |
| 72 | + }, |
| 73 | + { |
| 74 | + "description": "arbitrary quadruple byte", |
| 75 | + "property": "encode", |
| 76 | + "input": [134217728], |
| 77 | + "expected": [192, 128, 128, 0] |
| 78 | + }, |
| 79 | + { |
| 80 | + "description": "largest quadruple byte", |
| 81 | + "property": "encode", |
| 82 | + "input": [268435455], |
| 83 | + "expected": [255, 255, 255, 127] |
| 84 | + }, |
| 85 | + { |
| 86 | + "description": "smallest quintuple byte", |
| 87 | + "property": "encode", |
| 88 | + "input": [268435456], |
| 89 | + "expected": [129, 128, 128, 128, 0] |
| 90 | + }, |
| 91 | + { |
| 92 | + "description": "arbitrary quintuple byte", |
| 93 | + "property": "encode", |
| 94 | + "input": [4278190080], |
| 95 | + "expected": [143, 248, 128, 128, 0] |
| 96 | + }, |
| 97 | + { |
| 98 | + "description": "maximum 32-bit integer input", |
| 99 | + "property": "encode", |
| 100 | + "input": [4294967295], |
| 101 | + "expected": [143, 255, 255, 255, 127] |
| 102 | + }, |
| 103 | + { |
| 104 | + "description": "two single-byte values", |
| 105 | + "property": "encode", |
| 106 | + "input": [64, 127], |
| 107 | + "expected": [64, 127] |
| 108 | + }, |
| 109 | + { |
| 110 | + "description": "two multi-byte values", |
| 111 | + "property": "encode", |
| 112 | + "input": [16384, 1193046], |
| 113 | + "expected": [129, 128, 0, 200, 232, 86] |
| 114 | + }, |
| 115 | + { |
| 116 | + "description": "many multi-byte values", |
| 117 | + "property": "encode", |
| 118 | + "input": [8192, 1193046, 268435455, 0, 16383, 16384], |
| 119 | + "expected": [192, 0, 200, 232, 86, 255, 255, 255, 127, 0, 255, 127, 129, 128, 0] |
| 120 | + } |
| 121 | + ] |
| 122 | + }, |
| 123 | + { |
| 124 | + "description": "Decode a series of bytes, producing a series of integers.", |
| 125 | + "cases": [ |
| 126 | + { |
| 127 | + "description": "one byte", |
| 128 | + "property": "decode", |
| 129 | + "input": [127], |
| 130 | + "expected": [127] |
| 131 | + }, |
| 132 | + { |
| 133 | + "description": "two bytes", |
| 134 | + "property": "decode", |
| 135 | + "input": [192, 0], |
| 136 | + "expected": [8192] |
| 137 | + }, |
| 138 | + { |
| 139 | + "description": "three bytes", |
| 140 | + "property": "decode", |
| 141 | + "input": [255, 255, 127], |
| 142 | + "expected": [2097151] |
| 143 | + }, |
| 144 | + { |
| 145 | + "description": "four bytes", |
| 146 | + "property": "decode", |
| 147 | + "input": [129, 128, 128, 0], |
| 148 | + "expected": [2097152] |
| 149 | + }, |
| 150 | + { |
| 151 | + "description": "maximum 32-bit integer", |
| 152 | + "property": "decode", |
| 153 | + "input": [143, 255, 255, 255, 127], |
| 154 | + "expected": [4294967295] |
| 155 | + }, |
| 156 | + { |
| 157 | + "description": "incomplete sequence causes error", |
| 158 | + "property": "decode", |
| 159 | + "input": [255], |
| 160 | + "expected": null |
| 161 | + }, |
| 162 | + { |
| 163 | + "description": "incomplete sequence causes error, even if value is zero", |
| 164 | + "property": "decode", |
| 165 | + "input": [128], |
| 166 | + "expected": null |
| 167 | + }, |
| 168 | + { |
| 169 | + "description": "multiple values", |
| 170 | + "property": "decode", |
| 171 | + "input": [192, 0, 200, 232, 86, 255, 255, 255, 127, 0, 255, 127, 129, 128, 0], |
| 172 | + "expected": [8192, 1193046, 268435455, 0, 16383, 16384] |
| 173 | + } |
| 174 | + ] |
| 175 | + } |
| 176 | + ] |
147 | 177 | }
|
0 commit comments