1*e8f2b0d5SEd Tanous #include <boost/system/error_code.hpp>
2*e8f2b0d5SEd Tanous #include <sdbusplus/message.hpp>
3*e8f2b0d5SEd Tanous #include <sdbusplus/utility/make_dbus_args_tuple.hpp>
4*e8f2b0d5SEd Tanous
5*e8f2b0d5SEd Tanous #include <gtest/gtest.h>
6*e8f2b0d5SEd Tanous
7*e8f2b0d5SEd Tanous namespace sdbusplus
8*e8f2b0d5SEd Tanous {
9*e8f2b0d5SEd Tanous namespace utility
10*e8f2b0d5SEd Tanous {
11*e8f2b0d5SEd Tanous
TEST(MakeDbusArgsTuple,MessageFirst)12*e8f2b0d5SEd Tanous TEST(MakeDbusArgsTuple, MessageFirst)
13*e8f2b0d5SEd Tanous {
14*e8f2b0d5SEd Tanous std::tuple<boost::system::error_code, sdbusplus::message_t, int>
15*e8f2b0d5SEd Tanous input_tuple;
16*e8f2b0d5SEd Tanous auto tuple_out = make_dbus_args_tuple(input_tuple);
17*e8f2b0d5SEd Tanous static_assert(
18*e8f2b0d5SEd Tanous std::is_same_v<std::tuple_element_t<0, decltype(tuple_out)>, int&>,
19*e8f2b0d5SEd Tanous "Second type wasn't int");
20*e8f2b0d5SEd Tanous static_assert(std::tuple_size_v<decltype(tuple_out)> == 1,
21*e8f2b0d5SEd Tanous "Size was wrong");
22*e8f2b0d5SEd Tanous // Verify the output reference is now the first member, and references the 2
23*e8f2b0d5SEd Tanous // index tuple arg
24*e8f2b0d5SEd Tanous EXPECT_EQ(&std::get<2>(input_tuple), &std::get<0>(tuple_out));
25*e8f2b0d5SEd Tanous }
TEST(MakeDbusArgsTuple,ArgFirst)26*e8f2b0d5SEd Tanous TEST(MakeDbusArgsTuple, ArgFirst)
27*e8f2b0d5SEd Tanous {
28*e8f2b0d5SEd Tanous std::tuple<boost::system::error_code, int> input_tuple{
29*e8f2b0d5SEd Tanous boost::system::error_code(), 42};
30*e8f2b0d5SEd Tanous auto tuple_out = make_dbus_args_tuple(input_tuple);
31*e8f2b0d5SEd Tanous static_assert(
32*e8f2b0d5SEd Tanous std::is_same_v<std::tuple_element_t<0, decltype(tuple_out)>, int&>,
33*e8f2b0d5SEd Tanous "Second type wasn't int");
34*e8f2b0d5SEd Tanous static_assert(std::tuple_size_v<decltype(tuple_out)> == 1,
35*e8f2b0d5SEd Tanous "Size was wrong");
36*e8f2b0d5SEd Tanous // Verify the output reference is now the first member, and references the 1
37*e8f2b0d5SEd Tanous // index tuple arg
38*e8f2b0d5SEd Tanous EXPECT_EQ(&std::get<1>(input_tuple), &std::get<0>(tuple_out));
39*e8f2b0d5SEd Tanous EXPECT_EQ(std::get<0>(tuple_out), 42);
40*e8f2b0d5SEd Tanous }
TEST(MakeDbusArgsTuple,NoArgs)41*e8f2b0d5SEd Tanous TEST(MakeDbusArgsTuple, NoArgs)
42*e8f2b0d5SEd Tanous {
43*e8f2b0d5SEd Tanous std::tuple<boost::system::error_code> input_tuple;
44*e8f2b0d5SEd Tanous auto tuple_out = make_dbus_args_tuple(input_tuple);
45*e8f2b0d5SEd Tanous static_assert(std::tuple_size_v<decltype(tuple_out)> == 0,
46*e8f2b0d5SEd Tanous "Size was wrong");
47*e8f2b0d5SEd Tanous }
48*e8f2b0d5SEd Tanous } // namespace utility
49*e8f2b0d5SEd Tanous } // namespace sdbusplus
50