|
4 | 4 | public class VariableLengthQuantityTests |
5 | 5 | { |
6 | 6 | [Fact] |
7 | | - public void Zero() |
| 7 | + public void Encode_a_series_of_integers_producing_a_series_of_bytes_zero() |
8 | 8 | { |
9 | | - var integers = new[] { 0x0u }; |
10 | | - var expected = new[] { 0x0u }; |
| 9 | + uint[] integers = [0]; |
| 10 | + uint[] expected = [0]; |
11 | 11 | Assert.Equal(expected, VariableLengthQuantity.Encode(integers)); |
12 | 12 | } |
13 | 13 |
|
14 | 14 | [Fact(Skip = "Remove this Skip property to run this test")] |
15 | | - public void Arbitrary_single_byte() |
| 15 | + public void Encode_a_series_of_integers_producing_a_series_of_bytes_arbitrary_single_byte() |
16 | 16 | { |
17 | | - var integers = new[] { 0x40u }; |
18 | | - var expected = new[] { 0x40u }; |
| 17 | + uint[] integers = [64]; |
| 18 | + uint[] expected = [64]; |
19 | 19 | Assert.Equal(expected, VariableLengthQuantity.Encode(integers)); |
20 | 20 | } |
21 | 21 |
|
22 | 22 | [Fact(Skip = "Remove this Skip property to run this test")] |
23 | | - public void Largest_single_byte() |
| 23 | + public void Encode_a_series_of_integers_producing_a_series_of_bytes_largest_single_byte() |
24 | 24 | { |
25 | | - var integers = new[] { 0x7Fu }; |
26 | | - var expected = new[] { 0x7Fu }; |
| 25 | + uint[] integers = [127]; |
| 26 | + uint[] expected = [127]; |
27 | 27 | Assert.Equal(expected, VariableLengthQuantity.Encode(integers)); |
28 | 28 | } |
29 | 29 |
|
30 | 30 | [Fact(Skip = "Remove this Skip property to run this test")] |
31 | | - public void Smallest_double_byte() |
| 31 | + public void Encode_a_series_of_integers_producing_a_series_of_bytes_smallest_double_byte() |
32 | 32 | { |
33 | | - var integers = new[] { 0x80u }; |
34 | | - var expected = new[] { 0x81u, 0x0u }; |
| 33 | + uint[] integers = [128]; |
| 34 | + uint[] expected = [129, 0]; |
35 | 35 | Assert.Equal(expected, VariableLengthQuantity.Encode(integers)); |
36 | 36 | } |
37 | 37 |
|
38 | 38 | [Fact(Skip = "Remove this Skip property to run this test")] |
39 | | - public void Arbitrary_double_byte() |
| 39 | + public void Encode_a_series_of_integers_producing_a_series_of_bytes_arbitrary_double_byte() |
40 | 40 | { |
41 | | - var integers = new[] { 0x2000u }; |
42 | | - var expected = new[] { 0xC0u, 0x0u }; |
| 41 | + uint[] integers = [8192]; |
| 42 | + uint[] expected = [192, 0]; |
43 | 43 | Assert.Equal(expected, VariableLengthQuantity.Encode(integers)); |
44 | 44 | } |
45 | 45 |
|
46 | 46 | [Fact(Skip = "Remove this Skip property to run this test")] |
47 | | - public void Largest_double_byte() |
| 47 | + public void Encode_a_series_of_integers_producing_a_series_of_bytes_largest_double_byte() |
48 | 48 | { |
49 | | - var integers = new[] { 0x3FFFu }; |
50 | | - var expected = new[] { 0xFFu, 0x7Fu }; |
| 49 | + uint[] integers = [16383]; |
| 50 | + uint[] expected = [255, 127]; |
51 | 51 | Assert.Equal(expected, VariableLengthQuantity.Encode(integers)); |
52 | 52 | } |
53 | 53 |
|
54 | 54 | [Fact(Skip = "Remove this Skip property to run this test")] |
55 | | - public void Smallest_triple_byte() |
| 55 | + public void Encode_a_series_of_integers_producing_a_series_of_bytes_smallest_triple_byte() |
56 | 56 | { |
57 | | - var integers = new[] { 0x4000u }; |
58 | | - var expected = new[] { 0x81u, 0x80u, 0x0u }; |
| 57 | + uint[] integers = [16384]; |
| 58 | + uint[] expected = [129, 128, 0]; |
59 | 59 | Assert.Equal(expected, VariableLengthQuantity.Encode(integers)); |
60 | 60 | } |
61 | 61 |
|
62 | 62 | [Fact(Skip = "Remove this Skip property to run this test")] |
63 | | - public void Arbitrary_triple_byte() |
| 63 | + public void Encode_a_series_of_integers_producing_a_series_of_bytes_arbitrary_triple_byte() |
64 | 64 | { |
65 | | - var integers = new[] { 0x100000u }; |
66 | | - var expected = new[] { 0xC0u, 0x80u, 0x0u }; |
| 65 | + uint[] integers = [1048576]; |
| 66 | + uint[] expected = [192, 128, 0]; |
67 | 67 | Assert.Equal(expected, VariableLengthQuantity.Encode(integers)); |
68 | 68 | } |
69 | 69 |
|
70 | 70 | [Fact(Skip = "Remove this Skip property to run this test")] |
71 | | - public void Largest_triple_byte() |
| 71 | + public void Encode_a_series_of_integers_producing_a_series_of_bytes_largest_triple_byte() |
72 | 72 | { |
73 | | - var integers = new[] { 0x1FFFFFu }; |
74 | | - var expected = new[] { 0xFFu, 0xFFu, 0x7Fu }; |
| 73 | + uint[] integers = [2097151]; |
| 74 | + uint[] expected = [255, 255, 127]; |
75 | 75 | Assert.Equal(expected, VariableLengthQuantity.Encode(integers)); |
76 | 76 | } |
77 | 77 |
|
78 | 78 | [Fact(Skip = "Remove this Skip property to run this test")] |
79 | | - public void Smallest_quadruple_byte() |
| 79 | + public void Encode_a_series_of_integers_producing_a_series_of_bytes_smallest_quadruple_byte() |
80 | 80 | { |
81 | | - var integers = new[] { 0x200000u }; |
82 | | - var expected = new[] { 0x81u, 0x80u, 0x80u, 0x0u }; |
| 81 | + uint[] integers = [2097152]; |
| 82 | + uint[] expected = [129, 128, 128, 0]; |
83 | 83 | Assert.Equal(expected, VariableLengthQuantity.Encode(integers)); |
84 | 84 | } |
85 | 85 |
|
86 | 86 | [Fact(Skip = "Remove this Skip property to run this test")] |
87 | | - public void Arbitrary_quadruple_byte() |
| 87 | + public void Encode_a_series_of_integers_producing_a_series_of_bytes_arbitrary_quadruple_byte() |
88 | 88 | { |
89 | | - var integers = new[] { 0x8000000u }; |
90 | | - var expected = new[] { 0xC0u, 0x80u, 0x80u, 0x0u }; |
| 89 | + uint[] integers = [134217728]; |
| 90 | + uint[] expected = [192, 128, 128, 0]; |
91 | 91 | Assert.Equal(expected, VariableLengthQuantity.Encode(integers)); |
92 | 92 | } |
93 | 93 |
|
94 | 94 | [Fact(Skip = "Remove this Skip property to run this test")] |
95 | | - public void Largest_quadruple_byte() |
| 95 | + public void Encode_a_series_of_integers_producing_a_series_of_bytes_largest_quadruple_byte() |
96 | 96 | { |
97 | | - var integers = new[] { 0xFFFFFFFu }; |
98 | | - var expected = new[] { 0xFFu, 0xFFu, 0xFFu, 0x7Fu }; |
| 97 | + uint[] integers = [268435455]; |
| 98 | + uint[] expected = [255, 255, 255, 127]; |
99 | 99 | Assert.Equal(expected, VariableLengthQuantity.Encode(integers)); |
100 | 100 | } |
101 | 101 |
|
102 | 102 | [Fact(Skip = "Remove this Skip property to run this test")] |
103 | | - public void Smallest_quintuple_byte() |
| 103 | + public void Encode_a_series_of_integers_producing_a_series_of_bytes_smallest_quintuple_byte() |
104 | 104 | { |
105 | | - var integers = new[] { 0x10000000u }; |
106 | | - var expected = new[] { 0x81u, 0x80u, 0x80u, 0x80u, 0x0u }; |
| 105 | + uint[] integers = [268435456]; |
| 106 | + uint[] expected = [129, 128, 128, 128, 0]; |
107 | 107 | Assert.Equal(expected, VariableLengthQuantity.Encode(integers)); |
108 | 108 | } |
109 | 109 |
|
110 | 110 | [Fact(Skip = "Remove this Skip property to run this test")] |
111 | | - public void Arbitrary_quintuple_byte() |
| 111 | + public void Encode_a_series_of_integers_producing_a_series_of_bytes_arbitrary_quintuple_byte() |
112 | 112 | { |
113 | | - var integers = new[] { 0xFF000000u }; |
114 | | - var expected = new[] { 0x8Fu, 0xF8u, 0x80u, 0x80u, 0x0u }; |
| 113 | + uint[] integers = [4278190080]; |
| 114 | + uint[] expected = [143, 248, 128, 128, 0]; |
115 | 115 | Assert.Equal(expected, VariableLengthQuantity.Encode(integers)); |
116 | 116 | } |
117 | 117 |
|
118 | 118 | [Fact(Skip = "Remove this Skip property to run this test")] |
119 | | - public void Maximum_32_bit_integer_input() |
| 119 | + public void Encode_a_series_of_integers_producing_a_series_of_bytes_maximum_32_bit_integer_input() |
120 | 120 | { |
121 | | - var integers = new[] { 0xFFFFFFFFu }; |
122 | | - var expected = new[] { 0x8Fu, 0xFFu, 0xFFu, 0xFFu, 0x7Fu }; |
| 121 | + uint[] integers = [4294967295]; |
| 122 | + uint[] expected = [143, 255, 255, 255, 127]; |
123 | 123 | Assert.Equal(expected, VariableLengthQuantity.Encode(integers)); |
124 | 124 | } |
125 | 125 |
|
126 | 126 | [Fact(Skip = "Remove this Skip property to run this test")] |
127 | | - public void Two_single_byte_values() |
| 127 | + public void Encode_a_series_of_integers_producing_a_series_of_bytes_two_single_byte_values() |
128 | 128 | { |
129 | | - var integers = new[] { 0x40u, 0x7Fu }; |
130 | | - var expected = new[] { 0x40u, 0x7Fu }; |
| 129 | + uint[] integers = [64, 127]; |
| 130 | + uint[] expected = [64, 127]; |
131 | 131 | Assert.Equal(expected, VariableLengthQuantity.Encode(integers)); |
132 | 132 | } |
133 | 133 |
|
134 | 134 | [Fact(Skip = "Remove this Skip property to run this test")] |
135 | | - public void Two_multi_byte_values() |
| 135 | + public void Encode_a_series_of_integers_producing_a_series_of_bytes_two_multi_byte_values() |
136 | 136 | { |
137 | | - var integers = new[] { 0x4000u, 0x123456u }; |
138 | | - var expected = new[] { 0x81u, 0x80u, 0x0u, 0xC8u, 0xE8u, 0x56u }; |
| 137 | + uint[] integers = [16384, 1193046]; |
| 138 | + uint[] expected = [129, 128, 0, 200, 232, 86]; |
139 | 139 | Assert.Equal(expected, VariableLengthQuantity.Encode(integers)); |
140 | 140 | } |
141 | 141 |
|
142 | 142 | [Fact(Skip = "Remove this Skip property to run this test")] |
143 | | - public void Many_multi_byte_values() |
| 143 | + public void Encode_a_series_of_integers_producing_a_series_of_bytes_many_multi_byte_values() |
144 | 144 | { |
145 | | - var integers = new[] { 0x2000u, 0x123456u, 0xFFFFFFFu, 0x0u, 0x3FFFu, 0x4000u }; |
146 | | - var expected = new[] { 0xC0u, 0x0u, 0xC8u, 0xE8u, 0x56u, 0xFFu, 0xFFu, 0xFFu, 0x7Fu, 0x0u, 0xFFu, 0x7Fu, 0x81u, 0x80u, 0x0u }; |
| 145 | + uint[] integers = [8192, 1193046, 268435455, 0, 16383, 16384]; |
| 146 | + uint[] expected = [192, 0, 200, 232, 86, 255, 255, 255, 127, 0, 255, 127, 129, 128, 0]; |
147 | 147 | Assert.Equal(expected, VariableLengthQuantity.Encode(integers)); |
148 | 148 | } |
149 | 149 |
|
150 | 150 | [Fact(Skip = "Remove this Skip property to run this test")] |
151 | | - public void One_byte() |
| 151 | + public void Decode_a_series_of_bytes_producing_a_series_of_integers_one_byte() |
152 | 152 | { |
153 | | - var integers = new[] { 0x7Fu }; |
154 | | - var expected = new[] { 0x7Fu }; |
| 153 | + uint[] integers = [127]; |
| 154 | + uint[] expected = [127]; |
155 | 155 | Assert.Equal(expected, VariableLengthQuantity.Decode(integers)); |
156 | 156 | } |
157 | 157 |
|
158 | 158 | [Fact(Skip = "Remove this Skip property to run this test")] |
159 | | - public void Two_bytes() |
| 159 | + public void Decode_a_series_of_bytes_producing_a_series_of_integers_two_bytes() |
160 | 160 | { |
161 | | - var integers = new[] { 0xC0u, 0x0u }; |
162 | | - var expected = new[] { 0x2000u }; |
| 161 | + uint[] integers = [192, 0]; |
| 162 | + uint[] expected = [8192]; |
163 | 163 | Assert.Equal(expected, VariableLengthQuantity.Decode(integers)); |
164 | 164 | } |
165 | 165 |
|
166 | 166 | [Fact(Skip = "Remove this Skip property to run this test")] |
167 | | - public void Three_bytes() |
| 167 | + public void Decode_a_series_of_bytes_producing_a_series_of_integers_three_bytes() |
168 | 168 | { |
169 | | - var integers = new[] { 0xFFu, 0xFFu, 0x7Fu }; |
170 | | - var expected = new[] { 0x1FFFFFu }; |
| 169 | + uint[] integers = [255, 255, 127]; |
| 170 | + uint[] expected = [2097151]; |
171 | 171 | Assert.Equal(expected, VariableLengthQuantity.Decode(integers)); |
172 | 172 | } |
173 | 173 |
|
174 | 174 | [Fact(Skip = "Remove this Skip property to run this test")] |
175 | | - public void Four_bytes() |
| 175 | + public void Decode_a_series_of_bytes_producing_a_series_of_integers_four_bytes() |
176 | 176 | { |
177 | | - var integers = new[] { 0x81u, 0x80u, 0x80u, 0x0u }; |
178 | | - var expected = new[] { 0x200000u }; |
| 177 | + uint[] integers = [129, 128, 128, 0]; |
| 178 | + uint[] expected = [2097152]; |
179 | 179 | Assert.Equal(expected, VariableLengthQuantity.Decode(integers)); |
180 | 180 | } |
181 | 181 |
|
182 | 182 | [Fact(Skip = "Remove this Skip property to run this test")] |
183 | | - public void Maximum_32_bit_integer() |
| 183 | + public void Decode_a_series_of_bytes_producing_a_series_of_integers_maximum_32_bit_integer() |
184 | 184 | { |
185 | | - var integers = new[] { 0x8Fu, 0xFFu, 0xFFu, 0xFFu, 0x7Fu }; |
186 | | - var expected = new[] { 0xFFFFFFFFu }; |
| 185 | + uint[] integers = [143, 255, 255, 255, 127]; |
| 186 | + uint[] expected = [4294967295]; |
187 | 187 | Assert.Equal(expected, VariableLengthQuantity.Decode(integers)); |
188 | 188 | } |
189 | 189 |
|
190 | 190 | [Fact(Skip = "Remove this Skip property to run this test")] |
191 | | - public void Incomplete_sequence_causes_error() |
| 191 | + public void Decode_a_series_of_bytes_producing_a_series_of_integers_incomplete_sequence_causes_error() |
192 | 192 | { |
193 | | - var integers = new[] { 0xFFu }; |
| 193 | + uint[] integers = [255]; |
194 | 194 | Assert.Throws<InvalidOperationException>(() => VariableLengthQuantity.Decode(integers)); |
195 | 195 | } |
196 | 196 |
|
197 | 197 | [Fact(Skip = "Remove this Skip property to run this test")] |
198 | | - public void Incomplete_sequence_causes_error_even_if_value_is_zero() |
| 198 | + public void Decode_a_series_of_bytes_producing_a_series_of_integers_incomplete_sequence_causes_error_even_if_value_is_zero() |
199 | 199 | { |
200 | | - var integers = new[] { 0x80u }; |
| 200 | + uint[] integers = [128]; |
201 | 201 | Assert.Throws<InvalidOperationException>(() => VariableLengthQuantity.Decode(integers)); |
202 | 202 | } |
203 | 203 |
|
204 | 204 | [Fact(Skip = "Remove this Skip property to run this test")] |
205 | | - public void Multiple_values() |
| 205 | + public void Decode_a_series_of_bytes_producing_a_series_of_integers_multiple_values() |
206 | 206 | { |
207 | | - var integers = new[] { 0xC0u, 0x0u, 0xC8u, 0xE8u, 0x56u, 0xFFu, 0xFFu, 0xFFu, 0x7Fu, 0x0u, 0xFFu, 0x7Fu, 0x81u, 0x80u, 0x0u }; |
208 | | - var expected = new[] { 0x2000u, 0x123456u, 0xFFFFFFFu, 0x0u, 0x3FFFu, 0x4000u }; |
| 207 | + uint[] integers = [192, 0, 200, 232, 86, 255, 255, 255, 127, 0, 255, 127, 129, 128, 0]; |
| 208 | + uint[] expected = [8192, 1193046, 268435455, 0, 16383, 16384]; |
209 | 209 | Assert.Equal(expected, VariableLengthQuantity.Decode(integers)); |
210 | 210 | } |
211 | 211 | } |
0 commit comments