float64_test.cpp
Go to the documentation of this file.
1 #include "ros_lib/ros/msg.h"
2 #include <gtest/gtest.h>
3 
4 
5 class TestFloat64 : public ::testing::Test
6 {
7 public:
8  union
9  {
10  double val;
11  unsigned char buffer[8];
12  };
13 
14  static const double cases[];
15  static const int num_cases;
16 };
17 
18 const double TestFloat64::cases[] =
19 {
20  0.0, 10.0, 15642.1, -50.2, 0.0001, -0.321,
21  123456.789, -987.654321, 3.4e38, -3.4e38,
22 };
23 const int TestFloat64::num_cases = sizeof(TestFloat64::cases) / sizeof(double);
24 
25 
26 TEST_F(TestFloat64, testRoundTrip)
27 {
28  for (int i = 0; i < num_cases; i++)
29  {
30  memset(buffer, 0, sizeof(buffer));
32  EXPECT_FLOAT_EQ(cases[i], val);
33 
34  float ret = 0;
36  EXPECT_FLOAT_EQ(cases[i], ret);
37  }
38 }
39 
40 
41 int main(int argc, char **argv)
42 {
43  testing::InitGoogleTest(&argc, argv);
44  return RUN_ALL_TESTS();
45 }
static int serializeAvrFloat64(unsigned char *outbuffer, const float f)
This tricky function handles promoting a 32bit float to a 64bit double, so that AVR can publish messa...
Definition: msg.h:64
static const double cases[]
static const int num_cases
unsigned char buffer[8]
TEST_F(TestFloat64, testRoundTrip)
int main(int argc, char **argv)
static int deserializeAvrFloat64(const unsigned char *inbuffer, float *f)
This tricky function handles demoting a 64bit double to a 32bit float, so that AVR can understand mes...
Definition: msg.h:102


rosserial_client
Author(s): Michael Ferguson, Adam Stambler
autogenerated on Fri Jun 7 2019 22:02:43