6 # pragma GCC diagnostic ignored "-Wfloat-equal"
9 #include <gtest/gtest.h>
12 #include <root_ns_a/EmptyService.hpp>
13 #include <root_ns_a/EmptyMessage.hpp>
14 #include <root_ns_a/NestedMessage.hpp>
15 #include <root_ns_a/A.hpp>
16 #include <root_ns_a/ReportBackSoldier.hpp>
17 #include <root_ns_b/ServiceWithEmptyRequest.hpp>
18 #include <root_ns_b/ServiceWithEmptyResponse.hpp>
19 #include <root_ns_b/T.hpp>
28 root_ns_b::ServiceWithEmptyRequest::Request req;
29 ASSERT_EQ(1, root_ns_b::ServiceWithEmptyRequest::Request::encode(req, sc_wr));
30 ASSERT_EQ(
"", bs_wr.toString());
32 root_ns_b::ServiceWithEmptyRequest::Response resp;
33 ASSERT_EQ(1, root_ns_b::ServiceWithEmptyRequest::Response::encode(resp, sc_wr));
34 ASSERT_EQ(
"", bs_wr.toString());
36 resp.covariance.push_back(-2);
37 resp.covariance.push_back(65504);
38 root_ns_b::ServiceWithEmptyRequest::Response::encode(resp, sc_wr);
39 ASSERT_EQ(
"00000000 11000000 11111111 01111011", bs_wr.toString());
41 resp.covariance.push_back(42);
42 resp.covariance[0] = 999;
46 ASSERT_EQ(1, root_ns_b::ServiceWithEmptyRequest::Response::decode(resp, sc_rd));
48 ASSERT_EQ(2, resp.covariance.size());
49 ASSERT_EQ(-2, resp.covariance[0]);
50 ASSERT_EQ(65504, resp.covariance[1]);
56 ASSERT_EQ(0xe74617107a34aa9c, root_ns_a::EmptyService::getDataTypeSignature().
get());
57 ASSERT_STREQ(
"root_ns_a.EmptyService", root_ns_a::EmptyService::getDataTypeFullName());
60 ASSERT_EQ(0x99604d7066e0d713, root_ns_a::NestedMessage::getDataTypeSignature().
get());
61 ASSERT_STREQ(
"root_ns_a.NestedMessage", root_ns_a::NestedMessage::getDataTypeFullName());
69 root_ns_a::EmptyService::Request a, b;
74 root_ns_a::NestedMessage c,
d;
85 TEST(Dsdl, CloseComparison)
87 root_ns_a::A first, second;
89 ASSERT_TRUE(first == second);
91 first.vector[1].vector[1] = std::numeric_limits<double>::epsilon();
92 ASSERT_TRUE(first.isClose(second));
93 ASSERT_FALSE(first == second);
95 first.vector[1].vector[1] = std::numeric_limits<float>::epsilon();
96 ASSERT_FALSE(first.isClose(second));
97 ASSERT_FALSE(first == second);