xref: /openbmc/sdbusplus/test/message/types.cpp (revision 2b0bdd6e)
1 #include <gtest/gtest.h>
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 TEST(MessageTypes, Integer)
14 {
15     ASSERT_EQ(dbus_string(1),"i");
16 }
17 
18 TEST(MessageTypes, Double)
19 {
20     ASSERT_EQ(dbus_string(1.0), "d");
21 }
22 
23 TEST(MessageTypes, MultipleParameter)
24 {
25     ASSERT_EQ(dbus_string(false, true), "bb");
26     ASSERT_EQ(dbus_string(1, 2, 3, true, 1.0), "iiibd");
27 }
28 
29 TEST(MessageTypes, StringReferences)
30 {
31     std::string a = "a";
32     std::string b = "b";
33     const char* c = "c";
34 
35     ASSERT_EQ(dbus_string(a, std::move(b), c), "sss");
36 }
37 
38 TEST(MessageTypes, ObjectPath)
39 {
40     ASSERT_EQ(dbus_string(sdbusplus::message::object_path("/asdf")), "o");
41 }
42 
43 TEST(MessageTypes, Signature)
44 {
45     ASSERT_EQ(dbus_string(sdbusplus::message::signature("sss")), "g");
46 }
47