test_dd_int.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(DDIntTest, constructorTest) { // NOLINT(cert-err58-cpp,modernize-use-equals-delete)
11  DDInt param1("param1",0,"param1",1);
12  DDInt param2("",0,"",1,100);
13  DDInt param3("\000",(unsigned int)-1,"param1", 1, -100, -10); // NOLINT(bugprone-string-literal-with-embedded-nul)
14  }
15 
19  TEST(DDIntTest, valueTest) { // NOLINT(cert-err58-cpp,modernize-use-equals-delete)
20  DDInt param("dd_param",0,"param1",1);
21  // we won't do any tests on getLevel or getName, as those are implicit.
22  Value v(1);
23  ASSERT_TRUE(param.sameType(v));
24  ASSERT_TRUE(param.sameValue(v));
25 
26  v = Value(1.0);
27  ASSERT_FALSE(param.sameType(v));
28  ASSERT_TRUE(param.sameValue(v));
29 
30  v = Value(2);
31  ASSERT_TRUE(param.sameType(v));
32  ASSERT_FALSE(param.sameValue(v));
33 
34  v = Value(2.0);
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() == "int");
43  ASSERT_TRUE(param.sameValue(Value(2)));
44  }
45 
46  TEST(DDIntTest, streamTest) { // NOLINT(cert-err58-cpp,modernize-use-equals-delete)
47  DDInt param1("param1",0,"param1",1);
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)
bool sameType(Value val)
checks whether or not the raw value stored in the value is compatible with the given parameter...
Value getValue() const
gets the value of this parameter.
bool sameValue(Value val)
checks whether or not the value stored in the value object, when converted to the type of the interna...
int main(int argc, char **argv)
Definition: test_dd_int.cpp:55
The Value class is used to wrap all basic data-types (bool,int,double,string) in something generic...
Definition: dd_value.h:29
void setValue(Value val)
sets the value of this parameter as this one.
TEST(DDFullScaleTest, doTest)
A ROS client making sure the server sends the new information.
Definition: dd_client.cpp:16
string getType() const
gets the type this value wrapper stores
Definition: dd_value.h:84
an integer implementation of the parameter. This is used to 32 bit signed integral numbers...
Definition: dd_int_param.h:17


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