Main Page
Namespaces
Classes
Files
File List
File Members
tests
test_module_version.cpp
Go to the documentation of this file.
1
/*********************************************************************
2
* C++ unit test for dbw_fca_can/ModuleVersion.h
3
*********************************************************************/
4
5
#include <gtest/gtest.h>
6
7
// File under test
8
#include <
dbw_fca_can/ModuleVersion.h
>
9
using namespace
dbw_fca_can
;
10
11
// Test empty constructor
12
TEST
(
ModuleVersion
, empty)
13
{
14
EXPECT_EQ(0,
ModuleVersion
().major());
15
EXPECT_EQ(0,
ModuleVersion
().minor());
16
EXPECT_EQ(0,
ModuleVersion
().build());
17
EXPECT_FALSE(
ModuleVersion
().valid());
18
}
19
20
// Test validity
21
TEST
(
ModuleVersion
, valid)
22
{
23
// Test zeros and ones
24
EXPECT_FALSE(
ModuleVersion
(0,0,0).valid());
25
EXPECT_TRUE (
ModuleVersion
(1,0,0).valid());
26
EXPECT_TRUE (
ModuleVersion
(0,1,0).valid());
27
EXPECT_TRUE (
ModuleVersion
(0,0,1).valid());
28
29
// Test all valid values (non-zero)
30
for
(
size_t
i = 1; i <= UINT16_MAX; i++) {
31
EXPECT_TRUE(
ModuleVersion
(i,0,0).valid()) << i;
32
EXPECT_TRUE(
ModuleVersion
(0,i,0).valid()) << i;
33
EXPECT_TRUE(
ModuleVersion
(0,0,i).valid()) << i;
34
EXPECT_TRUE(
ModuleVersion
(i,i,i).valid()) << i;
35
}
36
}
37
38
// Test fields (major,minor,build)
39
TEST
(
ModuleVersion
, fields)
40
{
41
EXPECT_EQ(1,
ModuleVersion
(1,2,3).major());
42
EXPECT_EQ(2,
ModuleVersion
(1,2,3).minor());
43
EXPECT_EQ(3,
ModuleVersion
(1,2,3).build());
44
}
45
46
// Test operators
47
TEST
(
ModuleVersion
, operators)
48
{
49
EXPECT_LT(
ModuleVersion
(1,0,0),
ModuleVersion
(2,3,4));
50
EXPECT_LT(
ModuleVersion
(1,9,9),
ModuleVersion
(2,3,4));
51
EXPECT_LE(
ModuleVersion
(1,9,9),
ModuleVersion
(2,3,4));
52
EXPECT_LE(
ModuleVersion
(2,3,4),
ModuleVersion
(2,3,4));
53
EXPECT_GT(
ModuleVersion
(2,3,4),
ModuleVersion
(1,0,0));
54
EXPECT_GT(
ModuleVersion
(2,3,4),
ModuleVersion
(1,9,9));
55
EXPECT_GE(
ModuleVersion
(2,3,4),
ModuleVersion
(1,9,9));
56
EXPECT_GE(
ModuleVersion
(2,3,4),
ModuleVersion
(2,3,4));
57
EXPECT_EQ(
ModuleVersion
(1,2,3),
ModuleVersion
(1,2,3));
58
EXPECT_NE(
ModuleVersion
(1,2,3),
ModuleVersion
(3,2,1));
59
}
60
61
int
main
(
int
argc,
char
**argv)
62
{
63
testing::InitGoogleTest(&argc, argv);
64
return
RUN_ALL_TESTS();
65
}
66
dbw_fca_can::ModuleVersion
Definition:
ModuleVersion.h:51
main
int main(int argc, char **argv)
Definition:
test_module_version.cpp:61
ModuleVersion.h
TEST
TEST(ModuleVersion, empty)
Definition:
test_module_version.cpp:12
dbw_fca_can
Definition:
dispatch.h:39
dbw_fca_can
Author(s): Kevin Hallenbeck
autogenerated on Wed May 12 2021 02:14:05