diff options
| author | Patrick Williams <patrick@stwcx.xyz> | 2017-02-15 10:23:22 -0600 |
|---|---|---|
| committer | Patrick Williams <patrick@stwcx.xyz> | 2017-02-15 10:24:32 -0600 |
| commit | 16e175311d55045fa6709c0b91cc0f0ec5e2b3a5 (patch) | |
| tree | a352322a785e37831bb7c5d2e82b26842b1f68d8 | |
| parent | fb913e88d30f1c9c29c03926de0eae377442e984 (diff) | |
| download | sdbusplus-16e175311d55045fa6709c0b91cc0f0ec5e2b3a5.tar.gz sdbusplus-16e175311d55045fa6709c0b91cc0f0ec5e2b3a5.zip | |
message-append: Add more string test cases
Add cases uncovered by openbmc/openbmc#1025.
Change-Id: I680b95b2127d50837dccd3ea1ff655fc1eb19ec9
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
| -rw-r--r-- | test/message/append.cpp | 49 |
1 files changed, 45 insertions, 4 deletions
diff --git a/test/message/append.cpp b/test/message/append.cpp index d73a386..c3a06db 100644 --- a/test/message/append.cpp +++ b/test/message/append.cpp @@ -193,14 +193,49 @@ void runTests() b.call_noreply(m); } + // Test const string owned by const struct. openbmc/openbmc#1025 + { + struct + { + const char* foo; + + void insert(sdbusplus::message::message& m) + { + m.append(foo); + } + } s; + + auto m = newMethodCall__test(b); + s.foo = "1234"; + s.insert(m); + + verifyTypeString = "s"; + + struct verify + { + static void op(sd_bus_message* m) + { + const char* s = nullptr; + sd_bus_message_read_basic(m, 's', &s); + assert(0 == strcmp("1234", s)); + } + }; + verifyCallback = &verify::op; + + b.call_noreply(m); + } + // Test multiple strings, various forms. { auto m = newMethodCall__test(b); auto str = "jkl;"s; auto str2 = "JKL:"s; + const char* str3 = "1234"; + const char* const str4 = "5678"; + const auto str5 = "!@#$"; m.append(1, "asdf", "ASDF"s, str, - std::move(str2), 5); - verifyTypeString = "issssi"; + std::move(str2), str3, str4, str5, 5); + verifyTypeString = "isssssssi"; struct verify { @@ -208,14 +243,20 @@ void runTests() { int32_t a = 0, b = 0; const char *s0 = nullptr, *s1 = nullptr, *s2 = nullptr, - *s3 = nullptr; - sd_bus_message_read(m, "issssi", &a, &s0, &s1, &s2, &s3, &b); + *s3 = nullptr, *s4 = nullptr, *s5 = nullptr, + *s6 = nullptr; + sd_bus_message_read(m, "isssssssi", &a, &s0, &s1, &s2, &s3, + &s4, &s5, &s6, &b); assert(a == 1); assert(b == 5); assert(0 == strcmp("asdf", s0)); assert(0 == strcmp("ASDF", s1)); assert(0 == strcmp("jkl;", s2)); assert(0 == strcmp("JKL:", s3)); + assert(0 == strcmp("1234", s4)); + assert(0 == strcmp("5678", s5)); + assert(0 == strcmp("!@#$", s6)); + assert(b == 5); } }; verifyCallback = &verify::op; |

