00001
00002
00003
00004
00005 #include <gtest/gtest.h>
00006
00007
00008 #include <dbw_fca_can/PlatformVersion.h>
00009 using namespace dbw_fca_can;
00010
00011
00012 TEST(PlatformVersion, empty)
00013 {
00014 EXPECT_EQ((Platform)0, PlatformVersion().p);
00015 EXPECT_EQ( (Module)0, PlatformVersion().m);
00016 EXPECT_EQ(ModuleVersion(), PlatformVersion().v);
00017 }
00018
00019
00020 TEST(PlatformVersion, constructor)
00021 {
00022 EXPECT_EQ((Platform)1, PlatformVersion((Platform)1, (Module)2, ModuleVersion(3,4,5)).p);
00023 EXPECT_EQ((Module)2, PlatformVersion((Platform)1, (Module)2, ModuleVersion(3,4,5)).m);
00024 EXPECT_EQ(ModuleVersion(3,4,5), PlatformVersion((Platform)1, (Module)2, ModuleVersion(3,4,5)).v);
00025 EXPECT_EQ((Platform)1, PlatformVersion((Platform)1, (Module)2, 3, 4, 5).p);
00026 EXPECT_EQ((Module)2, PlatformVersion((Platform)1, (Module)2, 3, 4, 5).m);
00027 EXPECT_EQ(ModuleVersion(3,4,5), PlatformVersion((Platform)1, (Module)2, 3, 4, 5).v);
00028 }
00029
00030
00031 TEST(ModuleVersion, operators)
00032 {
00033 const Platform x = (Platform)1; const Module y = (Module)2;
00034 const Platform X = (Platform)3; const Module Y = (Module)3;
00035
00036
00037 EXPECT_FALSE(PlatformVersion(x,y,1,1,1) < PlatformVersion(x,y,1,1,1));
00038 EXPECT_TRUE (PlatformVersion(x,y,1,1,1) < PlatformVersion(x,y,9,9,9));
00039 EXPECT_FALSE(PlatformVersion(x,y,1,1,1) < PlatformVersion(X,y,9,9,9));
00040 EXPECT_FALSE(PlatformVersion(x,y,1,1,1) < PlatformVersion(x,Y,9,9,9));
00041 EXPECT_FALSE(PlatformVersion(x,y,9,9,9) <= PlatformVersion(x,y,1,1,1));
00042 EXPECT_TRUE (PlatformVersion(x,y,1,1,1) <= PlatformVersion(x,y,1,1,1));
00043 EXPECT_TRUE (PlatformVersion(x,y,1,1,1) <= PlatformVersion(x,y,9,9,9));
00044 EXPECT_FALSE(PlatformVersion(x,y,1,1,1) <= PlatformVersion(X,y,9,9,9));
00045 EXPECT_FALSE(PlatformVersion(x,y,1,1,1) <= PlatformVersion(x,Y,9,9,9));
00046 EXPECT_FALSE(PlatformVersion(x,y,1,1,1) > PlatformVersion(x,y,9,9,9));
00047 EXPECT_TRUE (PlatformVersion(x,y,9,9,9) > PlatformVersion(x,y,1,1,1));
00048 EXPECT_FALSE(PlatformVersion(x,y,9,9,9) > PlatformVersion(X,y,1,1,1));
00049 EXPECT_FALSE(PlatformVersion(x,y,9,9,9) > PlatformVersion(x,Y,1,1,1));
00050 EXPECT_FALSE(PlatformVersion(x,y,1,1,1) >= PlatformVersion(x,y,9,9,9));
00051 EXPECT_TRUE (PlatformVersion(x,y,1,1,1) >= PlatformVersion(x,y,1,1,1));
00052 EXPECT_TRUE (PlatformVersion(x,y,9,9,9) >= PlatformVersion(x,y,1,1,1));
00053 EXPECT_FALSE(PlatformVersion(x,y,9,9,9) >= PlatformVersion(X,y,1,1,1));
00054 EXPECT_FALSE(PlatformVersion(x,y,9,9,9) >= PlatformVersion(x,Y,1,1,1));
00055 EXPECT_FALSE(PlatformVersion(x,y,1,1,1) == PlatformVersion(x,y,9,9,9));
00056 EXPECT_TRUE (PlatformVersion(x,y,1,1,1) == PlatformVersion(x,y,1,1,1));
00057 EXPECT_FALSE(PlatformVersion(x,y,1,1,1) == PlatformVersion(X,y,1,1,1));
00058 EXPECT_FALSE(PlatformVersion(x,y,1,1,1) == PlatformVersion(x,Y,1,1,1));
00059 EXPECT_FALSE(PlatformVersion(x,y,1,1,1) != PlatformVersion(x,y,1,1,1));
00060 EXPECT_TRUE (PlatformVersion(x,y,1,1,1) != PlatformVersion(x,y,9,9,9));
00061 EXPECT_FALSE(PlatformVersion(x,y,1,1,1) != PlatformVersion(X,y,9,9,9));
00062 EXPECT_FALSE(PlatformVersion(x,y,1,1,1) != PlatformVersion(x,Y,9,9,9));
00063
00064
00065 EXPECT_FALSE(PlatformVersion(x,y,1,1,1) < ModuleVersion(1,1,1));
00066 EXPECT_TRUE (PlatformVersion(x,y,1,1,1) < ModuleVersion(9,9,9));
00067 EXPECT_FALSE(PlatformVersion(x,y,9,9,9) <= ModuleVersion(1,1,1));
00068 EXPECT_TRUE (PlatformVersion(x,y,1,1,1) <= ModuleVersion(1,1,1));
00069 EXPECT_TRUE (PlatformVersion(x,y,1,1,1) <= ModuleVersion(9,9,9));
00070 EXPECT_FALSE(PlatformVersion(x,y,1,1,1) > ModuleVersion(9,9,9));
00071 EXPECT_TRUE (PlatformVersion(x,y,9,9,9) > ModuleVersion(1,1,1));
00072 EXPECT_FALSE(PlatformVersion(x,y,1,1,1) >= ModuleVersion(9,9,9));
00073 EXPECT_TRUE (PlatformVersion(x,y,1,1,1) >= ModuleVersion(1,1,1));
00074 EXPECT_TRUE (PlatformVersion(x,y,9,9,9) >= ModuleVersion(1,1,1));
00075 EXPECT_FALSE(PlatformVersion(x,y,1,1,1) == ModuleVersion(9,9,9));
00076 EXPECT_TRUE (PlatformVersion(x,y,1,1,1) == ModuleVersion(1,1,1));
00077 EXPECT_FALSE(PlatformVersion(x,y,1,1,1) != ModuleVersion(1,1,1));
00078 EXPECT_TRUE (PlatformVersion(x,y,1,1,1) != ModuleVersion(9,9,9));
00079 }
00080
00081
00082 TEST(ModuleVersion, platformToString)
00083 {
00084 EXPECT_STREQ("FORD_CD4", platformToString(P_FORD_CD4));
00085 EXPECT_STREQ("FORD_P5", platformToString(P_FORD_P5));
00086 EXPECT_STREQ("FORD_C1", platformToString(P_FORD_C1));
00087 EXPECT_STREQ("FCA_RU", platformToString(P_FCA_RU));
00088 EXPECT_STREQ("FCA_WK2", platformToString(P_FCA_WK2));
00089 for (size_t i = 0x20; i <= UINT8_MAX; i++) {
00090 EXPECT_STREQ("UNKNOWN", platformToString((Platform)i)) << "i = " << i;
00091 }
00092 }
00093
00094
00095 TEST(ModuleVersion, moduleToString)
00096 {
00097 EXPECT_STREQ("BPEC ", moduleToString(M_BPEC));
00098 EXPECT_STREQ("TPEC ", moduleToString(M_TPEC));
00099 EXPECT_STREQ("STEER", moduleToString(M_STEER));
00100 EXPECT_STREQ("SHIFT", moduleToString(M_SHIFT));
00101 EXPECT_STREQ("ABS ", moduleToString(M_ABS));
00102 EXPECT_STREQ("BOO ", moduleToString(M_BOO));
00103 EXPECT_STREQ("EPS ", moduleToString(M_EPS));
00104 EXPECT_STREQ("UNKNOWN", moduleToString((Module)0));
00105 for (size_t i = 8; i <= UINT8_MAX; i++) {
00106 EXPECT_STREQ("UNKNOWN", moduleToString((Module)i)) << "i = " << i;
00107 }
00108 }
00109
00110 int main(int argc, char **argv)
00111 {
00112 testing::InitGoogleTest(&argc, argv);
00113 return RUN_ALL_TESTS();
00114 }
00115