33 #include <gtest/gtest.h>
46 nav_msgs::GetMap::Response map_resp;
47 double origin[3] = { 0.0, 0.0, 0.0 };
52 for(
unsigned int i=0; i < map_resp.map.info.width * map_resp.map.info.height; i++)
57 ADD_FAILURE() <<
"Uncaught exception : " <<
"This is OK on OS X";
67 nav_msgs::GetMap::Response map_resp;
68 double origin[3] = { 0.0, 0.0, 0.0 };
73 for(
unsigned int i=0; i < map_resp.map.info.width * map_resp.map.info.height; i++)
78 ADD_FAILURE() <<
"Uncaught exception";
88 nav_msgs::GetMap::Response map_resp;
89 double origin[3] = { 0.0, 0.0, 0.0 };
92 catch(std::runtime_error &e)
99 FAIL() <<
"Uncaught exception";
101 ADD_FAILURE() <<
"Didn't throw exception as expected";
104 std::vector<unsigned int>
countValues(
const nav_msgs::GetMap::Response& map_resp)
106 std::vector<unsigned int> counts(256, 0);
107 for (
unsigned int i = 0; i < map_resp.map.data.size(); i++)
109 unsigned char value =
static_cast<unsigned char>(map_resp.map.data[i]);
117 nav_msgs::GetMap::Response map_resp;
118 double origin[3] = { 0.0, 0.0, 0.0 };
121 std::vector<unsigned int> trinary_counts =
countValues(map_resp);
122 EXPECT_EQ(90u, trinary_counts[100]);
123 EXPECT_EQ(26u, trinary_counts[0]);
124 EXPECT_EQ(140u, trinary_counts[255]);
127 std::vector<unsigned int> scale_counts =
countValues(map_resp);
128 EXPECT_EQ(90u, scale_counts[100]);
129 EXPECT_EQ(26u, scale_counts[0]);
130 unsigned int scaled_values = 0;
131 for (
unsigned int i = 1; i < 100; i++)
133 scaled_values += scale_counts[i];
135 EXPECT_EQ(140u, scaled_values);
138 std::vector<unsigned int> raw_counts =
countValues(map_resp);
139 for (
unsigned int i = 0; i < raw_counts.size(); i++)
141 EXPECT_EQ(1u, raw_counts[i]) << i;
145 int main(
int argc,
char **argv)
147 testing::InitGoogleTest(&argc, argv);
148 return RUN_ALL_TESTS();