test_platform_version.cpp
Go to the documentation of this file.
1 /*********************************************************************
2  * C++ unit test for dbw_fca_can/PlatformVersion.h
3  *********************************************************************/
4 
5 #include <gtest/gtest.h>
6 
7 // File under test
9 using namespace dbw_fca_can;
10 
11 // Test empty constructor
13 {
14  EXPECT_EQ((Platform)0, PlatformVersion().p);
15  EXPECT_EQ( (Module)0, PlatformVersion().m);
16  EXPECT_EQ(ModuleVersion(), PlatformVersion().v);
17 }
18 
19 // Test that fields are populated by each constructor
20 TEST(PlatformVersion, constructor)
21 {
22  EXPECT_EQ((Platform)1, PlatformVersion((Platform)1, (Module)2, ModuleVersion(3,4,5)).p);
23  EXPECT_EQ((Module)2, PlatformVersion((Platform)1, (Module)2, ModuleVersion(3,4,5)).m);
24  EXPECT_EQ(ModuleVersion(3,4,5), PlatformVersion((Platform)1, (Module)2, ModuleVersion(3,4,5)).v);
25  EXPECT_EQ((Platform)1, PlatformVersion((Platform)1, (Module)2, 3, 4, 5).p);
26  EXPECT_EQ((Module)2, PlatformVersion((Platform)1, (Module)2, 3, 4, 5).m);
27  EXPECT_EQ(ModuleVersion(3,4,5), PlatformVersion((Platform)1, (Module)2, 3, 4, 5).v);
28 }
29 
30 // Test operators
31 TEST(ModuleVersion, operators)
32 {
33  const Platform x = (Platform)1; const Module y = (Module)2;
34  const Platform X = (Platform)3; const Module Y = (Module)3;
35 
36  // Compare PlatformVersion with PlatformVersion
37  EXPECT_FALSE(PlatformVersion(x,y,1,1,1) < PlatformVersion(x,y,1,1,1));
38  EXPECT_TRUE (PlatformVersion(x,y,1,1,1) < PlatformVersion(x,y,9,9,9));
39  EXPECT_FALSE(PlatformVersion(x,y,1,1,1) < PlatformVersion(X,y,9,9,9));
40  EXPECT_FALSE(PlatformVersion(x,y,1,1,1) < PlatformVersion(x,Y,9,9,9));
41  EXPECT_FALSE(PlatformVersion(x,y,9,9,9) <= PlatformVersion(x,y,1,1,1));
42  EXPECT_TRUE (PlatformVersion(x,y,1,1,1) <= PlatformVersion(x,y,1,1,1));
43  EXPECT_TRUE (PlatformVersion(x,y,1,1,1) <= PlatformVersion(x,y,9,9,9));
44  EXPECT_FALSE(PlatformVersion(x,y,1,1,1) <= PlatformVersion(X,y,9,9,9));
45  EXPECT_FALSE(PlatformVersion(x,y,1,1,1) <= PlatformVersion(x,Y,9,9,9));
46  EXPECT_FALSE(PlatformVersion(x,y,1,1,1) > PlatformVersion(x,y,9,9,9));
47  EXPECT_TRUE (PlatformVersion(x,y,9,9,9) > PlatformVersion(x,y,1,1,1));
48  EXPECT_FALSE(PlatformVersion(x,y,9,9,9) > PlatformVersion(X,y,1,1,1));
49  EXPECT_FALSE(PlatformVersion(x,y,9,9,9) > PlatformVersion(x,Y,1,1,1));
50  EXPECT_FALSE(PlatformVersion(x,y,1,1,1) >= PlatformVersion(x,y,9,9,9));
51  EXPECT_TRUE (PlatformVersion(x,y,1,1,1) >= PlatformVersion(x,y,1,1,1));
52  EXPECT_TRUE (PlatformVersion(x,y,9,9,9) >= PlatformVersion(x,y,1,1,1));
53  EXPECT_FALSE(PlatformVersion(x,y,9,9,9) >= PlatformVersion(X,y,1,1,1));
54  EXPECT_FALSE(PlatformVersion(x,y,9,9,9) >= PlatformVersion(x,Y,1,1,1));
55  EXPECT_FALSE(PlatformVersion(x,y,1,1,1) == PlatformVersion(x,y,9,9,9));
56  EXPECT_TRUE (PlatformVersion(x,y,1,1,1) == PlatformVersion(x,y,1,1,1));
57  EXPECT_FALSE(PlatformVersion(x,y,1,1,1) == PlatformVersion(X,y,1,1,1));
58  EXPECT_FALSE(PlatformVersion(x,y,1,1,1) == PlatformVersion(x,Y,1,1,1));
59  EXPECT_FALSE(PlatformVersion(x,y,1,1,1) != PlatformVersion(x,y,1,1,1));
60  EXPECT_TRUE (PlatformVersion(x,y,1,1,1) != PlatformVersion(x,y,9,9,9));
61  EXPECT_FALSE(PlatformVersion(x,y,1,1,1) != PlatformVersion(X,y,9,9,9));
62  EXPECT_FALSE(PlatformVersion(x,y,1,1,1) != PlatformVersion(x,Y,9,9,9));
63 
64  // Compare PlatformVersion with ModuleVersion
65  EXPECT_FALSE(PlatformVersion(x,y,1,1,1) < ModuleVersion(1,1,1));
66  EXPECT_TRUE (PlatformVersion(x,y,1,1,1) < ModuleVersion(9,9,9));
67  EXPECT_FALSE(PlatformVersion(x,y,9,9,9) <= ModuleVersion(1,1,1));
68  EXPECT_TRUE (PlatformVersion(x,y,1,1,1) <= ModuleVersion(1,1,1));
69  EXPECT_TRUE (PlatformVersion(x,y,1,1,1) <= ModuleVersion(9,9,9));
70  EXPECT_FALSE(PlatformVersion(x,y,1,1,1) > ModuleVersion(9,9,9));
71  EXPECT_TRUE (PlatformVersion(x,y,9,9,9) > ModuleVersion(1,1,1));
72  EXPECT_FALSE(PlatformVersion(x,y,1,1,1) >= ModuleVersion(9,9,9));
73  EXPECT_TRUE (PlatformVersion(x,y,1,1,1) >= ModuleVersion(1,1,1));
74  EXPECT_TRUE (PlatformVersion(x,y,9,9,9) >= ModuleVersion(1,1,1));
75  EXPECT_FALSE(PlatformVersion(x,y,1,1,1) == ModuleVersion(9,9,9));
76  EXPECT_TRUE (PlatformVersion(x,y,1,1,1) == ModuleVersion(1,1,1));
77  EXPECT_FALSE(PlatformVersion(x,y,1,1,1) != ModuleVersion(1,1,1));
78  EXPECT_TRUE (PlatformVersion(x,y,1,1,1) != ModuleVersion(9,9,9));
79 }
80 
81 // Test platformToString()
83 {
84  EXPECT_STREQ("FORD_CD4", platformToString(P_FORD_CD4));
85  EXPECT_STREQ("FORD_P5", platformToString(P_FORD_P5));
86  EXPECT_STREQ("FORD_C1", platformToString(P_FORD_C1));
87  EXPECT_STREQ("FORD_T6", platformToString(P_FORD_T6));
88  EXPECT_STREQ("FORD_U6", platformToString(P_FORD_U6));
89  EXPECT_STREQ("FORD_CD5", platformToString(P_FORD_CD5));
90  EXPECT_STREQ("FCA_RU", platformToString(P_FCA_RU));
91  EXPECT_STREQ("FCA_WK2", platformToString(P_FCA_WK2));
92  EXPECT_STREQ("POLARIS_GEM", platformToString(P_POLARIS_GEM));
93  EXPECT_STREQ("POLARIS_RZR", platformToString(P_POLARIS_RZR));
94  for (size_t i = 0x90; i <= UINT8_MAX; i++) {
95  EXPECT_STREQ("UNKNOWN", platformToString((Platform)i)) << "i = " << i;
96  }
97 }
98 
99 // Test moduleToString()
101 {
102  EXPECT_STREQ("BPEC ", moduleToString(M_BPEC));
103  EXPECT_STREQ("TPEC ", moduleToString(M_TPEC));
104  EXPECT_STREQ("STEER", moduleToString(M_STEER));
105  EXPECT_STREQ("SHIFT", moduleToString(M_SHIFT));
106  EXPECT_STREQ("ABS ", moduleToString(M_ABS));
107  EXPECT_STREQ("BOO ", moduleToString(M_BOO));
108  EXPECT_STREQ("EPS ", moduleToString(M_EPS));
109  EXPECT_STREQ("UNKNOWN", moduleToString((Module)0));
110  for (size_t i = 8; i <= UINT8_MAX; i++) {
111  EXPECT_STREQ("UNKNOWN", moduleToString((Module)i)) << "i = " << i;
112  }
113 }
114 
115 int main(int argc, char **argv)
116 {
117  testing::InitGoogleTest(&argc, argv);
118  return RUN_ALL_TESTS();
119 }
120 
TEST(PlatformVersion, empty)
int main(int argc, char **argv)
static const char * platformToString(Platform x)
TFSIMD_FORCE_INLINE const tfScalar & y() const
static const char * moduleToString(Module x)
TFSIMD_FORCE_INLINE const tfScalar & x() const


dbw_fca_can
Author(s): Kevin Hallenbeck
autogenerated on Wed May 12 2021 02:14:05