summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorPatrick Williams <patrick@stwcx.xyz>2016-07-20 17:52:55 -0500
committerPatrick Williams <patrick@stwcx.xyz>2016-09-12 21:54:52 -0500
commit930460c0fe571255ab370338623ce8ff5b239297 (patch)
tree5e1c1aa6fd09d277dd8bdc2031aa6ff72ff3ecc8 /test
parent4fe85a30e7b2c7cdbc08c28971a8f2f7b8c4de85 (diff)
downloadsdbusplus-930460c0fe571255ab370338623ce8ff5b239297.tar.gz
sdbusplus-930460c0fe571255ab370338623ce8ff5b239297.zip
std::vector support for append/read
Change-Id: I1820ee2213feb37fab10a491b1099032fd48c18d Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Diffstat (limited to 'test')
-rw-r--r--test/message/append.cpp42
-rw-r--r--test/message/read.cpp27
2 files changed, 69 insertions, 0 deletions
diff --git a/test/message/append.cpp b/test/message/append.cpp
index 4413910..87d8fc5 100644
--- a/test/message/append.cpp
+++ b/test/message/append.cpp
@@ -192,6 +192,48 @@ void runTests()
b.call_noreply(m);
}
+ // Test vector.
+ {
+ auto m = newMethodCall__test(b);
+ std::vector<std::string> s{ "1", "2", "3"};
+ m.append(1, s, 2);
+ verifyTypeString = "iasi";
+
+ struct verify
+ {
+ static void op(sd_bus_message* m)
+ {
+ int32_t a = 0;
+ sd_bus_message_read(m, "i", &a);
+ assert(a == 1);
+
+ auto rc = sd_bus_message_enter_container(m,
+ SD_BUS_TYPE_ARRAY,
+ "s");
+ assert(0 <= rc);
+
+ const char* s = nullptr;
+ sd_bus_message_read_basic(m, 's', &s);
+ assert(0 == strcmp("1", s));
+ sd_bus_message_read_basic(m, 's', &s);
+ assert(0 == strcmp("2", s));
+ sd_bus_message_read_basic(m, 's', &s);
+ assert(0 == strcmp("3", s));
+ assert(1 == sd_bus_message_at_end(m, false));
+
+ sd_bus_message_exit_container(m);
+
+ sd_bus_message_read(m, "i", &a);
+ assert(a == 2);
+
+ }
+ };
+ verifyCallback = &verify::op;
+
+
+ b.call_noreply(m);
+ }
+
// Shutdown server.
{
auto m = b.new_method_call(SERVICE, "/", INTERFACE, QUIT_METHOD);
diff --git a/test/message/read.cpp b/test/message/read.cpp
index 48c445e..1021175 100644
--- a/test/message/read.cpp
+++ b/test/message/read.cpp
@@ -193,6 +193,33 @@ void runTests()
b.call_noreply(m);
}
+ // Test vector.
+ {
+ auto m = newMethodCall__test(b);
+ std::vector<std::string> s{ "1", "2", "3"};
+ m.append(1, s, 2);
+ verifyTypeString = "iasi";
+
+ struct verify
+ {
+ static void op(sdbusplus::message::message& m)
+ {
+ int32_t a = 0;
+ std::vector<std::string> s;
+ m.read(a, s);
+ assert(a == 1);
+ assert(s[0] == "1");
+ assert(s[1] == "2");
+ assert(s[2] == "3");
+ decltype(s) s2 = { "1" , "2" , "3" };
+ assert(s == s2);
+ }
+ };
+ verifyCallback = &verify::op;
+
+ b.call_noreply(m);
+ }
+
// Shutdown server.
{
auto m = b.new_method_call(SERVICE, "/", INTERFACE, QUIT_METHOD);
OpenPOWER on IntegriCloud