94TEST(GetUintX, LittleEndian)
96 const std::array<uint8_t, 9> buf =
97 {0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9};
110 const std::array<uint8_t, 9> buf =
111 {0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9};
125 EXPECT_FALSE(
setUintX(0, &dummy, 0, ByteOrder::little));
126 EXPECT_FALSE(
setUintX(0, &dummy, 0, ByteOrder::big));
127 EXPECT_FALSE(
setUintX(0, &dummy, 3, ByteOrder::little));
128 EXPECT_FALSE(
setUintX(0, &dummy, 3, ByteOrder::big));
129 EXPECT_FALSE(
setUintX(0, &dummy, 5, ByteOrder::little));
130 EXPECT_FALSE(
setUintX(0, &dummy, 5, ByteOrder::big));
131 EXPECT_FALSE(
setUintX(0, &dummy, 6, ByteOrder::little));
132 EXPECT_FALSE(
setUintX(0, &dummy, 6, ByteOrder::big));
133 EXPECT_FALSE(
setUintX(0, &dummy, 7, ByteOrder::little));
134 EXPECT_FALSE(
setUintX(0, &dummy, 7, ByteOrder::big));
135 EXPECT_FALSE(
setUintX(0, &dummy, 9, ByteOrder::little));
136 EXPECT_FALSE(
setUintX(0, &dummy, 9, ByteOrder::big));
141 const std::array<uint8_t, 9> orig_buf =
142 {0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9};
145 EXPECT_TRUE(
setUintX(0xf1, buf.data(), 1, ByteOrder::little));
147 ElementsAre(0xf1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9));
148 EXPECT_TRUE(
setUintX(0xe2e1, buf.data(), 2, ByteOrder::little));
150 ElementsAre(0xe1, 0xe2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9));
151 EXPECT_TRUE(
setUintX(0xd4d3d2d1, buf.data(), 4, ByteOrder::little));
153 ElementsAre(0xd1, 0xd2, 0xd3, 0xd4, 0x5, 0x6, 0x7, 0x8, 0x9));
154 EXPECT_TRUE(
setUintX(0xc8c7c6c5c4c3c2c1, buf.data(), 8,
157 ElementsAre(0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0x9));
162 const std::array<uint8_t, 9> orig_buf =
163 {0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9};
166 EXPECT_TRUE(
setUintX(0xf1, buf.data(), 1, ByteOrder::big));
168 ElementsAre(0xf1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9));
169 EXPECT_TRUE(
setUintX(0xe1e2, buf.data(), 2, ByteOrder::big));
171 ElementsAre(0xe1, 0xe2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9));
172 EXPECT_TRUE(
setUintX(0xd1d2d3d4, buf.data(), 4, ByteOrder::big));
174 ElementsAre(0xd1, 0xd2, 0xd3, 0xd4, 0x5, 0x6, 0x7, 0x8, 0x9));
175 EXPECT_TRUE(
setUintX(0xc1c2c3c4c5c6c7c8, buf.data(), 8, ByteOrder::big));
177 ElementsAre(0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0x9));
199 const std::array<uint8_t, 9> buf =
200 {0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9};
208 "0x0807060504030201");
213 const std::array<uint8_t, 9> buf =
214 {0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9};
222 "0x0102030405060708");
225TEST(PrintByteBuf, LittleEndian)
227 const std::array<uint8_t, 9> buf =
228 {0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0xa};
230 EXPECT_EQ(
printByteBuf(buf.data(), 0, ByteOrder::little, 3),
"[]");
231 EXPECT_EQ(
printByteBuf(buf.data(), 1, ByteOrder::little, 3),
"[01]");
232 EXPECT_EQ(
printByteBuf(buf.data(), 2, ByteOrder::little, 3),
"[0102]");
233 EXPECT_EQ(
printByteBuf(buf.data(), 3, ByteOrder::little, 3),
235 EXPECT_EQ(
printByteBuf(buf.data(), 4, ByteOrder::little, 3),
237 EXPECT_EQ(
printByteBuf(buf.data(), 5, ByteOrder::little, 3),
239 EXPECT_EQ(
printByteBuf(buf.data(), 6, ByteOrder::little, 3),
241 EXPECT_EQ(
printByteBuf(buf.data(), 7, ByteOrder::little, 3),
242 "[010203 040506 07]");
243 EXPECT_EQ(
printByteBuf(buf.data(), 8, ByteOrder::little, 3),
244 "[010203 040506 0708]");
245 EXPECT_EQ(
printByteBuf(buf.data(), 9, ByteOrder::little, 3),
246 "[010203 040506 07080a]");
251 const std::array<uint8_t, 9> buf =
252 {0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0xa};
254 EXPECT_EQ(
printByteBuf(buf.data(), 0, ByteOrder::big, 3),
"[]");
255 EXPECT_EQ(
printByteBuf(buf.data(), 1, ByteOrder::big, 3),
"[01]");
256 EXPECT_EQ(
printByteBuf(buf.data(), 2, ByteOrder::big, 3),
"[0201]");
257 EXPECT_EQ(
printByteBuf(buf.data(), 3, ByteOrder::big, 3),
"[030201]");
258 EXPECT_EQ(
printByteBuf(buf.data(), 4, ByteOrder::big, 3),
260 EXPECT_EQ(
printByteBuf(buf.data(), 5, ByteOrder::big, 3),
262 EXPECT_EQ(
printByteBuf(buf.data(), 6, ByteOrder::big, 3),
264 EXPECT_EQ(
printByteBuf(buf.data(), 7, ByteOrder::big, 3),
265 "[07 060504 030201]");
266 EXPECT_EQ(
printByteBuf(buf.data(), 8, ByteOrder::big, 3),
267 "[0807 060504 030201]");
268 EXPECT_EQ(
printByteBuf(buf.data(), 9, ByteOrder::big, 3),
269 "[0a0807 060504 030201]");
274 const std::array<uint8_t, 9> buf =
275 {0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0xa};
277 EXPECT_EQ(
printByteBuf(buf.data(), 9, ByteOrder::little, 1),
278 "[01 02 03 04 05 06 07 08 0a]");
279 EXPECT_EQ(
printByteBuf(buf.data(), 9, ByteOrder::little, 2),
280 "[0102 0304 0506 0708 0a]");
281 EXPECT_EQ(
printByteBuf(buf.data(), 9, ByteOrder::little, 3),
282 "[010203 040506 07080a]");
283 EXPECT_EQ(
printByteBuf(buf.data(), 9, ByteOrder::little, 4),
284 "[01020304 05060708 0a]");
285 EXPECT_EQ(
printByteBuf(buf.data(), 9, ByteOrder::little, 5),
286 "[0102030405 0607080a]");
287 EXPECT_EQ(
printByteBuf(buf.data(), 9, ByteOrder::little, 6),
288 "[010203040506 07080a]");
289 EXPECT_EQ(
printByteBuf(buf.data(), 9, ByteOrder::little, 7),
290 "[01020304050607 080a]");
291 EXPECT_EQ(
printByteBuf(buf.data(), 9, ByteOrder::little, 8),
292 "[0102030405060708 0a]");
293 EXPECT_EQ(
printByteBuf(buf.data(), 9, ByteOrder::little, 9),
294 "[01020304050607080a]");
295 EXPECT_EQ(
printByteBuf(buf.data(), 9, ByteOrder::little, 10),
296 "[01020304050607080a]");
297 EXPECT_EQ(
printByteBuf(buf.data(), 9, ByteOrder::little, 100),
298 "[01020304050607080a]");
300 EXPECT_EQ(
printByteBuf(buf.data(), 9, ByteOrder::big, 1),
301 "[0a 08 07 06 05 04 03 02 01]");
302 EXPECT_EQ(
printByteBuf(buf.data(), 9, ByteOrder::big, 2),
303 "[0a 0807 0605 0403 0201]");
304 EXPECT_EQ(
printByteBuf(buf.data(), 9, ByteOrder::big, 3),
305 "[0a0807 060504 030201]");
306 EXPECT_EQ(
printByteBuf(buf.data(), 9, ByteOrder::big, 4),
307 "[0a 08070605 04030201]");
308 EXPECT_EQ(
printByteBuf(buf.data(), 9, ByteOrder::big, 5),
309 "[0a080706 0504030201]");
310 EXPECT_EQ(
printByteBuf(buf.data(), 9, ByteOrder::big, 6),
311 "[0a0807 060504030201]");
312 EXPECT_EQ(
printByteBuf(buf.data(), 9, ByteOrder::big, 7),
313 "[0a08 07060504030201]");
314 EXPECT_EQ(
printByteBuf(buf.data(), 9, ByteOrder::big, 8),
315 "[0a 0807060504030201]");
316 EXPECT_EQ(
printByteBuf(buf.data(), 9, ByteOrder::big, 9),
317 "[0a0807060504030201]");
318 EXPECT_EQ(
printByteBuf(buf.data(), 9, ByteOrder::big, 10),
319 "[0a0807060504030201]");
320 EXPECT_EQ(
printByteBuf(buf.data(), 9, ByteOrder::big, 100),
321 "[0a0807060504030201]");
std::vector< SwitchingFiber * > expected({ &a, &b, &a, &a, &a, &b, &c, &a, &c, &c, &c })