sdbus++: add support for 'set'
Add 'set' as a supported type to `sdbus++` and set as `std::set`.
The use of ordered-set is to match 'dict' as `std::map` and because
'struct' is `std::tuple`, which has `operator<=>` but not `std::hash`.
This ensures better compatiblilty with possible property type choices
by users.
Also, add a few test cases to ensure `std::set` and `std::unordered_set`
are well-covered.
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: I59605db1b22d54f783d807eda1e1ec1f9eb6792f
diff --git a/test/message/append.cpp b/test/message/append.cpp
index c6eb152..288199b 100644
--- a/test/message/append.cpp
+++ b/test/message/append.cpp
@@ -9,6 +9,7 @@
#include <string>
#include <tuple>
#include <unordered_map>
+#include <unordered_set>
#include <variant>
#include <vector>
@@ -257,6 +258,22 @@
new_message().append(s);
}
+TEST_F(AppendTest, UnorderedSet)
+{
+ const std::unordered_set<std::string> s{"one", "two", "eight"};
+
+ {
+ testing::InSequence seq;
+ expect_open_container(SD_BUS_TYPE_ARRAY, "s");
+ for (const auto& i : s)
+ {
+ expect_basic_string(SD_BUS_TYPE_STRING, i.c_str());
+ }
+ expect_close_container();
+ }
+ new_message().append(s);
+}
+
TEST_F(AppendTest, Map)
{
const std::map<int, std::string> m{