GCC Code Coverage Report | |||||||||||||||||||||
|
|||||||||||||||||||||
Line | Branch | Exec | Source |
1 |
#include <sstream> |
||
2 |
#include <array> |
||
3 |
|||
4 |
#include "gtest/gtest.h" |
||
5 |
|||
6 |
#include "zserio/CppRuntimeException.h" |
||
7 |
#include "zserio/StringView.h" |
||
8 |
#include "zserio/DebugStringUtil.h" |
||
9 |
#include "zserio/Reflectable.h" |
||
10 |
#include "zserio/pmr/PolymorphicAllocator.h" |
||
11 |
|||
12 |
#include "test_object/std_allocator/DebugStringObject.h" |
||
13 |
#include "test_object/std_allocator/DebugStringParamObject.h" |
||
14 |
#include "test_object/polymorphic_allocator/DebugStringObject.h" |
||
15 |
#include "test_object/polymorphic_allocator/DebugStringParamObject.h" |
||
16 |
|||
17 |
using StdDebugStringObject = test_object::std_allocator::DebugStringObject; |
||
18 |
using StdDebugStringParamObject = test_object::std_allocator::DebugStringParamObject; |
||
19 |
using PmrDebugStringObject = test_object::polymorphic_allocator::DebugStringObject; |
||
20 |
using PmrDebugStringParamObject = test_object::polymorphic_allocator::DebugStringParamObject; |
||
21 |
|||
22 |
using std_alloc = std::allocator<uint8_t>; |
||
23 |
using pmr_alloc = zserio::pmr::PropagatingPolymorphicAllocator<uint8_t>; |
||
24 |
|||
25 |
namespace zserio |
||
26 |
{ |
||
27 |
|||
28 |
✓✗✓✗ ✓✗✗✓ |
802 |
TEST(DebugStringUtilTest, toJsonStreamDefault) |
29 |
{ |
||
30 |
✓✗ | 2 |
std::ostringstream os; |
31 |
✓✗ | 2 |
StdDebugStringObject debugStringObject; |
32 |
✓✗ | 1 |
toJsonStream(debugStringObject, os); |
33 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗✓✗ |
1 |
ASSERT_EQ("{\n \"text\": \"test\"\n}", os.str()); |
34 |
} |
||
35 |
|||
36 |
✓✗✓✗ ✓✗✗✓ |
802 |
TEST(DebugStringUtilTest, toJsonStreamDefaultWithAlloc) |
37 |
{ |
||
38 |
✓✗ | 2 |
std::ostringstream os; |
39 |
✓✗ | 2 |
const StdDebugStringObject debugStringObject; |
40 |
✓✗ | 1 |
toJsonStream(debugStringObject, os, std_alloc()); |
41 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗✓✗ |
1 |
ASSERT_EQ("{\n \"text\": \"test\"\n}", os.str()); |
42 |
} |
||
43 |
|||
44 |
✓✗✓✗ ✓✗✗✓ |
802 |
TEST(DebugStringUtilTest, toJsonStreamDefaultWithPolymorphicAlloc) |
45 |
{ |
||
46 |
✓✗ | 2 |
std::ostringstream os; |
47 |
✓✗ | 2 |
const PmrDebugStringObject debugStringObject; |
48 |
✓✗ | 1 |
toJsonStream(debugStringObject, os, pmr_alloc()); |
49 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗✓✗ |
1 |
ASSERT_EQ("{\n \"text\": \"test\"\n}", os.str()); |
50 |
} |
||
51 |
|||
52 |
✓✗✓✗ ✓✗✗✓ |
802 |
TEST(DebugStringUtilTest, toJsonStreamIndent2) |
53 |
{ |
||
54 |
✓✗ | 2 |
std::ostringstream os; |
55 |
✓✗ | 2 |
const StdDebugStringObject debugStringObject; |
56 |
✓✗ | 1 |
toJsonStream(debugStringObject, os, 2); |
57 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗✓✗ |
1 |
ASSERT_EQ("{\n \"text\": \"test\"\n}", os.str()); |
58 |
} |
||
59 |
|||
60 |
✓✗✓✗ ✓✗✗✓ |
802 |
TEST(DebugStringUtilTest, toJsonStreamIndent2WithAlloc) |
61 |
{ |
||
62 |
✓✗ | 2 |
std::ostringstream os; |
63 |
✓✗ | 2 |
const StdDebugStringObject debugStringObject; |
64 |
✓✗ | 1 |
toJsonStream(debugStringObject, os, 2, std_alloc()); |
65 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗✓✗ |
1 |
ASSERT_EQ("{\n \"text\": \"test\"\n}", os.str()); |
66 |
} |
||
67 |
|||
68 |
✓✗✓✗ ✓✗✗✓ |
802 |
TEST(DebugStringUtilTest, toJsonStreamIndent2WithPolymorphicAlloc) |
69 |
{ |
||
70 |
✓✗ | 2 |
std::ostringstream os; |
71 |
✓✗ | 2 |
const PmrDebugStringObject debugStringObject; |
72 |
✓✗ | 1 |
toJsonStream(debugStringObject, os, 2, pmr_alloc()); |
73 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗✓✗ |
1 |
ASSERT_EQ("{\n \"text\": \"test\"\n}", os.str()); |
74 |
} |
||
75 |
|||
76 |
✓✗✓✗ ✓✗✗✓ |
802 |
TEST(DebugStringUtilTest, toJsonStreamFilter) |
77 |
{ |
||
78 |
✓✗ | 2 |
std::ostringstream os; |
79 |
✓✗ | 2 |
const StdDebugStringObject debugStringObject; |
80 |
✓✗ | 1 |
toJsonStream(debugStringObject, os, DepthWalkFilter(0)); |
81 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗✓✗ |
1 |
ASSERT_EQ("{\n}", os.str()); |
82 |
} |
||
83 |
|||
84 |
✓✗✓✗ ✓✗✗✓ |
802 |
TEST(DebugStringUtilTest, toJsonStreamFilterWithAlloc) |
85 |
{ |
||
86 |
✓✗ | 2 |
std::ostringstream os; |
87 |
✓✗ | 2 |
const StdDebugStringObject debugStringObject; |
88 |
✓✗ | 1 |
toJsonStream(debugStringObject, os, DefaultWalkFilter(), std_alloc()); |
89 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗✓✗ |
1 |
ASSERT_EQ("{\n \"text\": \"test\"\n}", os.str()); |
90 |
} |
||
91 |
|||
92 |
✓✗✓✗ ✓✗✗✓ |
802 |
TEST(DebugStringUtilTest, toJsonStreamFilterWithPolymorphicAlloc) |
93 |
{ |
||
94 |
✓✗ | 2 |
std::ostringstream os; |
95 |
✓✗ | 2 |
const PmrDebugStringObject debugStringObject; |
96 |
2 |
toJsonStream(debugStringObject, os, BasicDefaultWalkFilter<pmr_alloc>(), |
|
97 |
✓✗ | 1 |
pmr_alloc()); |
98 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗✓✗ |
1 |
ASSERT_EQ("{\n \"text\": \"test\"\n}", os.str()); |
99 |
} |
||
100 |
|||
101 |
✓✗✓✗ ✓✗✗✓ |
802 |
TEST(DebugStringUtilTest, toJsonStreamIndent2Filter) |
102 |
{ |
||
103 |
✓✗ | 2 |
std::ostringstream os; |
104 |
✓✗ | 2 |
const StdDebugStringObject debugStringObject; |
105 |
✓✗ | 1 |
toJsonStream(debugStringObject, os, 2, DefaultWalkFilter()); |
106 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗✓✗ |
1 |
ASSERT_EQ("{\n \"text\": \"test\"\n}", os.str()); |
107 |
} |
||
108 |
|||
109 |
✓✗✓✗ ✓✗✗✓ |
802 |
TEST(DebugStringUtilTest, toJsonStreamIndent2FilterWithAlloc) |
110 |
{ |
||
111 |
✓✗ | 2 |
std::ostringstream os; |
112 |
✓✗ | 2 |
const StdDebugStringObject debugStringObject; |
113 |
✓✗ | 1 |
toJsonStream(debugStringObject, os, 2, DepthWalkFilter(0), std_alloc()); |
114 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗✓✗ |
1 |
ASSERT_EQ("{\n}", os.str()); |
115 |
} |
||
116 |
|||
117 |
✓✗✓✗ ✓✗✗✓ |
802 |
TEST(DebugStringUtilTest, toJsonStreamIndent2FilterWithPolymorphicAlloc) |
118 |
{ |
||
119 |
✓✗ | 2 |
std::ostringstream os; |
120 |
✓✗ | 2 |
const PmrDebugStringObject debugStringObject; |
121 |
2 |
toJsonStream(debugStringObject, os, 2, BasicDepthWalkFilter<pmr_alloc>(0), |
|
122 |
✓✗ | 1 |
pmr_alloc()); |
123 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗✓✗ |
1 |
ASSERT_EQ("{\n}", os.str()); |
124 |
} |
||
125 |
|||
126 |
✓✗✓✗ ✓✗✗✓ |
802 |
TEST(DebugStringUtilTest, toJsonStringDefault) |
127 |
{ |
||
128 |
2 |
const StdDebugStringObject debugStringObject; |
|
129 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗✓✗ |
1 |
ASSERT_EQ("{\n \"text\": \"test\"\n}", toJsonString(debugStringObject)); |
130 |
} |
||
131 |
|||
132 |
✓✗✓✗ ✓✗✗✓ |
802 |
TEST(DebugStringUtilTest, toJsonStringDefaultWithAlloc) |
133 |
{ |
||
134 |
2 |
const StdDebugStringObject debugStringObject; |
|
135 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗✓✗ |
1 |
ASSERT_EQ("{\n \"text\": \"test\"\n}", toJsonString(debugStringObject, std_alloc())); |
136 |
} |
||
137 |
|||
138 |
✓✗✓✗ ✓✗✗✓ |
802 |
TEST(DebugStringUtilTest, toJsonStringDefaultWithPolymorphicAlloc) |
139 |
{ |
||
140 |
2 |
const PmrDebugStringObject debugStringObject; |
|
141 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗✓✗ |
1 |
ASSERT_EQ("{\n \"text\": \"test\"\n}", toJsonString(debugStringObject, pmr_alloc())); |
142 |
} |
||
143 |
|||
144 |
✓✗✓✗ ✓✗✗✓ |
802 |
TEST(DebugStringUtilTest, toJsonStringIndent2) |
145 |
{ |
||
146 |
2 |
const StdDebugStringObject debugStringObject; |
|
147 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗✓✗ |
1 |
ASSERT_EQ("{\n \"text\": \"test\"\n}", toJsonString(debugStringObject, 2)); |
148 |
} |
||
149 |
|||
150 |
✓✗✓✗ ✓✗✗✓ |
802 |
TEST(DebugStringUtilTest, toJsonStringIndent2WithAlloc) |
151 |
{ |
||
152 |
2 |
const StdDebugStringObject debugStringObject; |
|
153 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗✓✗ |
1 |
ASSERT_EQ("{\n \"text\": \"test\"\n}", toJsonString(debugStringObject, 2, std_alloc())); |
154 |
} |
||
155 |
|||
156 |
✓✗✓✗ ✓✗✗✓ |
802 |
TEST(DebugStringUtilTest, toJsonStringIndent2WithPolymorphicAlloc) |
157 |
{ |
||
158 |
2 |
const PmrDebugStringObject debugStringObject; |
|
159 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗✓✗ |
1 |
ASSERT_EQ("{\n \"text\": \"test\"\n}", |
160 |
toJsonString(debugStringObject, 2, pmr_alloc())); |
||
161 |
} |
||
162 |
|||
163 |
✓✗✓✗ ✓✗✗✓ |
802 |
TEST(DebugStringUtilTest, toJsonStringFilter) |
164 |
{ |
||
165 |
2 |
const StdDebugStringObject debugStringObject; |
|
166 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗✓✗ |
1 |
ASSERT_EQ("{\n \"text\": \"test\"\n}", toJsonString(debugStringObject, DefaultWalkFilter())); |
167 |
} |
||
168 |
|||
169 |
✓✗✓✗ ✓✗✗✓ |
802 |
TEST(DebugStringUtilTest, toJsonStringFilterWithAlloc) |
170 |
{ |
||
171 |
2 |
const StdDebugStringObject debugStringObject; |
|
172 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗✓✗ |
1 |
ASSERT_EQ("{\n \"text\": \"test\"\n}", |
173 |
toJsonString(debugStringObject, DefaultWalkFilter(), std_alloc())); |
||
174 |
} |
||
175 |
|||
176 |
✓✗✓✗ ✓✗✗✓ |
802 |
TEST(DebugStringUtilTest, toJsonStringFilterWithPolymorphicAlloc) |
177 |
{ |
||
178 |
2 |
const PmrDebugStringObject debugStringObject; |
|
179 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗✓✗ |
1 |
ASSERT_EQ("{\n \"text\": \"test\"\n}", |
180 |
toJsonString(debugStringObject, BasicDefaultWalkFilter<pmr_alloc>(), |
||
181 |
pmr_alloc())); |
||
182 |
} |
||
183 |
|||
184 |
✓✗✓✗ ✓✗✗✓ |
802 |
TEST(DebugStringUtilTest, toJsonStringIndent2Filter) |
185 |
{ |
||
186 |
2 |
const StdDebugStringObject debugStringObject; |
|
187 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗✓✗ |
1 |
ASSERT_EQ("{\n}", toJsonString(debugStringObject, 2, DepthWalkFilter(0))); |
188 |
} |
||
189 |
|||
190 |
✓✗✓✗ ✓✗✗✓ |
802 |
TEST(DebugStringUtilTest, toJsonStringIndent2FilterWithAlloc) |
191 |
{ |
||
192 |
2 |
const StdDebugStringObject debugStringObject; |
|
193 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗✓✗ |
1 |
ASSERT_EQ("{\n \"text\": \"test\"\n}", |
194 |
toJsonString(debugStringObject, 2, DefaultWalkFilter(), std_alloc())); |
||
195 |
} |
||
196 |
|||
197 |
✓✗✓✗ ✓✗✗✓ |
802 |
TEST(DebugStringUtilTest, toJsonStringIndent2FilterWithPolymorphicAlloc) |
198 |
{ |
||
199 |
2 |
const PmrDebugStringObject debugStringObject; |
|
200 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗✓✗ |
1 |
ASSERT_EQ("{\n \"text\": \"test\"\n}", |
201 |
toJsonString(debugStringObject, 2, BasicDefaultWalkFilter<pmr_alloc>(), |
||
202 |
pmr_alloc())); |
||
203 |
} |
||
204 |
|||
205 |
✓✗✓✗ ✓✗✗✓ |
802 |
TEST(DebugStringUtilTest, toJsonFileDefault) |
206 |
{ |
||
207 |
2 |
const StdDebugStringObject debugStringObject; |
|
208 |
✓✗✓✗ |
2 |
const std::string fileName = "DebugStringUtilTest_toJsonFileDefault.json"; |
209 |
✓✗ | 1 |
toJsonFile(debugStringObject, fileName); |
210 |
✓✗✓✗ ✓✗✓✗ ✗✓✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✗✗✗✗ ✗✗✗✗ ✗✗✗ |
2 |
ASSERT_THROW(toJsonFile(debugStringObject, ""), CppRuntimeException); |
211 |
|||
212 |
✓✗✓✗ |
2 |
std::ifstream is(fileName.c_str()); |
213 |
✓✗✓✗ |
2 |
std::stringstream ss; |
214 |
✓✗✓✗ |
1 |
ss << is.rdbuf(); |
215 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗✓✗ |
1 |
ASSERT_EQ("{\n \"text\": \"test\"\n}", ss.str()); |
216 |
} |
||
217 |
|||
218 |
✓✗✓✗ ✓✗✗✓ |
802 |
TEST(DebugStringUtilTest, toJsonFileDefaultWithAlloc) |
219 |
{ |
||
220 |
2 |
const StdDebugStringObject debugStringObject; |
|
221 |
✓✗✓✗ |
2 |
const std::string fileName = "DebugStringUtilTest_toJsonFileDefaultWithAlloc.json"; |
222 |
✓✗ | 1 |
toJsonFile(debugStringObject, fileName, std_alloc()); |
223 |
|||
224 |
✓✗✓✗ |
2 |
std::ifstream is(fileName.c_str()); |
225 |
✓✗✓✗ |
2 |
std::stringstream ss; |
226 |
✓✗✓✗ |
1 |
ss << is.rdbuf(); |
227 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗✓✗ |
1 |
ASSERT_EQ("{\n \"text\": \"test\"\n}", ss.str()); |
228 |
} |
||
229 |
|||
230 |
✓✗✓✗ ✓✗✗✓ |
802 |
TEST(DebugStringUtilTest, toJsonFileDefaultWithPolymorphicAlloc) |
231 |
{ |
||
232 |
2 |
const PmrDebugStringObject debugStringObject; |
|
233 |
✓✗✓✗ |
2 |
const string<pmr_alloc> fileName = "DebugStringUtilTest_toJsonFileDefaultWithPolymorphicAlloc.json"; |
234 |
✓✗ | 1 |
toJsonFile(debugStringObject, fileName, pmr_alloc()); |
235 |
|||
236 |
✓✗✓✗ |
2 |
std::ifstream is(fileName.c_str()); |
237 |
✓✗✓✗ |
2 |
std::stringstream ss; |
238 |
✓✗✓✗ |
1 |
ss << is.rdbuf(); |
239 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗✓✗ |
1 |
ASSERT_EQ("{\n \"text\": \"test\"\n}", ss.str()); |
240 |
} |
||
241 |
|||
242 |
✓✗✓✗ ✓✗✗✓ |
802 |
TEST(DebugStringUtilTest, toJsonFileIndent2) |
243 |
{ |
||
244 |
2 |
const StdDebugStringObject debugStringObject; |
|
245 |
✓✗✓✗ |
2 |
const std::string fileName = "DebugStringUtilTest_toJsonFileIndent2.json"; |
246 |
✓✗ | 1 |
toJsonFile(debugStringObject, fileName, 2); |
247 |
|||
248 |
✓✗✓✗ |
2 |
std::ifstream is(fileName.c_str()); |
249 |
✓✗✓✗ |
2 |
std::stringstream ss; |
250 |
✓✗✓✗ |
1 |
ss << is.rdbuf(); |
251 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗✓✗ |
1 |
ASSERT_EQ("{\n \"text\": \"test\"\n}", ss.str()); |
252 |
} |
||
253 |
|||
254 |
✓✗✓✗ ✓✗✗✓ |
802 |
TEST(DebugStringUtilTest, toJsonFileIndent2WithAlloc) |
255 |
{ |
||
256 |
2 |
const StdDebugStringObject debugStringObject; |
|
257 |
✓✗✓✗ |
2 |
const std::string fileName = "DebugStringUtilTest_toJsonFileIndent2WithAlloc.json"; |
258 |
✓✗ | 1 |
toJsonFile(debugStringObject, fileName, 2, std_alloc()); |
259 |
|||
260 |
✓✗✓✗ |
2 |
std::ifstream is(fileName.c_str()); |
261 |
✓✗✓✗ |
2 |
std::stringstream ss; |
262 |
✓✗✓✗ |
1 |
ss << is.rdbuf(); |
263 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗✓✗ |
1 |
ASSERT_EQ("{\n \"text\": \"test\"\n}", ss.str()); |
264 |
} |
||
265 |
|||
266 |
✓✗✓✗ ✓✗✗✓ |
802 |
TEST(DebugStringUtilTest, toJsonFileIndent2WithPolymorphicAlloc) |
267 |
{ |
||
268 |
2 |
const PmrDebugStringObject debugStringObject; |
|
269 |
✓✗✓✗ |
2 |
const string<pmr_alloc> fileName = "DebugStringUtilTest_toJsonFileIndent2WithPolymorphicAlloc.json"; |
270 |
✓✗ | 1 |
toJsonFile(debugStringObject, fileName, 2, pmr_alloc()); |
271 |
|||
272 |
✓✗✓✗ |
2 |
std::ifstream is(fileName.c_str()); |
273 |
✓✗✓✗ |
2 |
std::stringstream ss; |
274 |
✓✗✓✗ |
1 |
ss << is.rdbuf(); |
275 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗✓✗ |
1 |
ASSERT_EQ("{\n \"text\": \"test\"\n}", ss.str()); |
276 |
} |
||
277 |
|||
278 |
✓✗✓✗ ✓✗✗✓ |
802 |
TEST(DebugStringUtilTest, toJsonFileFilter) |
279 |
{ |
||
280 |
2 |
const StdDebugStringObject debugStringObject; |
|
281 |
✓✗✓✗ |
2 |
const std::string fileName = "DebugStringUtilTest_toJsonFileFilter.json"; |
282 |
✓✗ | 1 |
toJsonFile(debugStringObject, fileName, DefaultWalkFilter()); |
283 |
|||
284 |
✓✗✓✗ |
2 |
std::ifstream is(fileName.c_str()); |
285 |
✓✗✓✗ |
2 |
std::stringstream ss; |
286 |
✓✗✓✗ |
1 |
ss << is.rdbuf(); |
287 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗✓✗ |
1 |
ASSERT_EQ("{\n \"text\": \"test\"\n}", ss.str()); |
288 |
} |
||
289 |
|||
290 |
✓✗✓✗ ✓✗✗✓ |
802 |
TEST(DebugStringUtilTest, toJsonFileFilterWithAlloc) |
291 |
{ |
||
292 |
2 |
const StdDebugStringObject debugStringObject; |
|
293 |
✓✗ | 2 |
DefaultWalkFilter defaultWalkFilter; |
294 |
✓✗✓✗ |
2 |
const std::string fileName = "DebugStringUtilTest_toJsonFileFilterWithAlloc.json"; |
295 |
✓✗ | 1 |
toJsonFile(debugStringObject, fileName, defaultWalkFilter, std_alloc()); |
296 |
|||
297 |
✓✗✓✗ |
2 |
std::ifstream is(fileName.c_str()); |
298 |
✓✗✓✗ |
2 |
std::stringstream ss; |
299 |
✓✗✓✗ |
1 |
ss << is.rdbuf(); |
300 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗✓✗ |
1 |
ASSERT_EQ("{\n \"text\": \"test\"\n}", ss.str()); |
301 |
} |
||
302 |
|||
303 |
✓✗✓✗ ✓✗✗✓ |
802 |
TEST(DebugStringUtilTest, toJsonFileFilterWithPolymorphicAlloc) |
304 |
{ |
||
305 |
2 |
const PmrDebugStringObject debugStringObject; |
|
306 |
✓✗ | 2 |
BasicDefaultWalkFilter<pmr_alloc> defaultWalkFilter; |
307 |
✓✗✓✗ |
2 |
const string<pmr_alloc> fileName = "DebugStringUtilTest_toJsonFileFilterWithPolymorphicAlloc.json"; |
308 |
✓✗ | 1 |
toJsonFile(debugStringObject, fileName, defaultWalkFilter, pmr_alloc()); |
309 |
|||
310 |
✓✗✓✗ |
2 |
std::ifstream is(fileName.c_str()); |
311 |
✓✗✓✗ |
2 |
std::stringstream ss; |
312 |
✓✗✓✗ |
1 |
ss << is.rdbuf(); |
313 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗✓✗ |
1 |
ASSERT_EQ("{\n \"text\": \"test\"\n}", ss.str()); |
314 |
} |
||
315 |
|||
316 |
✓✗✓✗ ✓✗✗✓ |
802 |
TEST(DebugStringUtilTest, toJsonFileIndent2Filter) |
317 |
{ |
||
318 |
2 |
const StdDebugStringObject debugStringObject; |
|
319 |
✓✗ | 2 |
DepthWalkFilter depthWalkFilter(0); |
320 |
✓✗✓✗ |
2 |
const std::string fileName = "DebugStringUtilTest_toJsonFileIndent2Filter.json"; |
321 |
✓✗ | 1 |
toJsonFile(debugStringObject, fileName, 2, depthWalkFilter); |
322 |
|||
323 |
✓✗✓✗ |
2 |
std::ifstream is(fileName.c_str()); |
324 |
✓✗✓✗ |
2 |
std::stringstream ss; |
325 |
✓✗✓✗ |
1 |
ss << is.rdbuf(); |
326 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗✓✗ |
1 |
ASSERT_EQ("{\n}", ss.str()); |
327 |
} |
||
328 |
|||
329 |
✓✗✓✗ ✓✗✗✓ |
802 |
TEST(DebugStringUtilTest, toJsonFileIndent2FilterWithAlloc) |
330 |
{ |
||
331 |
2 |
const StdDebugStringObject debugStringObject; |
|
332 |
✓✗ | 2 |
DefaultWalkFilter defaultWalkFilter; |
333 |
✓✗✓✗ |
2 |
const std::string fileName = "DebugStringUtilTest_toJsonFileIndent2FilterWithAlloc.json"; |
334 |
✓✗ | 1 |
toJsonFile(debugStringObject, fileName, 2, defaultWalkFilter, std_alloc()); |
335 |
|||
336 |
✓✗✓✗ |
2 |
std::ifstream is(fileName.c_str()); |
337 |
✓✗✓✗ |
2 |
std::stringstream ss; |
338 |
✓✗✓✗ |
1 |
ss << is.rdbuf(); |
339 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗✓✗ |
1 |
ASSERT_EQ("{\n \"text\": \"test\"\n}", ss.str()); |
340 |
} |
||
341 |
|||
342 |
✓✗✓✗ ✓✗✗✓ |
802 |
TEST(DebugStringUtilTest, toJsonFileIndent2FilterWithPolymorphicAlloc) |
343 |
{ |
||
344 |
2 |
const PmrDebugStringObject debugStringObject; |
|
345 |
✓✗ | 2 |
BasicDefaultWalkFilter<pmr_alloc> defaultWalkFilter; |
346 |
✓✗✓✗ |
2 |
const string<pmr_alloc> fileName = "DebugStringUtilTest_toJsonFileIndent2FilterWithPolymorphicAlloc.json"; |
347 |
✓✗ | 1 |
toJsonFile(debugStringObject, fileName, 2, defaultWalkFilter, pmr_alloc()); |
348 |
|||
349 |
✓✗✓✗ |
2 |
std::ifstream is(fileName.c_str()); |
350 |
✓✗✓✗ |
2 |
std::stringstream ss; |
351 |
✓✗✓✗ |
1 |
ss << is.rdbuf(); |
352 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗✓✗ |
1 |
ASSERT_EQ("{\n \"text\": \"test\"\n}", ss.str()); |
353 |
} |
||
354 |
|||
355 |
✓✗✓✗ ✓✗✗✓ |
802 |
TEST(DebugStringUtilTest, fromJsonStreamTypeInfo) |
356 |
{ |
||
357 |
✓✗✓✗ |
2 |
std::istringstream ss("{\n \"text\": \"something\"\n}"); |
358 |
✓✗✓✗ ✓✗ |
2 |
IReflectablePtr reflectable = fromJsonStream(StdDebugStringObject::typeInfo(), ss); |
359 |
✓✗✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_TRUE(reflectable); |
360 |
|||
361 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✓✗ ✓✗ |
1 |
ASSERT_EQ("something"_sv, reflectable->getField("text")->getStringView()); |
362 |
} |
||
363 |
|||
364 |
✓✗✓✗ ✓✗✗✓ |
802 |
TEST(DebugStringUtilTest, fromJsonStreamParameterizedTypeInfo) |
365 |
{ |
||
366 |
✓✗✓✗ |
2 |
std::istringstream ss("{\n \"text\": \"something\"\n}"); |
367 |
✓✗✓✗ ✓✗ |
2 |
IReflectablePtr reflectable = fromJsonStream(StdDebugStringParamObject::typeInfo(), ss); |
368 |
✓✗✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_TRUE(reflectable); |
369 |
|||
370 |
✓✗✓✗ ✓✗✗✓ ✗✓✗✗ ✗✗✗✗ ✗✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✗✗ ✗✗✗✗ ✗✗✗✗ ✗ |
2 |
ASSERT_THROW(reflectable->getParameter("param"), CppRuntimeException); |
371 |
✓✗✓✗ ✓✗✓✓ ✗✗ |
1 |
reflectable->initialize(vector<AnyHolder<>>{AnyHolder<>{10}}); |
372 |
|||
373 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✓✗ |
1 |
ASSERT_EQ(10, reflectable->getParameter("param")->getInt32()); |
374 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✓✗ ✓✗ |
1 |
ASSERT_EQ("something"_sv, reflectable->getField("text")->getStringView()); |
375 |
} |
||
376 |
|||
377 |
✓✗✓✗ ✓✗✗✓ |
802 |
TEST(DebugStringUtilTest, fromJsonStreamTypeInfoWithAlloc) |
378 |
{ |
||
379 |
✓✗✓✗ |
2 |
std::istringstream ss("{\n \"text\": \"something\"\n}"); |
380 |
✓✗✓✗ ✓✗ |
2 |
IReflectablePtr reflectable = fromJsonStream(StdDebugStringObject::typeInfo(), ss, std_alloc()); |
381 |
✓✗✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_TRUE(reflectable); |
382 |
|||
383 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✓✗ ✓✗ |
1 |
ASSERT_EQ("something"_sv, reflectable->getField("text")->getStringView()); |
384 |
} |
||
385 |
|||
386 |
✓✗✓✗ ✓✗✗✓ |
802 |
TEST(DebugStringUtilTest, fromJsonStreamTypeInfoWithPolymorphicAllocDefault) |
387 |
{ |
||
388 |
✓✗✓✗ |
2 |
std::istringstream ss("{\n \"text\": \"something\"\n}"); |
389 |
IBasicReflectablePtr<pmr_alloc> reflectable = |
||
390 |
✓✗✓✗ ✓✗ |
2 |
fromJsonStream(PmrDebugStringObject::typeInfo(), ss); |
391 |
✓✗✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_TRUE(reflectable); |
392 |
|||
393 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✓✗ ✓✗ |
1 |
ASSERT_EQ("something"_sv, reflectable->getField("text")->getStringView()); |
394 |
} |
||
395 |
|||
396 |
✓✗✓✗ ✓✗✗✓ |
802 |
TEST(DebugStringUtilTest, fromJsonStreamTypeInfoWithPolymorphicAlloc) |
397 |
{ |
||
398 |
✓✗✓✗ |
2 |
std::istringstream ss("{\n \"text\": \"something\"\n}"); |
399 |
IBasicReflectablePtr<pmr_alloc> reflectable = |
||
400 |
✓✗✓✗ ✓✗ |
2 |
fromJsonStream(PmrDebugStringObject::typeInfo(), ss, pmr_alloc()); |
401 |
✓✗✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_TRUE(reflectable); |
402 |
|||
403 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✓✗ ✓✗ |
1 |
ASSERT_EQ("something"_sv, reflectable->getField("text")->getStringView()); |
404 |
} |
||
405 |
|||
406 |
✓✗✓✗ ✓✗✗✓ |
802 |
TEST(DebugStringUtilTest, fromJsonStreamType) |
407 |
{ |
||
408 |
✓✗✓✗ |
2 |
std::istringstream ss("{\n \"text\": \"something\"\n}"); |
409 |
✓✗✓✗ |
2 |
StdDebugStringObject debugStringObject = fromJsonStream<StdDebugStringObject>(ss); |
410 |
|||
411 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗✓✗ |
1 |
ASSERT_EQ("something", debugStringObject.getText()); |
412 |
} |
||
413 |
|||
414 |
✓✗✓✗ ✓✗✗✓ |
802 |
TEST(DebugStringUtilTest, fromJsonStreamParameterizedType) |
415 |
{ |
||
416 |
✓✗✓✗ |
2 |
std::istringstream ss("{\n \"text\": \"something\"\n}"); |
417 |
✓✗✓✗ ✓✗✗ |
2 |
StdDebugStringParamObject debugStringParamObject = fromJsonStream<StdDebugStringParamObject>(ss); |
418 |
|||
419 |
✓✗✓✗ ✓✗✗✓ ✗✓✗✗ ✗✗✗✗ ✗✗✓✗ ✓✗✗✗ ✗✗✗✗ ✗✗✗✗ ✗✗✗✗ ✗✗ |
2 |
ASSERT_THROW(debugStringParamObject.getParam(), CppRuntimeException); |
420 |
|||
421 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗✓✗ |
1 |
ASSERT_EQ("something", debugStringParamObject.getText()); |
422 |
} |
||
423 |
|||
424 |
✓✗✓✗ ✓✗✗✓ |
802 |
TEST(DebugStringUtilTest, fromJsonStreamTypeWithAlloc) |
425 |
{ |
||
426 |
✓✗✓✗ |
2 |
std::istringstream ss("{\n \"text\": \"something\"\n}"); |
427 |
✓✗✓✗ |
2 |
StdDebugStringObject debugStringObject = fromJsonStream<StdDebugStringObject>(ss, std_alloc()); |
428 |
|||
429 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗✓✗ |
1 |
ASSERT_EQ("something", debugStringObject.getText()); |
430 |
} |
||
431 |
|||
432 |
✓✗✓✗ ✓✗✗✓ |
802 |
TEST(DebugStringUtilTest, fromJsonStreamTypeWithPolymorphicAllocDefault) |
433 |
{ |
||
434 |
✓✗✓✗ |
2 |
std::istringstream ss("{\n \"text\": \"something\"\n}"); |
435 |
✓✗✓✗ |
2 |
PmrDebugStringObject debugStringObject = fromJsonStream<PmrDebugStringObject>(ss); |
436 |
|||
437 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗✓✗ |
1 |
ASSERT_EQ("something", debugStringObject.getText()); |
438 |
} |
||
439 |
|||
440 |
✓✗✓✗ ✓✗✗✓ |
802 |
TEST(DebugStringUtilTest, fromJsonStreamTypeWithPolymorphicAlloc) |
441 |
{ |
||
442 |
✓✗✓✗ |
2 |
std::istringstream ss("{\n \"text\": \"something\"\n}"); |
443 |
✓✗✓✗ |
2 |
PmrDebugStringObject debugStringObject = fromJsonStream<PmrDebugStringObject>(ss, pmr_alloc()); |
444 |
|||
445 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗✓✗ |
1 |
ASSERT_EQ("something", debugStringObject.getText()); |
446 |
} |
||
447 |
|||
448 |
✓✗✓✗ ✓✗✗✓ |
802 |
TEST(DebugStringUtilTest, fromJsonStringTypeInfo) |
449 |
{ |
||
450 |
✓✗ | 2 |
std::string jsonString("{\n \"text\": \"something\"\n}"); |
451 |
✓✗✓✗ ✓✗ |
2 |
IReflectablePtr reflectable = fromJsonString(StdDebugStringObject::typeInfo(), jsonString); |
452 |
✓✗✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_TRUE(reflectable); |
453 |
|||
454 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✓✗ ✓✗ |
1 |
ASSERT_EQ("something"_sv, reflectable->getField("text")->getStringView()); |
455 |
} |
||
456 |
|||
457 |
✓✗✓✗ ✓✗✗✓ |
802 |
TEST(DebugStringUtilTest, fromJsonStringParameterizedTypeInfo) |
458 |
{ |
||
459 |
✓✗ | 2 |
std::string jsonString("{\n \"text\": \"something\"\n}"); |
460 |
✓✗✓✗ ✓✗ |
2 |
IReflectablePtr reflectable = fromJsonString(StdDebugStringParamObject::typeInfo(), jsonString); |
461 |
✓✗✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_TRUE(reflectable); |
462 |
|||
463 |
✓✗✓✗ ✓✗✗✓ ✗✓✗✗ ✗✗✗✗ ✗✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✗✗ ✗✗✗✗ ✗✗✗✗ ✗ |
2 |
ASSERT_THROW(reflectable->getParameter("param"), CppRuntimeException); |
464 |
✓✗✓✗ ✓✗✓✓ ✗✗ |
1 |
reflectable->initialize(vector<AnyHolder<>>{AnyHolder<>{10}}); |
465 |
|||
466 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✓✗ |
1 |
ASSERT_EQ(10, reflectable->getParameter("param")->getInt32()); |
467 |
|||
468 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✓✗ ✓✗ |
1 |
ASSERT_EQ("something"_sv, reflectable->getField("text")->getStringView()); |
469 |
} |
||
470 |
|||
471 |
✓✗✓✗ ✓✗✗✓ |
802 |
TEST(DebugStringUtilTest, fromJsonStringTypeInfoWithAlloc) |
472 |
{ |
||
473 |
✓✗ | 2 |
std::string jsonString("{\n \"text\": \"something\"\n}"); |
474 |
IReflectablePtr reflectable = |
||
475 |
✓✗✓✗ ✓✗ |
2 |
fromJsonString(StdDebugStringObject::typeInfo(), jsonString, std_alloc()); |
476 |
✓✗✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_TRUE(reflectable); |
477 |
|||
478 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✓✗ ✓✗ |
1 |
ASSERT_EQ("something"_sv, reflectable->getField("text")->getStringView()); |
479 |
} |
||
480 |
|||
481 |
✓✗✓✗ ✓✗✗✓ |
802 |
TEST(DebugStringUtilTest, fromJsonStringTypeInfoWithPolymorphicAllocDefault) |
482 |
{ |
||
483 |
✓✗ | 2 |
string<pmr_alloc> jsonString("{\n \"text\": \"something\"\n}"); |
484 |
IBasicReflectablePtr<pmr_alloc> reflectable = |
||
485 |
✓✗✓✗ ✓✗ |
2 |
fromJsonString(PmrDebugStringObject::typeInfo(), jsonString); |
486 |
✓✗✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_TRUE(reflectable); |
487 |
|||
488 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✓✗ ✓✗ |
1 |
ASSERT_EQ("something"_sv, reflectable->getField("text")->getStringView()); |
489 |
} |
||
490 |
|||
491 |
✓✗✓✗ ✓✗✗✓ |
802 |
TEST(DebugStringUtilTest, fromJsonStringTypeInfoWithPolymorphicAlloc) |
492 |
{ |
||
493 |
✓✗ | 2 |
string<pmr_alloc> jsonString("{\n \"text\": \"something\"\n}"); |
494 |
IBasicReflectablePtr<pmr_alloc> reflectable = |
||
495 |
✓✗✓✗ ✓✗ |
2 |
fromJsonString(PmrDebugStringObject::typeInfo(), jsonString, pmr_alloc()); |
496 |
✓✗✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_TRUE(reflectable); |
497 |
|||
498 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✓✗ ✓✗ |
1 |
ASSERT_EQ("something"_sv, reflectable->getField("text")->getStringView()); |
499 |
} |
||
500 |
|||
501 |
✓✗✓✗ ✓✗✗✓ |
802 |
TEST(DebugStringUtilTest, fromJsonStringType) |
502 |
{ |
||
503 |
✓✗ | 2 |
std::string jsonString("{\n \"text\": \"something\"\n}"); |
504 |
✓✗✓✗ |
2 |
StdDebugStringObject debugStringObject = fromJsonString<StdDebugStringObject>(jsonString); |
505 |
|||
506 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗✓✗ |
1 |
ASSERT_EQ("something", debugStringObject.getText()); |
507 |
} |
||
508 |
|||
509 |
✓✗✓✗ ✓✗✗✓ |
802 |
TEST(DebugStringUtilTest, fromJsonStringParameterizedType) |
510 |
{ |
||
511 |
✓✗ | 2 |
std::string jsonString("{\n \"text\": \"something\"\n}"); |
512 |
StdDebugStringParamObject debugStringParamObject = |
||
513 |
✓✗✓✗ ✓✗✗ |
2 |
fromJsonString<StdDebugStringParamObject>(jsonString); |
514 |
|||
515 |
✓✗✓✗ ✓✗✗✓ ✗✓✗✗ ✗✗✗✗ ✗✗✓✗ ✓✗✗✗ ✗✗✗✗ ✗✗✗✗ ✗✗✗✗ ✗✗ |
2 |
ASSERT_THROW(debugStringParamObject.getParam(), CppRuntimeException); |
516 |
|||
517 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗✓✗ |
1 |
ASSERT_EQ("something", debugStringParamObject.getText()); |
518 |
} |
||
519 |
|||
520 |
✓✗✓✗ ✓✗✗✓ |
802 |
TEST(DebugStringUtilTest, fromJsonStringTypeWithAlloc) |
521 |
{ |
||
522 |
✓✗ | 2 |
std::string jsonString("{\n \"text\": \"something\"\n}"); |
523 |
✓✗✓✗ |
2 |
StdDebugStringObject debugStringObject = fromJsonString<StdDebugStringObject>(jsonString, std_alloc()); |
524 |
|||
525 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗✓✗ |
1 |
ASSERT_EQ("something", debugStringObject.getText()); |
526 |
} |
||
527 |
|||
528 |
✓✗✓✗ ✓✗✗✓ |
802 |
TEST(DebugStringUtilTest, fromJsonStringTypeWithPolymorphicAllocDefault) |
529 |
{ |
||
530 |
✓✗ | 2 |
string<pmr_alloc> jsonString("{\n \"text\": \"something\"\n}"); |
531 |
✓✗✓✗ |
2 |
PmrDebugStringObject debugStringObject = fromJsonString<PmrDebugStringObject>(jsonString); |
532 |
|||
533 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗✓✗ |
1 |
ASSERT_EQ("something", debugStringObject.getText()); |
534 |
} |
||
535 |
|||
536 |
✓✗✓✗ ✓✗✗✓ |
802 |
TEST(DebugStringUtilTest, fromJsonStringTypeWithPolymorphicAlloc) |
537 |
{ |
||
538 |
✓✗ | 2 |
string<pmr_alloc> jsonString("{\n \"text\": \"something\"\n}"); |
539 |
✓✗✓✗ |
2 |
PmrDebugStringObject debugStringObject = fromJsonString<PmrDebugStringObject>(jsonString, pmr_alloc()); |
540 |
|||
541 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗✓✗ |
1 |
ASSERT_EQ("something", debugStringObject.getText()); |
542 |
} |
||
543 |
|||
544 |
✓✗✓✗ ✓✗✗✓ |
802 |
TEST(DebugStringUtilTest, fromJsonFileTypeInfo) |
545 |
{ |
||
546 |
1 |
const char* fileName = "DebugStringUtilTest_fromJsonFileTypeInfo.json"; |
|
547 |
{ |
||
548 |
✓✗ | 2 |
std::ofstream os(fileName, std::ofstream::out | std::ofstream::trunc); |
549 |
✓✗ | 1 |
os << "{\n \"text\": \"something\"\n}"; |
550 |
} |
||
551 |
|||
552 |
✓✗✓✗ ✓✗ |
2 |
IReflectablePtr reflectable = fromJsonFile(StdDebugStringObject::typeInfo(), fileName); |
553 |
✓✗✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_TRUE(reflectable); |
554 |
|||
555 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✓✗ |
1 |
ASSERT_EQ("something"_sv, reflectable->getField("text")->getStringView()); |
556 |
|||
557 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✓ ✗✓✗✗ ✗✗✗✗ ✗✗✓✗ ✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✗✗✗✗ ✗✗✗✗ ✗✗✗ |
2 |
ASSERT_THROW(fromJsonFile(StdDebugStringObject::typeInfo(), ""), CppRuntimeException); |
558 |
} |
||
559 |
|||
560 |
✓✗✓✗ ✓✗✗✓ |
802 |
TEST(DebugStringUtilTest, fromJsonFileParameterizedTypeInfo) |
561 |
{ |
||
562 |
1 |
const char* fileName = "DebugStringUtilTest_fromJsonFileParameterizedTypeInfo.json"; |
|
563 |
{ |
||
564 |
✓✗ | 2 |
std::ofstream os(fileName, std::ofstream::out | std::ofstream::trunc); |
565 |
✓✗ | 1 |
os << "{\n \"text\": \"something\"\n}"; |
566 |
} |
||
567 |
|||
568 |
✓✗✓✗ ✓✗ |
2 |
IReflectablePtr reflectable = fromJsonFile(StdDebugStringParamObject::typeInfo(), fileName); |
569 |
✓✗✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_TRUE(reflectable); |
570 |
|||
571 |
✓✗✓✗ ✓✗✗✓ ✗✓✗✗ ✗✗✗✗ ✗✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✗✗ ✗✗✗✗ ✗✗✗✗ ✗ |
2 |
ASSERT_THROW(reflectable->getParameter("param"), CppRuntimeException); |
572 |
✓✗✓✗ ✓✗✓✓ ✗✗ |
1 |
reflectable->initialize(vector<AnyHolder<>>{AnyHolder<>{10}}); |
573 |
|||
574 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✓✗ |
1 |
ASSERT_EQ(10, reflectable->getParameter("param")->getInt32()); |
575 |
|||
576 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✓✗ ✓✗ |
1 |
ASSERT_EQ("something"_sv, reflectable->getField("text")->getStringView()); |
577 |
} |
||
578 |
|||
579 |
✓✗✓✗ ✓✗✗✓ |
802 |
TEST(DebugStringUtilTest, fromJsonFileTypeInfoWithAlloc) |
580 |
{ |
||
581 |
1 |
const char* fileName = "DebugStringUtilTest_fromJsonFileTypeInfoWithAlloc.json"; |
|
582 |
{ |
||
583 |
✓✗ | 2 |
std::ofstream os(fileName, std::ofstream::out | std::ofstream::trunc); |
584 |
✓✗ | 1 |
os << "{\n \"text\": \"something\"\n}"; |
585 |
} |
||
586 |
|||
587 |
✓✗✓✗ ✓✗ |
2 |
IReflectablePtr reflectable = fromJsonFile(StdDebugStringObject::typeInfo(), fileName, std_alloc()); |
588 |
✓✗✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_TRUE(reflectable); |
589 |
|||
590 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✓✗ ✓✗ |
1 |
ASSERT_EQ("something"_sv, reflectable->getField("text")->getStringView()); |
591 |
} |
||
592 |
|||
593 |
✓✗✓✗ ✓✗✗✓ |
802 |
TEST(DebugStringUtilTest, fromJsonFileTypeInfoWithPolymorphicAllocDefault) |
594 |
{ |
||
595 |
1 |
const char* fileName = "DebugStringUtilTest_fromJsonFileTypeInfoWithPolymorphicAllocDefault.json"; |
|
596 |
{ |
||
597 |
✓✗ | 2 |
std::ofstream os(fileName, std::ofstream::out | std::ofstream::trunc); |
598 |
✓✗ | 1 |
os << "{\n \"text\": \"something\"\n}"; |
599 |
} |
||
600 |
|||
601 |
IBasicReflectablePtr<pmr_alloc> reflectable = |
||
602 |
✓✗✓✗ ✓✗ |
2 |
fromJsonFile(PmrDebugStringObject::typeInfo(), fileName); |
603 |
✓✗✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_TRUE(reflectable); |
604 |
|||
605 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✓✗ ✓✗ |
1 |
ASSERT_EQ("something"_sv, reflectable->getField("text")->getStringView()); |
606 |
} |
||
607 |
|||
608 |
✓✗✓✗ ✓✗✗✓ |
802 |
TEST(DebugStringUtilTest, fromJsonFileTypeInfoWithPolymorphicAlloc) |
609 |
{ |
||
610 |
1 |
const char* fileName = "DebugStringUtilTest_fromJsonFileTypeInfoWithPolymorphicAlloc.json"; |
|
611 |
{ |
||
612 |
✓✗ | 2 |
std::ofstream os(fileName, std::ofstream::out | std::ofstream::trunc); |
613 |
✓✗ | 1 |
os << "{\n \"text\": \"something\"\n}"; |
614 |
} |
||
615 |
|||
616 |
IBasicReflectablePtr<pmr_alloc> reflectable = |
||
617 |
✓✗✓✗ ✓✗ |
2 |
fromJsonFile(PmrDebugStringObject::typeInfo(), fileName, pmr_alloc()); |
618 |
✓✗✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_TRUE(reflectable); |
619 |
|||
620 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✓✗ ✓✗ |
1 |
ASSERT_EQ("something"_sv, reflectable->getField("text")->getStringView()); |
621 |
} |
||
622 |
|||
623 |
✓✗✓✗ ✓✗✗✓ |
802 |
TEST(DebugStringUtilTest, fromJsonFileParameterizedTypeInfoWithPolymorphicAlloc) |
624 |
{ |
||
625 |
1 |
const char* fileName = "DebugStringUtilTest_fromJsonFileParameterizedTypeInfoWithPolymorphicAlloc.json"; |
|
626 |
{ |
||
627 |
✓✗ | 2 |
std::ofstream os(fileName, std::ofstream::out | std::ofstream::trunc); |
628 |
✓✗ | 1 |
os << "{\n \"text\": \"something\"\n}"; |
629 |
} |
||
630 |
|||
631 |
IBasicReflectablePtr<pmr_alloc> reflectable = fromJsonFile( |
||
632 |
✓✗✓✗ ✓✗ |
2 |
PmrDebugStringParamObject::typeInfo(), fileName, pmr_alloc()); |
633 |
✓✗✗✓ ✗✗✗✗ ✗✗✗✗ ✓✗ |
1 |
ASSERT_TRUE(reflectable); |
634 |
|||
635 |
✓✗✓✗ ✓✗✗✓ ✗✓✗✗ ✗✗✗✗ ✗✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✗✗ ✗✗✗✗ ✗✗✗✗ ✗ |
2 |
ASSERT_THROW(reflectable->getParameter("param"), CppRuntimeException); |
636 |
✓✗✓✗ ✓✗✓✓ ✗✗ |
1 |
reflectable->initialize(vector<AnyHolder<pmr_alloc>, pmr_alloc>{AnyHolder<pmr_alloc>{10}}); |
637 |
|||
638 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✓✗ |
1 |
ASSERT_EQ(10, reflectable->getParameter("param")->getInt32()); |
639 |
|||
640 |
✓✗✓✗ ✓✗✗✓ ✗✗✗✗ ✗✗✓✗ ✓✗ |
1 |
ASSERT_EQ("something"_sv, reflectable->getField("text")->getStringView()); |
641 |
} |
||
642 |
|||
643 |
✓✗✓✗ ✓✗✗✓ |
802 |
TEST(DebugStringUtilTest, fromJsonFileType) |
644 |
{ |
||
645 |
1 |
const char* fileName = "DebugStringUtilTest_fromJsonFileType.json"; |
|
646 |
{ |
||
647 |
✓✗ | 2 |
std::ofstream os(fileName, std::ofstream::out | std::ofstream::trunc); |
648 |
✓✗ | 1 |
os << "{\n \"text\": \"something\"\n}"; |
649 |
} |
||
650 |
|||
651 |
✓✗✓✗ |
2 |
StdDebugStringObject debugStringObject = fromJsonFile<StdDebugStringObject>(fileName); |
652 |
|||
653 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗✓✗ |
1 |
ASSERT_EQ("something", debugStringObject.getText()); |
654 |
} |
||
655 |
|||
656 |
✓✗✓✗ ✓✗✗✓ |
802 |
TEST(DebugStringUtilTest, fromJsonFileParameterizedType) |
657 |
{ |
||
658 |
1 |
const char* fileName = "DebugStringUtilTest_fromJsonFileParameterizedType.json"; |
|
659 |
{ |
||
660 |
✓✗ | 2 |
std::ofstream os(fileName, std::ofstream::out | std::ofstream::trunc); |
661 |
✓✗ | 1 |
os << "{\n \"text\": \"something\"\n}"; |
662 |
} |
||
663 |
|||
664 |
✓✗✓✗ ✓✗✗ |
2 |
StdDebugStringParamObject debugStringParamObject = fromJsonFile<StdDebugStringParamObject>(fileName); |
665 |
|||
666 |
✓✗✓✗ ✓✗✗✓ ✗✓✗✗ ✗✗✗✗ ✗✗✓✗ ✓✗✗✗ ✗✗✗✗ ✗✗✗✗ ✗✗✗✗ ✗✗ |
2 |
ASSERT_THROW(debugStringParamObject.getParam(), CppRuntimeException); |
667 |
|||
668 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗✓✗ |
1 |
ASSERT_EQ("something", debugStringParamObject.getText()); |
669 |
} |
||
670 |
|||
671 |
✓✗✓✗ ✓✗✗✓ |
802 |
TEST(DebugStringUtilTest, fromJsonFileTypeWithAlloc) |
672 |
{ |
||
673 |
1 |
const char* fileName = "DebugStringUtilTest_fromJsonFileTypeWithAlloc.json"; |
|
674 |
{ |
||
675 |
✓✗ | 2 |
std::ofstream os(fileName, std::ofstream::out | std::ofstream::trunc); |
676 |
✓✗ | 1 |
os << "{\n \"text\": \"something\"\n}"; |
677 |
} |
||
678 |
|||
679 |
✓✗✓✗ |
2 |
StdDebugStringObject debugStringObject = fromJsonFile<StdDebugStringObject>(fileName, std_alloc()); |
680 |
|||
681 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗✓✗ |
1 |
ASSERT_EQ("something", debugStringObject.getText()); |
682 |
} |
||
683 |
|||
684 |
✓✗✓✗ ✓✗✗✓ |
802 |
TEST(DebugStringUtilTest, fromJsonFileTypeWithPolymorphicAllocDefault) |
685 |
{ |
||
686 |
1 |
const char* fileName = "DebugStringUtilTest_fromJsonFileTypeWithPolymorphicAllocDefault.json"; |
|
687 |
{ |
||
688 |
✓✗ | 2 |
std::ofstream os(fileName, std::ofstream::out | std::ofstream::trunc); |
689 |
✓✗ | 1 |
os << "{\n \"text\": \"something\"\n}"; |
690 |
} |
||
691 |
|||
692 |
✓✗✓✗ |
2 |
PmrDebugStringObject debugStringObject = fromJsonFile<PmrDebugStringObject>(fileName); |
693 |
|||
694 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗✓✗ |
1 |
ASSERT_EQ("something", debugStringObject.getText()); |
695 |
} |
||
696 |
|||
697 |
✓✗✓✗ ✓✗✗✓ |
802 |
TEST(DebugStringUtilTest, fromJsonFileTypeWithPolymorphicAlloc) |
698 |
{ |
||
699 |
1 |
const char* fileName = "DebugStringUtilTest_fromJsonFileTypeWithPolymorphicAlloc.json"; |
|
700 |
{ |
||
701 |
✓✗ | 2 |
std::ofstream os(fileName, std::ofstream::out | std::ofstream::trunc); |
702 |
✓✗ | 1 |
os << "{\n \"text\": \"something\"\n}"; |
703 |
} |
||
704 |
|||
705 |
✓✗✓✗ |
2 |
PmrDebugStringObject debugStringObject = fromJsonFile<PmrDebugStringObject>(fileName, pmr_alloc()); |
706 |
|||
707 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗✓✗ |
1 |
ASSERT_EQ("something", debugStringObject.getText()); |
708 |
} |
||
709 |
|||
710 |
✓✗✓✗ ✓✗✗✓ |
802 |
TEST(DebugStringUtilTest, fromJsonFileParameterizedTypeWithPolymorphicAlloc) |
711 |
{ |
||
712 |
1 |
const char* fileName = "DebugStringUtilTest_fromJsonFileParameteriezedTypeWithPolymorphicAlloc.json"; |
|
713 |
{ |
||
714 |
✓✗ | 2 |
std::ofstream os(fileName, std::ofstream::out | std::ofstream::trunc); |
715 |
✓✗ | 1 |
os << "{\n \"text\": \"something\"\n}"; |
716 |
} |
||
717 |
|||
718 |
PmrDebugStringParamObject debugStringParamObject = |
||
719 |
✓✗✓✗ ✓✗✗ |
2 |
fromJsonFile<PmrDebugStringParamObject>(fileName, pmr_alloc()); |
720 |
|||
721 |
✓✗✓✗ ✓✗✗✓ ✗✓✗✗ ✗✗✗✗ ✗✗✓✗ ✓✗✗✗ ✗✗✗✗ ✗✗✗✗ ✗✗✗✗ ✗✗ |
2 |
ASSERT_THROW(debugStringParamObject.getParam(), CppRuntimeException); |
722 |
|||
723 |
✓✗✓✗ ✗✓✗✗ ✗✗✗✗ ✓✗✓✗ |
1 |
ASSERT_EQ("something", debugStringParamObject.getText()); |
724 |
} |
||
725 |
|||
726 |
✓✗✓✗ |
2394 |
} // namespace zserio |
Generated by: GCOVR (Version 4.2) |