test_dd_double.cpp
Go to the documentation of this file.
1 #include <ros/ros.h>
2 #include <gtest/gtest.h>
4 
5 namespace ddynamic_reconfigure {
6 
10  TEST(DDDoubleTest, constructorTest) { // NOLINT(cert-err58-cpp,modernize-use-equals-delete)
11  DDDouble param1("param1",0,"param1",0.5);
12  DDDouble param2("",0,"",1,10);
13  DDDouble param3("\000",0,"\000", -0, -3.4e100, 43.5e20); // NOLINT(bugprone-string-literal-with-embedded-nul)
14  }
15 
19  TEST(DDDoubleTest, valueTest) { // NOLINT(cert-err58-cpp,modernize-use-equals-delete)
20  DDDouble param("dd_param",0,"dd_param",1);
21  // we won't do any tests on getLevel or getName, as those are implicit.
22  Value v(1.0);
23  ASSERT_TRUE(param.sameType(v));
24  ASSERT_TRUE(param.sameValue(v));
25 
26  v = Value(1);
27  ASSERT_FALSE(param.sameType(v));
28  ASSERT_TRUE(param.sameValue(v));
29 
30  v = Value(2.0);
31  ASSERT_TRUE(param.sameType(v));
32  ASSERT_FALSE(param.sameValue(v));
33 
34  v = Value(2);
35  ASSERT_FALSE(param.sameType(v));
36  ASSERT_FALSE(param.sameValue(v));
37 
38  param.setValue(v);
39  v = Value(3);
40  ASSERT_FALSE(param.sameValue(v)); // makes sure anti-aliasing happens
41 
42  ASSERT_TRUE(param.getValue().getType() == "double");
43  ASSERT_TRUE(param.sameValue(Value(2)));
44  }
45 
46  TEST(DDDoubleTest, streamTest) { // NOLINT(cert-err58-cpp,modernize-use-equals-delete)
47  DDDouble param1("param1",0,"param1",1.0);
48  stringstream stream;
49  stream << param1;
50  ASSERT_EQ(param1.getName() + ":" + param1.getValue().toString(),stream.str());
51  }
52 }
53 
54 
55 int main(int argc, char** argv) {
56  testing::InitGoogleTest(&argc, argv);
57 
58  srand((unsigned int)random());
59 
60  return RUN_ALL_TESTS();
61 }
bool param(const std::string &param_name, T &param_val, const T &default_val)
Value getValue() const
gets the value of this parameter.
int main(int argc, char **argv)
void setValue(Value val)
sets the value of this parameter as this one.
a double implementation of the parameter. This is used to handle double-precision floating point numb...
The Value class is used to wrap all basic data-types (bool,int,double,string) in something generic...
Definition: dd_value.h:29
bool sameValue(Value val)
checks whether or not the value stored in the value object, when converted to the type of the interna...
TEST(DDFullScaleTest, doTest)
A ROS client making sure the server sends the new information.
Definition: dd_client.cpp:16
bool sameType(Value val)
checks whether or not the raw value stored in the value is compatible with the given parameter...
string getType() const
gets the type this value wrapper stores
Definition: dd_value.h:84


ddynamic_reconfigure
Author(s): Noam Dori
autogenerated on Thu May 16 2019 02:46:37