00001
00002
00003
00004
00005 #include <gtest/gtest.h>
00006
00007
00008 #include <dbw_fca_can/ModuleVersion.h>
00009 using namespace dbw_fca_can;
00010
00011
00012 TEST(ModuleVersion, empty)
00013 {
00014 EXPECT_EQ(0, ModuleVersion().major());
00015 EXPECT_EQ(0, ModuleVersion().minor());
00016 EXPECT_EQ(0, ModuleVersion().build());
00017 EXPECT_FALSE(ModuleVersion().valid());
00018 }
00019
00020
00021 TEST(ModuleVersion, valid)
00022 {
00023
00024 EXPECT_FALSE(ModuleVersion(0,0,0).valid());
00025 EXPECT_TRUE (ModuleVersion(1,0,0).valid());
00026 EXPECT_TRUE (ModuleVersion(0,1,0).valid());
00027 EXPECT_TRUE (ModuleVersion(0,0,1).valid());
00028
00029
00030 for (size_t i = 1; i <= UINT16_MAX; i++) {
00031 EXPECT_TRUE(ModuleVersion(i,0,0).valid()) << i;
00032 EXPECT_TRUE(ModuleVersion(0,i,0).valid()) << i;
00033 EXPECT_TRUE(ModuleVersion(0,0,i).valid()) << i;
00034 EXPECT_TRUE(ModuleVersion(i,i,i).valid()) << i;
00035 }
00036 }
00037
00038
00039 TEST(ModuleVersion, fields)
00040 {
00041 EXPECT_EQ(1, ModuleVersion(1,2,3).major());
00042 EXPECT_EQ(2, ModuleVersion(1,2,3).minor());
00043 EXPECT_EQ(3, ModuleVersion(1,2,3).build());
00044 }
00045
00046
00047 TEST(ModuleVersion, operators)
00048 {
00049 EXPECT_LT(ModuleVersion(1,0,0), ModuleVersion(2,3,4));
00050 EXPECT_LT(ModuleVersion(1,9,9), ModuleVersion(2,3,4));
00051 EXPECT_LE(ModuleVersion(1,9,9), ModuleVersion(2,3,4));
00052 EXPECT_LE(ModuleVersion(2,3,4), ModuleVersion(2,3,4));
00053 EXPECT_GT(ModuleVersion(2,3,4), ModuleVersion(1,0,0));
00054 EXPECT_GT(ModuleVersion(2,3,4), ModuleVersion(1,9,9));
00055 EXPECT_GE(ModuleVersion(2,3,4), ModuleVersion(1,9,9));
00056 EXPECT_GE(ModuleVersion(2,3,4), ModuleVersion(2,3,4));
00057 EXPECT_EQ(ModuleVersion(1,2,3), ModuleVersion(1,2,3));
00058 EXPECT_NE(ModuleVersion(1,2,3), ModuleVersion(3,2,1));
00059 }
00060
00061 int main(int argc, char **argv)
00062 {
00063 testing::InitGoogleTest(&argc, argv);
00064 return RUN_ALL_TESTS();
00065 }
00066