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/read.cpp b/test/message/read.cpp
index 1d99940..d1d78e7 100644
--- a/test/message/read.cpp
+++ b/test/message/read.cpp
@@ -10,6 +10,7 @@
#include <string>
#include <tuple>
#include <unordered_map>
+#include <unordered_set>
#include <variant>
#include <vector>
@@ -296,6 +297,27 @@
EXPECT_EQ(ss, ret_ss);
}
+TEST_F(ReadTest, UnorderedSet)
+{
+ const std::unordered_set<std::string> ss{"one", "two", "eight"};
+
+ {
+ testing::InSequence seq;
+ expect_enter_container(SD_BUS_TYPE_ARRAY, "s");
+ for (const auto& s : ss)
+ {
+ expect_at_end(false, 0);
+ expect_basic<const char*>(SD_BUS_TYPE_STRING, s.c_str());
+ }
+ expect_at_end(false, 1);
+ expect_exit_container();
+ }
+
+ std::unordered_set<std::string> ret_ss;
+ new_message().read(ret_ss);
+ EXPECT_EQ(ss, ret_ss);
+}
+
TEST_F(ReadTest, Map)
{
const std::map<int, std::string> mis{