| 59 | // Shifting ------------------------------------------------------------------ |
| 60 | |
| 61 | TEST(ShiftRight, ShortBuffer) { |
| 62 | const size_t kLength = 5; |
| 63 | std::vector<std::vector<uint8_t>> exp = { |
| 64 | {0xAA, 0xBB, 0xCC, 0xDD, 0xEE}, {0x00, 0xAA, 0xBB, 0xCC, 0xDD}, |
| 65 | {0x00, 0x00, 0xAA, 0xBB, 0xCC}, {0x00, 0x00, 0x00, 0xAA, 0xBB}, |
| 66 | {0x00, 0x00, 0x00, 0x00, 0xAA}, {0x00, 0x00, 0x00, 0x00, 0x00}}; |
| 67 | for (size_t i = 0; i < exp.size(); i++) { |
| 68 | std::vector<uint8_t> buf = {0xAA, 0xBB, 0xCC, 0xDD, 0xEE}; |
| 69 | bess::utils::ShiftBytesRightSmall(buf.data(), kLength, i); |
| 70 | int ret = memcmp(exp[i].data(), buf.data(), kLength); |
| 71 | if (ret != 0) { |
| 72 | EXPECT_TRUE(false) << "equality check failed for shift: " << i; |
| 73 | PrintBytes("buf", buf); |
| 74 | PrintBytes("exp", exp[i]); |
| 75 | } |
| 76 | } |
| 77 | } |
| 78 | |
| 79 | TEST(ShiftRight, Aligned) { |
| 80 | std::vector<size_t> lengths = {8, 16, 24, 32}; |
nothing calls this directly
no test coverage detected