test_dd_double.cpp
Go to the documentation of this file.
00001 #include <ros/ros.h>
00002 #include <gtest/gtest.h>
00003 #include <ddynamic_reconfigure/param/dd_double_param.h>
00004 
00005 namespace ddynamic_reconfigure {
00006 
00010     TEST(DDDoubleTest, constructorTest) { // NOLINT(cert-err58-cpp,modernize-use-equals-delete)
00011         DDDouble param1("param1",0,"param1",0.5);
00012         DDDouble param2("",0,"",1,10);
00013         DDDouble param3("\000",0,"\000", -0, -3.4e100, 43.5e20); // NOLINT(bugprone-string-literal-with-embedded-nul)
00014     }
00015 
00019     TEST(DDDoubleTest, valueTest) { // NOLINT(cert-err58-cpp,modernize-use-equals-delete)
00020         DDDouble param("dd_param",0,"dd_param",1);
00021         // we won't do any tests on getLevel or getName, as those are implicit.
00022         Value v(1.0);
00023         ASSERT_TRUE(param.sameType(v));
00024         ASSERT_TRUE(param.sameValue(v));
00025 
00026         v = Value(1);
00027         ASSERT_FALSE(param.sameType(v));
00028         ASSERT_TRUE(param.sameValue(v));
00029 
00030         v = Value(2.0);
00031         ASSERT_TRUE(param.sameType(v));
00032         ASSERT_FALSE(param.sameValue(v));
00033 
00034         v = Value(2);
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() == "double");
00043         ASSERT_TRUE(param.sameValue(Value(2)));
00044     }
00045 
00046     TEST(DDDoubleTest, streamTest) { // NOLINT(cert-err58-cpp,modernize-use-equals-delete)
00047         DDDouble param1("param1",0,"param1",1.0);
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