10 #include <gtest/gtest.h>
11 #include "../../include/message_bus.hpp"
13 TEST(message_test, test_message_creation) {
14 auto test_subject =
new message(1, make_data<bool>(
true));
15 ASSERT_TRUE(test_subject);
19 TEST(message_test, test_message_get_data) {
20 auto test_subject =
new message(1, make_data<bool>(
true));
21 ASSERT_TRUE(*
static_cast<bool *
>(test_subject->get_data()));
22 delete (test_subject);
25 TEST(message_test, test_message_get_base_data) {
26 auto test_subject =
new message(1, 30,
nullptr);
27 test_subject->base_data1 = 100;
28 test_subject->base_data2 = 150;
30 ASSERT_FALSE(
static_cast<bool>(test_subject->get_data()));
31 ASSERT_EQ(30, test_subject->base_data0);
32 ASSERT_EQ(100, test_subject->base_data1);
33 ASSERT_EQ(150, test_subject->base_data2);
34 delete (test_subject);
37 TEST(message_test, test_message_get_data_and_base_data) {
38 auto test_subject =
new message(1, 30, make_data<bool>(
true));
39 test_subject->base_data1 = 100;
40 test_subject->base_data2 = 150;
42 ASSERT_TRUE(*
static_cast<bool *
>(test_subject->get_data()));
43 ASSERT_EQ(30, test_subject->base_data0);
44 ASSERT_EQ(100, test_subject->base_data1);
45 ASSERT_EQ(150, test_subject->base_data2);
47 delete (test_subject);
50 TEST(message_test, test_message_copy) {
51 auto test_subject =
new message(1, 50, make_data<int>(12));
52 test_subject->base_data1 = 100;
53 test_subject->base_data2 = 150;
55 auto copy = test_subject->make_copy();
56 ASSERT_TRUE(test_subject->get_data());
57 ASSERT_TRUE(copy->get_data());
58 ASSERT_EQ(test_subject->get_data(), copy->get_data());
59 ASSERT_EQ(test_subject->msg_name, copy->msg_name);
60 ASSERT_EQ(test_subject->base_data0, copy->base_data0);
61 ASSERT_EQ(test_subject->base_data1, copy->base_data1);
62 ASSERT_EQ(test_subject->base_data2, copy->base_data2);
64 delete (test_subject);
68 int main(
int argc,
char **argv) {
69 ::testing::InitGoogleTest(&argc, argv);
70 return RUN_ALL_TESTS();
A message object passed around in the message bus. Holds anything created with make_data<>().