test: convert message_types to gtest
Change-Id: Ifb5d2b9f4cb5c6700f5c0164466cc5289ee40a26
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
diff --git a/test/Makefile.am b/test/Makefile.am
index e064504..af70c63 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -25,6 +25,7 @@
check_PROGRAMS += message_types
message_types_SOURCES = message/types.cpp
+message_types_LDFLAGS = $(gtest_ldflags)
check_PROGRAMS += utility_tuple_to_array
utility_tuple_to_array_SOURCES = utility/tuple_to_array.cpp
diff --git a/test/message/types.cpp b/test/message/types.cpp
index 8676e25..604996e 100644
--- a/test/message/types.cpp
+++ b/test/message/types.cpp
@@ -1,4 +1,4 @@
-#include <cassert>
+#include <gtest/gtest.h>
#include <sdbusplus/message/types.hpp>
#include <sdbusplus/utility/tuple_to_array.hpp>
@@ -10,31 +10,37 @@
sdbusplus::message::types::type_id<Args...>()).data());
}
-int main()
+TEST(MessageTypes, Integer)
{
+ ASSERT_EQ(dbus_string(1),"i");
+}
- // Check a few simple types.
- assert(dbus_string(1) == "i");
- assert(dbus_string(1.0) == "d");
+TEST(MessageTypes, Double)
+{
+ ASSERT_EQ(dbus_string(1.0), "d");
+}
- // Check a multiple parameter call.
- assert(dbus_string(false, true) == "bb");
- assert(dbus_string(1, 2, 3, true, 1.0) == "iiibd");
+TEST(MessageTypes, MultipleParameter)
+{
+ ASSERT_EQ(dbus_string(false, true), "bb");
+ ASSERT_EQ(dbus_string(1, 2, 3, true, 1.0), "iiibd");
+}
- // Check an l-value and r-value reference.
- {
- std::string a = "a";
- std::string b = "b";
- const char* c = "c";
+TEST(MessageTypes, StringReferences)
+{
+ std::string a = "a";
+ std::string b = "b";
+ const char* c = "c";
- assert(dbus_string(a, std::move(b), c) == "sss");
- }
+ ASSERT_EQ(dbus_string(a, std::move(b), c), "sss");
+}
- // Check object_path and signatures.
- assert(dbus_string(std::string("asdf"),
- sdbusplus::message::object_path("/asdf"),
- sdbusplus::message::signature("sss")) ==
- "sog");
+TEST(MessageTypes, ObjectPath)
+{
+ ASSERT_EQ(dbus_string(sdbusplus::message::object_path("/asdf")), "o");
+}
- return 0;
+TEST(MessageTypes, Signature)
+{
+ ASSERT_EQ(dbus_string(sdbusplus::message::signature("sss")), "g");
}