GCC Code Coverage Report | |||||||||||||||||||||
|
|||||||||||||||||||||
Line | Branch | Exec | Source |
1 |
#include <cmath> |
||
2 |
|||
3 |
#include "gtest/gtest.h" |
||
4 |
|||
5 |
#include "zserio/ReflectableUtil.h" |
||
6 |
#include "zserio/Reflectable.h" |
||
7 |
#include "zserio/TypeInfo.h" |
||
8 |
|||
9 |
#include "test_object/std_allocator/ReflectableUtilBitmask.h" |
||
10 |
#include "test_object/std_allocator/ReflectableUtilEnum.h" |
||
11 |
#include "test_object/std_allocator/ReflectableUtilUnion.h" |
||
12 |
|||
13 |
using test_object::std_allocator::ReflectableUtilBitmask; |
||
14 |
using test_object::std_allocator::ReflectableUtilEnum; |
||
15 |
using test_object::std_allocator::ReflectableUtilChoice; |
||
16 |
using test_object::std_allocator::ReflectableUtilObject; |
||
17 |
using test_object::std_allocator::ReflectableUtilUnion; |
||
18 |
|||
19 |
namespace zserio |
||
20 |
{ |
||
21 |
|||
22 |
✓✗✓✗ ✓✗✗✓ |
802 |
TEST(ReflectableUtilTest, unequalTypeInfo) |
23 |
{ |
||
24 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_FALSE(ReflectableUtil::equal(ReflectableFactory::getBool(false), |
25 |
ReflectableFactory::getUInt8(13))); |
||
26 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_FALSE(ReflectableUtil::equal(ReflectableFactory::getInt8(0), |
27 |
ReflectableFactory::getInt16(0))); |
||
28 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_FALSE(ReflectableUtil::equal(ReflectableFactory::getInt8(0), |
29 |
ReflectableFactory::getUInt8(0))); |
||
30 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_FALSE(ReflectableUtil::equal(ReflectableFactory::getUInt64(0), |
31 |
ReflectableFactory::getVarSize(0))); |
||
32 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_FALSE(ReflectableUtil::equal(ReflectableFactory::getInt8(0), |
33 |
ReflectableFactory::getFloat32(0.0))); |
||
34 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_FALSE(ReflectableUtil::equal(ReflectableFactory::getFloat16(0.0F), |
35 |
ReflectableFactory::getFloat32(0.0F))); |
||
36 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_FALSE(ReflectableUtil::equal(ReflectableFactory::getString(""), |
37 |
ReflectableFactory::getInt8(0))); |
||
38 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_FALSE(ReflectableUtil::equal(ReflectableFactory::getBitBuffer(BitBuffer()), |
39 |
ReflectableFactory::getString(""))); |
||
40 |
} |
||
41 |
|||
42 |
✓✗✓✗ ✓✗✗✓ |
802 |
TEST(ReflectableUtilTest, equalsNullValues) |
43 |
{ |
||
44 |
✓✗✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_TRUE(ReflectableUtil::equal(nullptr, nullptr)); |
45 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✗✗✓✗ |
1 |
ASSERT_FALSE(ReflectableUtil::equal(ReflectableFactory::getBool(false), nullptr)); |
46 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✗✗✓✗ |
1 |
ASSERT_FALSE(ReflectableUtil::equal(nullptr, ReflectableFactory::getInt8(0))); |
47 |
} |
||
48 |
|||
49 |
✓✗✓✗ ✓✗✗✓ |
802 |
TEST(ReflectableUtilTest, equalBools) |
50 |
{ |
||
51 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_TRUE(ReflectableUtil::equal(ReflectableFactory::getBool(true), ReflectableFactory::getBool(true))); |
52 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_FALSE(ReflectableUtil::equal(ReflectableFactory::getBool(false), |
53 |
ReflectableFactory::getBool(true))); |
||
54 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_FALSE(ReflectableUtil::equal(ReflectableFactory::getBool(true), |
55 |
ReflectableFactory::getBool(false))); |
||
56 |
} |
||
57 |
|||
58 |
✓✗✓✗ ✓✗✗✓ |
802 |
TEST(ReflectableUtilTest, equalSingedIntegrals) |
59 |
{ |
||
60 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_TRUE(ReflectableUtil::equal(ReflectableFactory::getInt8(INT8_MIN), |
61 |
ReflectableFactory::getInt8(INT8_MIN))); |
||
62 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_TRUE(ReflectableUtil::equal(ReflectableFactory::getInt8(INT8_MAX), |
63 |
ReflectableFactory::getInt8(INT8_MAX))); |
||
64 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_FALSE(ReflectableUtil::equal(ReflectableFactory::getInt8(-1), |
65 |
ReflectableFactory::getInt8(0))); |
||
66 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_FALSE(ReflectableUtil::equal(ReflectableFactory::getInt8(INT8_MIN), |
67 |
ReflectableFactory::getInt8(INT8_MAX))); |
||
68 |
|||
69 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_TRUE(ReflectableUtil::equal(ReflectableFactory::getInt16(INT16_MIN), |
70 |
ReflectableFactory::getInt16(INT16_MIN))); |
||
71 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_TRUE(ReflectableUtil::equal(ReflectableFactory::getInt16(INT16_MAX), |
72 |
ReflectableFactory::getInt16(INT16_MAX))); |
||
73 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_FALSE(ReflectableUtil::equal(ReflectableFactory::getInt16(-1), |
74 |
ReflectableFactory::getInt16(0))); |
||
75 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_FALSE(ReflectableUtil::equal(ReflectableFactory::getInt16(INT16_MIN), |
76 |
ReflectableFactory::getInt16(INT16_MAX))); |
||
77 |
|||
78 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_TRUE(ReflectableUtil::equal(ReflectableFactory::getInt32(INT32_MIN), |
79 |
ReflectableFactory::getInt32(INT32_MIN))); |
||
80 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_TRUE(ReflectableUtil::equal(ReflectableFactory::getInt32(INT32_MAX), |
81 |
ReflectableFactory::getInt32(INT32_MAX))); |
||
82 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_FALSE(ReflectableUtil::equal(ReflectableFactory::getInt32(-1), |
83 |
ReflectableFactory::getInt32(0))); |
||
84 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_FALSE(ReflectableUtil::equal(ReflectableFactory::getInt32(INT32_MIN), |
85 |
ReflectableFactory::getInt32(INT32_MAX))); |
||
86 |
|||
87 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_TRUE(ReflectableUtil::equal(ReflectableFactory::getInt64(INT64_MIN), |
88 |
ReflectableFactory::getInt64(INT64_MIN))); |
||
89 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_TRUE(ReflectableUtil::equal(ReflectableFactory::getInt64(INT64_MAX), |
90 |
ReflectableFactory::getInt64(INT64_MAX))); |
||
91 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_FALSE(ReflectableUtil::equal(ReflectableFactory::getInt64(-1), |
92 |
ReflectableFactory::getInt64(0))); |
||
93 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_FALSE(ReflectableUtil::equal(ReflectableFactory::getInt64(INT64_MIN), |
94 |
ReflectableFactory::getInt64(INT64_MAX))); |
||
95 |
} |
||
96 |
|||
97 |
✓✗✓✗ ✓✗✗✓ |
802 |
TEST(ReflectableUtilTest, equalUnsignedIntegrals) |
98 |
{ |
||
99 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_TRUE(ReflectableUtil::equal(ReflectableFactory::getUInt8(0), |
100 |
ReflectableFactory::getUInt8(0))); |
||
101 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_TRUE(ReflectableUtil::equal(ReflectableFactory::getUInt8(UINT8_MAX), |
102 |
ReflectableFactory::getUInt8(UINT8_MAX))); |
||
103 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_FALSE(ReflectableUtil::equal(ReflectableFactory::getUInt8(0), |
104 |
ReflectableFactory::getUInt8(1))); |
||
105 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_FALSE(ReflectableUtil::equal(ReflectableFactory::getUInt8(0), |
106 |
ReflectableFactory::getUInt8(UINT8_MAX))); |
||
107 |
|||
108 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_TRUE(ReflectableUtil::equal(ReflectableFactory::getUInt16(0), |
109 |
ReflectableFactory::getUInt16(0))); |
||
110 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_TRUE(ReflectableUtil::equal(ReflectableFactory::getUInt16(UINT16_MAX), |
111 |
ReflectableFactory::getUInt16(UINT16_MAX))); |
||
112 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_FALSE(ReflectableUtil::equal(ReflectableFactory::getUInt16(0), |
113 |
ReflectableFactory::getUInt16(1))); |
||
114 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_FALSE(ReflectableUtil::equal(ReflectableFactory::getUInt16(0), |
115 |
ReflectableFactory::getUInt16(UINT16_MAX))); |
||
116 |
|||
117 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_TRUE(ReflectableUtil::equal(ReflectableFactory::getUInt32(0), |
118 |
ReflectableFactory::getUInt32(0))); |
||
119 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_TRUE(ReflectableUtil::equal(ReflectableFactory::getUInt32(UINT32_MAX), |
120 |
ReflectableFactory::getUInt32(UINT32_MAX))); |
||
121 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_FALSE(ReflectableUtil::equal(ReflectableFactory::getUInt32(0), |
122 |
ReflectableFactory::getUInt32(1))); |
||
123 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_FALSE(ReflectableUtil::equal(ReflectableFactory::getUInt32(0), |
124 |
ReflectableFactory::getUInt32(UINT32_MAX))); |
||
125 |
|||
126 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_TRUE(ReflectableUtil::equal(ReflectableFactory::getUInt64(0), |
127 |
ReflectableFactory::getUInt64(0))); |
||
128 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_TRUE(ReflectableUtil::equal(ReflectableFactory::getUInt64(UINT64_MAX), |
129 |
ReflectableFactory::getUInt64(UINT64_MAX))); |
||
130 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_FALSE(ReflectableUtil::equal(ReflectableFactory::getUInt64(0), |
131 |
ReflectableFactory::getUInt64(1))); |
||
132 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_FALSE(ReflectableUtil::equal(ReflectableFactory::getUInt64(0), |
133 |
ReflectableFactory::getUInt64(UINT64_MAX))); |
||
134 |
} |
||
135 |
|||
136 |
✓✗✓✗ ✓✗✗✓ |
802 |
TEST(ReflectableUtilTest, equalFloatingPoints) |
137 |
{ |
||
138 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_TRUE(ReflectableUtil::equal(ReflectableFactory::getFloat16(0.0F), |
139 |
ReflectableFactory::getFloat16(0.0F))); |
||
140 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_FALSE(ReflectableUtil::equal(ReflectableFactory::getFloat16(-1.0F), |
141 |
ReflectableFactory::getFloat16(1.0F))); |
||
142 |
|||
143 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_TRUE(ReflectableUtil::equal(ReflectableFactory::getFloat32(0.0F), |
144 |
ReflectableFactory::getFloat32(0.0F))); |
||
145 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_FALSE(ReflectableUtil::equal(ReflectableFactory::getFloat32(-1.0F), |
146 |
ReflectableFactory::getFloat32(1.0F))); |
||
147 |
|||
148 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_TRUE(ReflectableUtil::equal(ReflectableFactory::getFloat64(0.0), |
149 |
ReflectableFactory::getFloat64(0.0))); |
||
150 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_FALSE(ReflectableUtil::equal(ReflectableFactory::getFloat64(-1.0), |
151 |
ReflectableFactory::getFloat64(1.0))); |
||
152 |
|||
153 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_TRUE(ReflectableUtil::equal(ReflectableFactory::getFloat64(std::numeric_limits<double>::epsilon()), |
154 |
ReflectableFactory::getFloat64(std::numeric_limits<double>::epsilon()))); |
||
155 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_TRUE(ReflectableUtil::equal(ReflectableFactory::getFloat64(std::numeric_limits<double>::min()), |
156 |
ReflectableFactory::getFloat64(std::numeric_limits<double>::min()))); |
||
157 |
|||
158 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_TRUE(ReflectableUtil::equal( |
159 |
ReflectableFactory::getFloat64(1.0 + std::numeric_limits<double>::epsilon()), |
||
160 |
ReflectableFactory::getFloat64(1.0))); |
||
161 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_TRUE(ReflectableUtil::equal( |
162 |
ReflectableFactory::getFloat64(std::numeric_limits<double>::denorm_min() * 2), |
||
163 |
ReflectableFactory::getFloat64(std::numeric_limits<double>::denorm_min()))); |
||
164 |
|||
165 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_TRUE(ReflectableUtil::equal(ReflectableFactory::getFloat64(static_cast<double>(NAN)), |
166 |
ReflectableFactory::getFloat64(static_cast<double>(NAN)))); |
||
167 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_TRUE(ReflectableUtil::equal(ReflectableFactory::getFloat64(static_cast<double>(INFINITY)), |
168 |
ReflectableFactory::getFloat64(static_cast<double>(INFINITY)))); |
||
169 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_TRUE(ReflectableUtil::equal(ReflectableFactory::getFloat64(-static_cast<double>(INFINITY)), |
170 |
ReflectableFactory::getFloat64(-static_cast<double>(INFINITY)))); |
||
171 |
|||
172 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_FALSE(ReflectableUtil::equal(ReflectableFactory::getFloat64(0.0), |
173 |
ReflectableFactory::getFloat64(static_cast<double>(INFINITY)))); |
||
174 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_FALSE(ReflectableUtil::equal(ReflectableFactory::getFloat64(static_cast<double>(INFINITY)), |
175 |
ReflectableFactory::getFloat64(0.0))); |
||
176 |
|||
177 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_FALSE(ReflectableUtil::equal(ReflectableFactory::getFloat64(0.0), |
178 |
ReflectableFactory::getFloat64(static_cast<double>(NAN)))); |
||
179 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_FALSE(ReflectableUtil::equal(ReflectableFactory::getFloat64(static_cast<double>(NAN)), |
180 |
ReflectableFactory::getFloat64(0.0))); |
||
181 |
|||
182 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_FALSE(ReflectableUtil::equal(ReflectableFactory::getFloat64(static_cast<double>(NAN)), |
183 |
ReflectableFactory::getFloat64(static_cast<double>(INFINITY)))); |
||
184 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_FALSE(ReflectableUtil::equal(ReflectableFactory::getFloat64(static_cast<double>(INFINITY)), |
185 |
ReflectableFactory::getFloat64(static_cast<double>(NAN)))); |
||
186 |
|||
187 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_FALSE(ReflectableUtil::equal(ReflectableFactory::getFloat64(static_cast<double>(INFINITY)), |
188 |
ReflectableFactory::getFloat64(-static_cast<double>(INFINITY)))); |
||
189 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_FALSE(ReflectableUtil::equal(ReflectableFactory::getFloat64(-static_cast<double>(INFINITY)), |
190 |
ReflectableFactory::getFloat64(static_cast<double>(INFINITY)))); |
||
191 |
} |
||
192 |
|||
193 |
✓✗✓✗ ✓✗✗✓ |
802 |
TEST(ReflectableUtilTest, equalStrings) |
194 |
{ |
||
195 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_TRUE(ReflectableUtil::equal(ReflectableFactory::getString(""), |
196 |
ReflectableFactory::getString(""))); |
||
197 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_TRUE(ReflectableUtil::equal(ReflectableFactory::getString("test"), |
198 |
ReflectableFactory::getString("test"))); |
||
199 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_FALSE(ReflectableUtil::equal(ReflectableFactory::getString(""), |
200 |
ReflectableFactory::getString("a"))); |
||
201 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_FALSE(ReflectableUtil::equal(ReflectableFactory::getString("1"), |
202 |
ReflectableFactory::getString(""))); |
||
203 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_FALSE(ReflectableUtil::equal(ReflectableFactory::getString("test"), |
204 |
ReflectableFactory::getString("test2"))); |
||
205 |
} |
||
206 |
|||
207 |
✓✗✓✗ ✓✗✗✓ |
802 |
TEST(ReflectableUtilTest, equalBitBuffers) |
208 |
{ |
||
209 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_TRUE(ReflectableUtil::equal(ReflectableFactory::getBitBuffer(BitBuffer()), |
210 |
ReflectableFactory::getBitBuffer(BitBuffer()))); |
||
211 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_TRUE(ReflectableUtil::equal(ReflectableFactory::getBitBuffer(BitBuffer({0xAB}, 8)), |
212 |
ReflectableFactory::getBitBuffer(BitBuffer({0xAB}, 8)))); |
||
213 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_FALSE(ReflectableUtil::equal(ReflectableFactory::getBitBuffer(BitBuffer({0xAB}, 8)), |
214 |
ReflectableFactory::getBitBuffer(BitBuffer()))); |
||
215 |
} |
||
216 |
|||
217 |
✓✗✓✗ ✓✗✗✓ |
802 |
TEST(ReflectableUtilTest, equalBytes) |
218 |
{ |
||
219 |
✓✗ | 2 |
vector<uint8_t> bytesData1{{0xCA, 0xFE}}; |
220 |
✓✗✓✗ |
2 |
vector<uint8_t> bytesData2{{0xCA, 0xDE}}; |
221 |
✓✗ | 2 |
vector<uint8_t> bytesEmpty; |
222 |
|||
223 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_TRUE(ReflectableUtil::equal(ReflectableFactory::getBytes(bytesEmpty), |
224 |
ReflectableFactory::getBytes(bytesEmpty))); |
||
225 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_TRUE(ReflectableUtil::equal(ReflectableFactory::getBytes(bytesData1), |
226 |
ReflectableFactory::getBytes(bytesData1))); |
||
227 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_FALSE(ReflectableUtil::equal(ReflectableFactory::getBytes(bytesData1), |
228 |
ReflectableFactory::getBytes(bytesEmpty))); |
||
229 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗✓✗ |
1 |
ASSERT_FALSE(ReflectableUtil::equal(ReflectableFactory::getBytes(bytesData1), |
230 |
ReflectableFactory::getBytes(bytesData2))); |
||
231 |
} |
||
232 |
|||
233 |
✓✗✓✗ ✓✗✗✓ |
802 |
TEST(ReflectableUtilTest, equalEnums) |
234 |
{ |
||
235 |
1 |
const ReflectableUtilEnum oneEnum = ReflectableUtilEnum::ONE; |
|
236 |
1 |
const ReflectableUtilEnum twoEnum = ReflectableUtilEnum::TWO; |
|
237 |
|||
238 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_TRUE(ReflectableUtil::equal(enumReflectable(oneEnum), enumReflectable(oneEnum))); |
239 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_TRUE(ReflectableUtil::equal(enumReflectable(twoEnum), enumReflectable(twoEnum))); |
240 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_FALSE(ReflectableUtil::equal(enumReflectable(oneEnum), enumReflectable(twoEnum))); |
241 |
} |
||
242 |
|||
243 |
✓✗✓✗ ✓✗✗✓ |
802 |
TEST(ReflectableUtilTest, equalBitmasks) |
244 |
{ |
||
245 |
1 |
const ReflectableUtilBitmask readBitmask = ReflectableUtilBitmask::Values::READ; |
|
246 |
1 |
const ReflectableUtilBitmask writeBitmask = ReflectableUtilBitmask::Values::WRITE; |
|
247 |
|||
248 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_TRUE(ReflectableUtil::equal(readBitmask.reflectable(), readBitmask.reflectable())); |
249 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_TRUE(ReflectableUtil::equal(writeBitmask.reflectable(), writeBitmask.reflectable())); |
250 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_FALSE(ReflectableUtil::equal(writeBitmask.reflectable(), readBitmask.reflectable())); |
251 |
} |
||
252 |
|||
253 |
✓✗✓✗ ✓✗✗✓ |
802 |
TEST(ReflectableUtilTest, equalCompounds) |
254 |
{ |
||
255 |
2 |
ReflectableUtilUnion compound1 = ReflectableUtilUnion(); |
|
256 |
✓✗ | 1 |
compound1.setReflectableUtilEnum(ReflectableUtilEnum::ONE); |
257 |
✓✗ | 1 |
compound1.initializeChildren(); |
258 |
|||
259 |
✓✗ | 2 |
ReflectableUtilUnion compound2 = ReflectableUtilUnion(); |
260 |
✓✗ | 1 |
compound2.setReflectableUtilEnum(ReflectableUtilEnum::TWO); // different enum value |
261 |
✓✗ | 1 |
compound2.initializeChildren(); |
262 |
|||
263 |
✓✗ | 2 |
ReflectableUtilUnion compound3 = ReflectableUtilUnion(); |
264 |
✓✗ | 1 |
compound3.setReflectableUtilBitmask(ReflectableUtilBitmask::Values::READ); |
265 |
✓✗ | 1 |
compound3.initializeChildren(); |
266 |
|||
267 |
✓✗ | 2 |
ReflectableUtilUnion compound4 = ReflectableUtilUnion(); |
268 |
✓✗✓✗ |
1 |
compound4.setReflectableUtilObject(ReflectableUtilObject(0, ReflectableUtilChoice())); |
269 |
✓✗ | 1 |
compound4.initializeChildren(); |
270 |
|||
271 |
✓✗ | 2 |
ReflectableUtilUnion compound5 = ReflectableUtilUnion(); |
272 |
✓✗✓✗ |
1 |
compound5.setReflectableUtilObject(ReflectableUtilObject(1, ReflectableUtilChoice())); |
273 |
✓✗✓✗ ✓✗ |
1 |
compound5.getReflectableUtilObject().getReflectableUtilChoice().setArray(std::vector<uint32_t>()); |
274 |
✓✗ | 1 |
compound5.initializeChildren(); |
275 |
|||
276 |
✓✗ | 2 |
ReflectableUtilUnion compound6 = ReflectableUtilUnion(); |
277 |
✓✗✓✗ |
1 |
compound6.setReflectableUtilObject(ReflectableUtilObject(1, ReflectableUtilChoice())); |
278 |
✓✗✓✗ ✓✗✓✗ |
1 |
compound6.getReflectableUtilObject().getReflectableUtilChoice().setArray(std::vector<uint32_t>{{1, 2, 3}}); |
279 |
✓✗ | 1 |
compound6.initializeChildren(); |
280 |
|||
281 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_TRUE(ReflectableUtil::equal(compound1.reflectable(), compound1.reflectable())); |
282 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_TRUE(ReflectableUtil::equal(compound2.reflectable(), compound2.reflectable())); |
283 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_TRUE(ReflectableUtil::equal(compound3.reflectable(), compound3.reflectable())); |
284 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_TRUE(ReflectableUtil::equal(compound4.reflectable(), compound4.reflectable())); |
285 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_TRUE(ReflectableUtil::equal(compound5.reflectable(), compound5.reflectable())); |
286 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_TRUE(ReflectableUtil::equal(compound6.reflectable(), compound6.reflectable())); |
287 |
|||
288 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_FALSE(ReflectableUtil::equal(compound1.reflectable(), compound2.reflectable())); |
289 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_FALSE(ReflectableUtil::equal(compound1.reflectable(), compound3.reflectable())); |
290 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_FALSE(ReflectableUtil::equal(compound1.reflectable(), compound4.reflectable())); |
291 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_FALSE(ReflectableUtil::equal(compound1.reflectable(), compound5.reflectable())); |
292 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_FALSE(ReflectableUtil::equal(compound1.reflectable(), compound6.reflectable())); |
293 |
|||
294 |
// unequal fields in choice |
||
295 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_FALSE(ReflectableUtil::equal(compound5.reflectable(), compound6.reflectable())); |
296 |
|||
297 |
// unequal parameters in choice |
||
298 |
✓✗ | 2 |
ReflectableUtilChoice choice1; |
299 |
✓✗ | 1 |
choice1.initialize(0); |
300 |
✓✗ | 2 |
ReflectableUtilChoice choice2; |
301 |
✓✗ | 1 |
choice2.initialize(3); |
302 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_FALSE(ReflectableUtil::equal(choice1.reflectable(), choice2.reflectable())); |
303 |
|||
304 |
// array and not array |
||
305 |
✓✗✓✗ |
2 |
std::vector<ReflectableUtilUnion> compoundArray(1); |
306 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_FALSE(ReflectableUtil::equal(compound1.reflectable(), |
307 |
ReflectableFactory::getCompoundArray(compoundArray))); |
||
308 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗✓✗ |
1 |
ASSERT_FALSE(ReflectableUtil::equal(ReflectableFactory::getCompoundArray(compoundArray), |
309 |
compound1.reflectable())); |
||
310 |
} |
||
311 |
|||
312 |
✓✗✓✗ ✓✗✗✓ |
802 |
TEST(ReflectableUtilTest, equalArrays) |
313 |
{ |
||
314 |
✓✗ | 2 |
std::vector<uint32_t> array1 = {1, 2, 3}; |
315 |
✓✗✓✗ |
2 |
std::vector<uint32_t> array2 = {1, 2, 4}; |
316 |
✓✗✓✗ |
2 |
std::vector<uint32_t> array3 = {1, 2}; |
317 |
|||
318 |
✓✗✓✗ |
2 |
auto array1Reflectable = ReflectableFactory::getUInt32Array(array1); |
319 |
✓✗✓✗ |
2 |
auto array2Reflectable = ReflectableFactory::getUInt32Array(array2); |
320 |
✓✗✓✗ |
2 |
auto array3Reflectable = ReflectableFactory::getUInt32Array(array3); |
321 |
|||
322 |
✓✗✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_TRUE(ReflectableUtil::equal(array1Reflectable, array1Reflectable)); |
323 |
✓✗✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_TRUE(ReflectableUtil::equal(array2Reflectable, array2Reflectable)); |
324 |
✓✗✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_TRUE(ReflectableUtil::equal(array3Reflectable, array3Reflectable)); |
325 |
|||
326 |
✓✗✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_FALSE(ReflectableUtil::equal(array1Reflectable, array2Reflectable)); |
327 |
✓✗✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗✓✗ |
1 |
ASSERT_FALSE(ReflectableUtil::equal(array1Reflectable, array3Reflectable)); |
328 |
} |
||
329 |
|||
330 |
✓✗✓✗ ✓✗✗✓ |
802 |
TEST(ReflectableUtilTest, equalWrong) |
331 |
{ |
||
332 |
using allocator_type = ::std::allocator<uint8_t>; |
||
333 |
✗✓ | 2 |
class WrongTypeInfo : public TypeInfoBase<allocator_type> |
334 |
{ |
||
335 |
public: |
||
336 |
2 |
WrongTypeInfo(StringView schemaName, SchemaType schemaType, CppType cppType) : |
|
337 |
2 |
TypeInfoBase(schemaName, schemaType, cppType) |
|
338 |
2 |
{} |
|
339 |
}; |
||
340 |
|||
341 |
const WrongTypeInfo wrongTypeInfo = { |
||
342 |
✓✗ | 2 |
"int<>"_sv, SchemaType::DYNAMIC_SIGNED_BITFIELD, CppType::PUBSUB}; |
343 |
const WrongTypeInfo wrongTypeInfoDiffName = { |
||
344 |
✓✗✓✗ |
2 |
"diff"_sv, SchemaType::DYNAMIC_SIGNED_BITFIELD, CppType::PUBSUB}; |
345 |
|||
346 |
✗✓ | 2 |
class Reflectable : public ::zserio::ReflectableAllocatorHolderBase<allocator_type> |
347 |
{ |
||
348 |
public: |
||
349 |
2 |
explicit Reflectable(const TypeInfoBase<allocator_type>& typeInfo, const allocator_type& allocator) : |
|
350 |
2 |
::zserio::ReflectableAllocatorHolderBase<allocator_type>(typeInfo, allocator) |
|
351 |
2 |
{} |
|
352 |
}; |
||
353 |
|||
354 |
auto wrongReflectable = std::allocate_shared<Reflectable>(allocator_type(), wrongTypeInfo, |
||
355 |
✓✗✓✗ |
2 |
allocator_type()); |
356 |
auto wrongReflectableDiffName = std::allocate_shared<Reflectable>(allocator_type(), wrongTypeInfoDiffName, |
||
357 |
✓✗✓✗ |
2 |
allocator_type()); |
358 |
|||
359 |
✓✗✓✗ ✓✗✗✓ ✗✓✗✗ ✗✗✗✗ ✗✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✗✗ ✗✗✗✗ ✗✗✗✗ ✗ |
2 |
ASSERT_THROW(ReflectableUtil::equal(wrongReflectable, wrongReflectable), CppRuntimeException); |
360 |
✓✗✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗✓✗ |
1 |
ASSERT_FALSE(ReflectableUtil::equal(wrongReflectable, wrongReflectableDiffName)); |
361 |
} |
||
362 |
|||
363 |
✓✗✓✗ ✓✗✗✓ |
802 |
TEST(ReflectableUtilTest, getValueArithmeticType) |
364 |
{ |
||
365 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✗✗✓✗ |
1 |
ASSERT_FALSE(ReflectableUtil::getValue<bool>(ReflectableFactory::getBool(false))); |
366 |
|||
367 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✓✗ |
1 |
ASSERT_EQ(1, ReflectableUtil::getValue<uint8_t>(ReflectableFactory::getUInt8(1))); |
368 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✓✗ |
1 |
ASSERT_EQ(12, ReflectableUtil::getValue<uint16_t>(ReflectableFactory::getUInt16(12))); |
369 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✓✗ |
1 |
ASSERT_EQ(123, ReflectableUtil::getValue<uint32_t>(ReflectableFactory::getUInt32(123))); |
370 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✓✗ |
1 |
ASSERT_EQ(1234, ReflectableUtil::getValue<uint64_t>(ReflectableFactory::getUInt64(1234))); |
371 |
|||
372 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✓✗ |
1 |
ASSERT_EQ(-1, ReflectableUtil::getValue<int8_t>(ReflectableFactory::getInt8(-1))); |
373 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✓✗ |
1 |
ASSERT_EQ(-12, ReflectableUtil::getValue<int16_t>(ReflectableFactory::getInt16(-12))); |
374 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✓✗ |
1 |
ASSERT_EQ(-123, ReflectableUtil::getValue<int32_t>(ReflectableFactory::getInt32(-123))); |
375 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✓✗ |
1 |
ASSERT_EQ(-1234, ReflectableUtil::getValue<int64_t>(ReflectableFactory::getInt64(-1234))); |
376 |
|||
377 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✓✗ |
1 |
ASSERT_EQ(12, ReflectableUtil::getValue<uint16_t>(ReflectableFactory::getVarUInt16(12))); |
378 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✓✗ |
1 |
ASSERT_EQ(123, ReflectableUtil::getValue<uint32_t>(ReflectableFactory::getVarUInt32(123))); |
379 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✓✗ |
1 |
ASSERT_EQ(1234, ReflectableUtil::getValue<uint64_t>(ReflectableFactory::getVarUInt64(1234))); |
380 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✓✗ |
1 |
ASSERT_EQ(UINT64_MAX, ReflectableUtil::getValue<uint64_t>(ReflectableFactory::getVarUInt(UINT64_MAX))); |
381 |
|||
382 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✓✗ |
1 |
ASSERT_EQ(-12, ReflectableUtil::getValue<int16_t>(ReflectableFactory::getVarInt16(-12))); |
383 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✓✗ |
1 |
ASSERT_EQ(-123, ReflectableUtil::getValue<int32_t>(ReflectableFactory::getVarInt32(-123))); |
384 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✓✗ |
1 |
ASSERT_EQ(-1234, ReflectableUtil::getValue<int64_t>(ReflectableFactory::getVarInt64(-1234))); |
385 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✓✗ |
1 |
ASSERT_EQ(INT64_MIN, ReflectableUtil::getValue<int64_t>(ReflectableFactory::getVarInt(INT64_MIN))); |
386 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✓✗ |
1 |
ASSERT_EQ(INT64_MAX, ReflectableUtil::getValue<int64_t>(ReflectableFactory::getVarInt(INT64_MAX))); |
387 |
|||
388 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✓✗ |
1 |
ASSERT_EQ(0, ReflectableUtil::getValue<uint32_t>(ReflectableFactory::getVarSize(0))); |
389 |
|||
390 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✓✗ |
1 |
ASSERT_EQ(1.0F, ReflectableUtil::getValue<float>(ReflectableFactory::getFloat16(1.0F))); |
391 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✓✗ |
1 |
ASSERT_EQ(3.5F, ReflectableUtil::getValue<float>(ReflectableFactory::getFloat32(3.5F))); |
392 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✓✗ |
1 |
ASSERT_EQ(9.875, ReflectableUtil::getValue<double>(ReflectableFactory::getFloat64(9.875))); |
393 |
} |
||
394 |
|||
395 |
✓✗✓✗ ✓✗✗✓ |
802 |
TEST(ReflectableUtilTest, getValueString) |
396 |
{ |
||
397 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✓✗ |
1 |
ASSERT_EQ("test"_sv, ReflectableUtil::getValue<StringView>(ReflectableFactory::getString("test"))); |
398 |
} |
||
399 |
|||
400 |
✓✗✓✗ ✓✗✗✓ |
802 |
TEST(ReflectableUtilTest, getValueBitBuffer) |
401 |
{ |
||
402 |
2 |
const BitBuffer bitBuffer; |
|
403 |
✓✗✓✗ |
2 |
auto reflectable = ReflectableFactory::getBitBuffer(bitBuffer); |
404 |
✓✗ | 1 |
const BitBuffer& bitBufferRef = ReflectableUtil::getValue<BitBuffer>(reflectable); |
405 |
✓✗✗✓ ✗✗✗✗ ✗✗✓✗ ✓✗ |
1 |
ASSERT_EQ(bitBuffer, bitBufferRef); |
406 |
} |
||
407 |
|||
408 |
✓✗✓✗ ✓✗✗✓ |
802 |
TEST(ReflectableUtilTest, getValueEnum) |
409 |
{ |
||
410 |
1 |
ReflectableUtilEnum reflectableUtilEnum = ReflectableUtilEnum::ONE; |
|
411 |
✓✗ | 2 |
auto reflectable = enumReflectable(reflectableUtilEnum); |
412 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗✓✗ |
1 |
ASSERT_EQ(reflectableUtilEnum, ReflectableUtil::getValue<ReflectableUtilEnum>(reflectable)); |
413 |
} |
||
414 |
|||
415 |
✓✗✓✗ ✓✗✗✓ |
802 |
TEST(ReflectableUtilTest, getValueBitmask) |
416 |
{ |
||
417 |
1 |
ReflectableUtilBitmask reflectableUtilBitmask = ReflectableUtilBitmask::Values::READ; |
|
418 |
✓✗ | 2 |
auto reflectable = reflectableUtilBitmask.reflectable(); |
419 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗✓✗ |
1 |
ASSERT_EQ(reflectableUtilBitmask, ReflectableUtil::getValue<ReflectableUtilBitmask>(reflectable)); |
420 |
} |
||
421 |
|||
422 |
✓✗✓✗ ✓✗✗✓ |
802 |
TEST(ReflectableUtilTest, getValueCompound) |
423 |
{ |
||
424 |
2 |
ReflectableUtilUnion reflectableUtilUnion; |
|
425 |
✓✗✓✗ |
2 |
auto reflectable = reflectableUtilUnion.reflectable(); |
426 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_EQ(&reflectableUtilUnion, &ReflectableUtil::getValue<ReflectableUtilUnion>(reflectable)); |
427 |
|||
428 |
ReflectableUtilUnion& reflectableUtilUnionRef = |
||
429 |
✓✗ | 1 |
ReflectableUtil::getValue<ReflectableUtilUnion>(reflectable); |
430 |
✓✗ | 1 |
reflectableUtilUnionRef.setReflectableUtilBitmask(ReflectableUtilBitmask::Values::WRITE); |
431 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_EQ(ReflectableUtilBitmask::Values::WRITE, reflectableUtilUnion.getReflectableUtilBitmask()); |
432 |
|||
433 |
✓✗✓✗ |
2 |
auto constReflectable = static_cast<const ReflectableUtilUnion&>(reflectableUtilUnion).reflectable(); |
434 |
const ReflectableUtilUnion& reflectableUtilUnionConstRef = |
||
435 |
✓✗ | 1 |
ReflectableUtil::getValue<ReflectableUtilUnion>(constReflectable); |
436 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_EQ(ReflectableUtilBitmask::Values::WRITE, reflectableUtilUnionConstRef.getReflectableUtilBitmask()); |
437 |
✓✗✗✓ ✗✗✗✗ ✗✗✓✗ ✓✗ |
1 |
ASSERT_EQ(&reflectableUtilUnion, &reflectableUtilUnionConstRef); |
438 |
} |
||
439 |
|||
440 |
✓✗✓✗ ✓✗✗✓ |
802 |
TEST(ReflectableUtilTest, getValueBuiltinArray) |
441 |
{ |
||
442 |
✓✗ | 2 |
std::vector<uint8_t> uint8Array{{1, 2, 3}}; |
443 |
✓✗✓✗ |
2 |
auto reflectable = ReflectableFactory::getUInt8Array(uint8Array); |
444 |
✓✗ | 1 |
std::vector<uint8_t>& uint8ArrayRef = ReflectableUtil::getValue<std::vector<uint8_t>>(reflectable); |
445 |
✓✗✗✓ ✗✗✗✗ ✗✗✓✗ |
1 |
ASSERT_EQ(&uint8Array, &uint8ArrayRef); |
446 |
|||
447 |
auto constReflectable = ReflectableFactory::getUInt8Array( |
||
448 |
✓✗✓✗ |
2 |
static_cast<const std::vector<uint8_t>&>(uint8Array)); |
449 |
const std::vector<uint8_t>& uint8ArrayConstRef = |
||
450 |
✓✗ | 1 |
ReflectableUtil::getValue<std::vector<uint8_t>>(constReflectable); |
451 |
✓✗✗✓ ✗✗✗✗ ✗✗✓✗ ✓✗ |
1 |
ASSERT_EQ(&uint8Array, &uint8ArrayConstRef); |
452 |
} |
||
453 |
|||
454 |
✓✗✓✗ ✓✗✗✓ |
802 |
TEST(ReflectableUtilTest, getValueCompoundArray) |
455 |
{ |
||
456 |
2 |
std::vector<ReflectableUtilUnion> reflectableUtilUnionArray; |
|
457 |
✓✗✓✗ |
2 |
auto reflectable = ReflectableFactory::getCompoundArray(reflectableUtilUnionArray); |
458 |
std::vector<ReflectableUtilUnion>& reflectableUtilUnionArrayRef = |
||
459 |
✓✗ | 1 |
ReflectableUtil::getValue<std::vector<ReflectableUtilUnion>>(reflectable); |
460 |
✓✗✗✓ ✗✗✗✗ ✗✗✓✗ ✓✗ |
1 |
ASSERT_EQ(&reflectableUtilUnionArray, &reflectableUtilUnionArrayRef); |
461 |
} |
||
462 |
|||
463 |
✓✗✓✗ |
2394 |
} // namespace zserio |
Generated by: GCOVR (Version 4.2) |