test_dd_string.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(DDStringTest, constructorTest) { // NOLINT(cert-err58-cpp,modernize-use-equals-delete)
11  DDString param1("param1",0,"param1","Hello World");
12  DDString param2("",0,"","");
13  DDString param3("\000",0,"\000","\000"); // NOLINT(bugprone-string-literal-with-embedded-nul)
14  }
15 
19  TEST(DDStringTest, valueTest) { // NOLINT(cert-err58-cpp,modernize-use-equals-delete)
20  DDString 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);
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);
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() == "string");
43  ASSERT_TRUE(param.sameValue(Value("2")));
44  }
45 
46  TEST(DDStringTest, streamTest) { // NOLINT(cert-err58-cpp,modernize-use-equals-delete)
47  DDString param1("param1",0,"param1","Hello World");
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.
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)
bool sameType(Value val)
checks whether or not the raw value stored in the value is compatible with the given parameter...
The Value class is used to wrap all basic data-types (bool,int,double,string) in something generic...
Definition: dd_value.h:29
TEST(DDFullScaleTest, doTest)
A ROS client making sure the server sends the new information.
Definition: dd_client.cpp:16
a string implementation of the parameter. This is used to handle strings of characters of variable le...
void setValue(Value val)
sets the value of this parameter as this one.
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