summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorJames Feist <james.feist@linux.intel.com>2019-04-03 11:54:52 -0700
committerVernon Mauery <vernon.mauery@linux.intel.com>2019-04-04 22:55:56 +0000
commitf299807f1bcca4e2582427d4dcd2a4473871d125 (patch)
treea750b64c4e8d37e7b943d9623e238df8a82bab2d /test
parent7a614182acb466908b9893e953e027711f8c554a (diff)
downloadphosphor-host-ipmid-f299807f1bcca4e2582427d4dcd2a4473871d125.tar.gz
phosphor-host-ipmid-f299807f1bcca4e2582427d4dcd2a4473871d125.zip
message: pack: add variant support
Add variant support to allow return of mutliple specific types. Also change types to const as this is required by the visitor and these could have been const all along. Tested: Added unit test and used in oem provider Change-Id: I5cb056c15d4813b9eee58eecb707664477d019d9 Signed-off-by: James Feist <james.feist@linux.intel.com>
Diffstat (limited to 'test')
-rw-r--r--test/message/pack.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/test/message/pack.cpp b/test/message/pack.cpp
index 60459ed..b3957cc 100644
--- a/test/message/pack.cpp
+++ b/test/message/pack.cpp
@@ -265,6 +265,21 @@ TEST(PackAdvanced, TupleInts)
ASSERT_EQ(p.raw, k);
}
+TEST(PackAdvanced, VariantArray)
+{
+ ipmi::message::Payload p;
+ std::variant<std::array<uint8_t, 2>, uint32_t> variant;
+ auto data = std::array<uint8_t, 2>{2, 4};
+ variant = data;
+
+ p.pack(variant);
+ ASSERT_EQ(p.size(), sizeof(data));
+
+ // check that the bytes were correctly packed packed (LSB first)
+ std::vector<uint8_t> k = {2, 4};
+ ASSERT_EQ(p.raw, k);
+}
+
TEST(PackAdvanced, BoolsnBitfieldsnFixedIntsOhMy)
{
// each element will be added, filling the low-order bits first
OpenPOWER on IntegriCloud