Go to the documentation of this file.00001
00002
00003
00004
00005 #include <gtest/gtest.h>
00006
00007
00008 #include <dbw_mkz_can/sonar_lut.h>
00009 using namespace dbw_mkz_can;
00010
00011
00012 TEST(sonar_lut, sonarMetersFromBits)
00013 {
00014 EXPECT_EQ((float) 0.00, sonarMetersFromBits(0));
00015 EXPECT_EQ((float) 0.30, sonarMetersFromBits(1));
00016 EXPECT_EQ((float) 0.45, sonarMetersFromBits(2));
00017 EXPECT_EQ((float) 0.60, sonarMetersFromBits(3));
00018 EXPECT_EQ((float) 0.75, sonarMetersFromBits(4));
00019 EXPECT_EQ((float) 0.90, sonarMetersFromBits(5));
00020 EXPECT_EQ((float) 1.05, sonarMetersFromBits(6));
00021 EXPECT_EQ((float) 1.20, sonarMetersFromBits(7));
00022 EXPECT_EQ((float) 1.35, sonarMetersFromBits(8));
00023 EXPECT_EQ((float) 1.50, sonarMetersFromBits(9));
00024 EXPECT_EQ((float) 1.65, sonarMetersFromBits(10));
00025 EXPECT_EQ((float) 1.80, sonarMetersFromBits(11));
00026 EXPECT_EQ((float) 1.95, sonarMetersFromBits(12));
00027 EXPECT_EQ((float) 2.10, sonarMetersFromBits(13));
00028 EXPECT_EQ((float) 2.25, sonarMetersFromBits(14));
00029 EXPECT_EQ((float) 2.40, sonarMetersFromBits(15));
00030 EXPECT_EQ((float)15.15, sonarMetersFromBits(100));
00031 }
00032
00033
00034 TEST(sonar_lut, sonarColorFromRange)
00035 {
00036 const uint32_t RED = 0xC0FF0000;
00037 const uint32_t YLW = 0xC0FFFF00;
00038 const uint32_t GRN = 0xC000FF00;
00039
00040 EXPECT_EQ(RED, sonarColorFromRange(-INFINITY));
00041 EXPECT_EQ(RED, sonarColorFromRange(0.00));
00042 EXPECT_EQ(RED, sonarColorFromRange(0.30));
00043 EXPECT_EQ(RED, sonarColorFromRange(0.45));
00044 EXPECT_EQ(RED, sonarColorFromRange(0.60));
00045 EXPECT_EQ(YLW, sonarColorFromRange(0.75));
00046 EXPECT_EQ(YLW, sonarColorFromRange(0.90));
00047 EXPECT_EQ(YLW, sonarColorFromRange(1.05));
00048 EXPECT_EQ(YLW, sonarColorFromRange(1.20));
00049 EXPECT_EQ(GRN, sonarColorFromRange(1.35));
00050 EXPECT_EQ(GRN, sonarColorFromRange(1.50));
00051 EXPECT_EQ(GRN, sonarColorFromRange(INFINITY));
00052 }
00053
00055
00056 int main(int argc, char **argv)
00057 {
00058 testing::InitGoogleTest(&argc, argv);
00059 return RUN_ALL_TESTS();
00060 }
00061