MCPcopy Create free account
hub / github.com/NetSys/bess / TEST

Function TEST

core/utils/bits_test.cc:61–77  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

59// Shifting ------------------------------------------------------------------
60
61TEST(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
79TEST(ShiftRight, Aligned) {
80 std::vector<size_t> lengths = {8, 16, 24, 32};

Callers

nothing calls this directly

Calls 10

ShiftBytesRightSmallFunction · 0.85
PrintBytesFunction · 0.85
SetupBuffersFunction · 0.85
ShiftBytesRightFunction · 0.85
ShiftBytesLeftSmallFunction · 0.85
ShiftBytesLeftFunction · 0.85
MaskBytesSmallFunction · 0.85
MaskBytesFunction · 0.85
sizeMethod · 0.80
dataMethod · 0.80

Tested by

no test coverage detected