summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorWilliam A. Kennington III <wak@google.com>2019-04-24 14:44:03 -0700
committerWilliam A. Kennington III <wak@google.com>2019-04-29 12:06:35 -0700
commit906e0f802b56d26e7e0c65eba797fa8a596dee91 (patch)
treebce270b5f95f2893c1596fd2fdb3c8578465d612 /test
parentd10d90563e58606964fe3b8460eed2ca719527e5 (diff)
downloadphosphor-host-ipmid-906e0f802b56d26e7e0c65eba797fa8a596dee91.tar.gz
phosphor-host-ipmid-906e0f802b56d26e7e0c65eba797fa8a596dee91.zip
message/pack: Check for outstanding bits
Currently, if you pack a non-byte aligned member into a message and then pack an array, it will do the wrong thing and treat the unaligned data as being appended to the end of the message. Allowing for this behavior is convoluted and probably not useful, so just return an error. Change-Id: I6f200dbea96c41f49a110ba7536ccfd37115d277 Signed-off-by: William A. Kennington III <wak@google.com>
Diffstat (limited to 'test')
-rw-r--r--test/message/pack.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/test/message/pack.cpp b/test/message/pack.cpp
index d0a738a..7e6cf31 100644
--- a/test/message/pack.cpp
+++ b/test/message/pack.cpp
@@ -235,6 +235,13 @@ TEST(PackBasics, VectorUint8)
ASSERT_EQ(p.raw, k);
}
+TEST(PackBasics, VectorUnaligned)
+{
+ ipmi::message::Payload p;
+ EXPECT_EQ(p.pack(true, std::vector<uint8_t>{1}), 1);
+ EXPECT_EQ(p.raw, std::vector<uint8_t>{0b1});
+}
+
TEST(PackBasics, OptionalEmpty)
{
// an optional will only pack if the value is present
OpenPOWER on IntegriCloud