1 #include <sdbusplus/message/types.hpp> 2 #include <sdbusplus/utility/tuple_to_array.hpp> 3 4 #include <gtest/gtest.h> 5 6 template <typename... Args> 7 auto dbus_string(Args&&... args) 8 { 9 return std::string(sdbusplus::utility::tuple_to_array( 10 sdbusplus::message::types::type_id<Args...>()) 11 .data()); 12 } 13 14 TEST(MessageTypes, Integer) 15 { 16 ASSERT_EQ(dbus_string(1), "i"); 17 } 18 19 TEST(MessageTypes, Double) 20 { 21 ASSERT_EQ(dbus_string(1.0), "d"); 22 } 23 24 TEST(MessageTypes, MultipleParameter) 25 { 26 ASSERT_EQ(dbus_string(false, true), "bb"); 27 ASSERT_EQ(dbus_string(1, 2, 3, true, 1.0), "iiibd"); 28 } 29 30 TEST(MessageTypes, StringReferences) 31 { 32 std::string a = "a"; 33 std::string b = "b"; 34 const char* c = "c"; 35 36 ASSERT_EQ(dbus_string(a, std::move(b), c), "sss"); 37 } 38 39 TEST(MessageTypes, ObjectPath) 40 { 41 ASSERT_EQ(dbus_string(sdbusplus::message::object_path("/asdf")), "o"); 42 } 43 44 TEST(MessageTypes, Signature) 45 { 46 ASSERT_EQ(dbus_string(sdbusplus::message::signature("sss")), "g"); 47 } 48