summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorWilliam A. Kennington III <wak@google.com>2018-06-26 14:31:15 -0700
committerBrad Bishop <bradleyb@fuzziesquirrel.com>2018-07-09 18:20:42 +0000
commit60a728351ee5f5ed1a1c180b1a40eabc45a7794b (patch)
treefc51123a210e453f93d77f78c0b75cf0e8093502 /test
parent8890e45549737829c282a1e9302bf685cefe07d5 (diff)
downloadsdbusplus-60a728351ee5f5ed1a1c180b1a40eabc45a7794b.tar.gz
sdbusplus-60a728351ee5f5ed1a1c180b1a40eabc45a7794b.zip
test/message/read: Add missing variant skip
We were missing a test of the variant code which is used when the type of the variant provided by the caller does not contain the type needed at runtime to store the data in the message. This tests to make sure that the skip is issued correctly when we can't read out the member. Tested: Unit tests still build and pass Change-Id: I41fdc3e40589f1feedfadc3ab33fe808ff3a6d16 Signed-off-by: William A. Kennington III <wak@google.com>
Diffstat (limited to 'test')
-rw-r--r--test/message/read.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/test/message/read.cpp b/test/message/read.cpp
index 1b6ae84..89f6af0 100644
--- a/test/message/read.cpp
+++ b/test/message/read.cpp
@@ -61,6 +61,12 @@ class ReadTest : public testing::Test
.WillOnce(Return(ret));
}
+ void expect_skip(const char *contents)
+ {
+ EXPECT_CALL(mock, sd_bus_message_skip(nullptr, StrEq(contents)))
+ .WillOnce(Return(0));
+ }
+
void expect_enter_container(char type, const char *contents)
{
EXPECT_CALL(mock, sd_bus_message_enter_container(nullptr, type,
@@ -311,6 +317,18 @@ TEST_F(ReadTest, Variant)
EXPECT_EQ(v2, ret_v2);
}
+TEST_F(ReadTest, VariantSkipUnmatched)
+{
+ {
+ testing::InSequence seq;
+ expect_verify_type(SD_BUS_TYPE_VARIANT, "i", false);
+ expect_verify_type(SD_BUS_TYPE_VARIANT, "b", false);
+ expect_skip("v");
+ }
+ sdbusplus::message::variant<int, bool> ret;
+ new_message().read(ret);
+}
+
TEST_F(ReadTest, LargeCombo)
{
const std::vector<std::set<std::string>> vas{
OpenPOWER on IntegriCloud