xref: /openbmc/sdbusplus/test/message/types.cpp (revision 696fa72a)
1 #include <cassert>
2 #include <sdbusplus/message/types.hpp>
3 #include <sdbusplus/utility/tuple_to_array.hpp>
4 
5 template <typename ...Args>
6 auto dbus_string(Args&& ... args)
7 {
8     return std::string(
9                sdbusplus::utility::tuple_to_array(
10                    sdbusplus::message::types::type_id<Args...>()).data());
11 }
12 
13 int main()
14 {
15 
16     // Check a few simple types.
17     assert(dbus_string(1) == "i");
18     assert(dbus_string(1.0) == "d");
19 
20     // Check a multiple parameter call.
21     assert(dbus_string(false, true) == "bb");
22     assert(dbus_string(1, 2, 3, true, 1.0) == "iiibd");
23 
24     // Check an l-value and r-value reference.
25     {
26         std::string a = "a";
27         std::string b = "b";
28         const char* c = "c";
29 
30         assert(dbus_string(a, std::move(b), c) == "sss");
31     }
32     return 0;
33 }
34