test_dd_int.cpp
Go to the documentation of this file.
00001 #include <ros/ros.h>
00002 #include <gtest/gtest.h>
00003 #include <ddynamic_reconfigure/param/dd_int_param.h>
00004 
00005 namespace ddynamic_reconfigure {
00006 
00010     TEST(DDIntTest, constructorTest) { // NOLINT(cert-err58-cpp,modernize-use-equals-delete)
00011         DDInt param1("param1",0,"param1",1);
00012         DDInt param2("",0,"",1,100);
00013         DDInt param3("\000",(unsigned int)-1,"param1", 1, -100, -10); // NOLINT(bugprone-string-literal-with-embedded-nul)
00014     }
00015 
00019     TEST(DDIntTest, valueTest) { // NOLINT(cert-err58-cpp,modernize-use-equals-delete)
00020         DDInt param("dd_param",0,"param1",1);
00021         // we won't do any tests on getLevel or getName, as those are implicit.
00022         Value v(1);
00023         ASSERT_TRUE(param.sameType(v));
00024         ASSERT_TRUE(param.sameValue(v));
00025 
00026         v = Value(1.0);
00027         ASSERT_FALSE(param.sameType(v));
00028         ASSERT_TRUE(param.sameValue(v));
00029 
00030         v = Value(2);
00031         ASSERT_TRUE(param.sameType(v));
00032         ASSERT_FALSE(param.sameValue(v));
00033 
00034         v = Value(2.0);
00035         ASSERT_FALSE(param.sameType(v));
00036         ASSERT_FALSE(param.sameValue(v));
00037 
00038         param.setValue(v);
00039         v = Value(3);
00040         ASSERT_FALSE(param.sameValue(v)); // makes sure anti-aliasing happens
00041 
00042         ASSERT_TRUE(param.getValue().getType() == "int");
00043         ASSERT_TRUE(param.sameValue(Value(2)));
00044     }
00045 
00046     TEST(DDIntTest, streamTest) { // NOLINT(cert-err58-cpp,modernize-use-equals-delete)
00047         DDInt param1("param1",0,"param1",1);
00048         stringstream stream;
00049         stream << param1;
00050         ASSERT_EQ(param1.getName() + ":" + param1.getValue().toString(),stream.str());
00051     }
00052 }
00053 
00054 
00055 int main(int argc, char** argv) {
00056     testing::InitGoogleTest(&argc, argv);
00057 
00058     srand((unsigned int)random());
00059 
00060     return RUN_ALL_TESTS();
00061 }


ddynamic_reconfigure
Author(s): Noam Dori
autogenerated on Wed May 15 2019 04:39:27