GCC Code Coverage Report | |||||||||||||||||||||
|
|||||||||||||||||||||
Line | Branch | Exec | Source |
1 |
// Copyright 2011 Florent Lamiraux, Thomas Moulard. |
||
2 |
// |
||
3 |
|||
4 |
#include "dynamic-graph/value.h" |
||
5 |
|||
6 |
#include <dynamic-graph/exception-factory.h> |
||
7 |
|||
8 |
#include <iostream> |
||
9 |
|||
10 |
#define BOOST_TEST_MODULE value |
||
11 |
|||
12 |
#include <boost/version.hpp> |
||
13 |
|||
14 |
#if BOOST_VERSION >= 105900 |
||
15 |
#include <boost/test/tools/output_test_stream.hpp> |
||
16 |
#else |
||
17 |
#include <boost/test/output_test_stream.hpp> |
||
18 |
#endif |
||
19 |
#include <boost/test/unit_test.hpp> |
||
20 |
|||
21 |
using boost::test_tools::output_test_stream; |
||
22 |
|||
23 |
namespace dg = dynamicgraph; |
||
24 |
|||
25 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗ |
4 |
BOOST_AUTO_TEST_CASE(value_none) { |
26 |
using dg::command::Value; |
||
27 |
|||
28 |
✓✗ | 4 |
Value value1; |
29 |
✓✗ | 4 |
Value value(value1); |
30 |
|||
31 |
// Similar to NaN != NaN |
||
32 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✓ |
2 |
BOOST_CHECK(!(value1 == value)); |
33 |
|||
34 |
{ |
||
35 |
✓✗✓✗ |
4 |
output_test_stream output; |
36 |
✓✗ | 2 |
output << value1; |
37 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✓ |
2 |
BOOST_CHECK(output.is_equal("Type=unknown, value=")); |
38 |
} |
||
39 |
2 |
} |
|
40 |
|||
41 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗ |
4 |
BOOST_AUTO_TEST_CASE(value_bool) { |
42 |
using dg::command::Value; |
||
43 |
|||
44 |
2 |
bool abool1(false); |
|
45 |
✓✗ | 4 |
Value value1(abool1); |
46 |
✓✗ | 4 |
Value value = value1; |
47 |
|||
48 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✓ |
2 |
BOOST_CHECK(value1 == value); |
49 |
|||
50 |
{ |
||
51 |
✓✗✓✗ |
4 |
output_test_stream output; |
52 |
✓✗ | 2 |
output << value1; |
53 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✓ |
2 |
BOOST_CHECK(output.is_equal("Type=bool, value=0")); |
54 |
} |
||
55 |
|||
56 |
{ |
||
57 |
✓✗✓✗ |
4 |
output_test_stream output; |
58 |
✓✗ | 2 |
output << value; |
59 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✓ |
2 |
BOOST_CHECK(output.is_equal("Type=bool, value=0")); |
60 |
} |
||
61 |
2 |
} |
|
62 |
|||
63 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗ |
4 |
BOOST_AUTO_TEST_CASE(value_exceptions) { |
64 |
using dg::command::Value; |
||
65 |
|||
66 |
✓✗ | 4 |
Value value1; |
67 |
✓✗ | 4 |
dg::command::EitherType anet(value1); |
68 |
✓✗✓✗ ✓✗✓✗ |
4 |
output_test_stream output, output2; |
69 |
|||
70 |
// Check if the exception is working when calling intValue |
||
71 |
// while we are having a none. |
||
72 |
2 |
bool res = false; |
|
73 |
try { |
||
74 |
✗✓ | 2 |
int aInt(anet); |
75 |
aInt++; // silence unused variable warnings to have a stable release in the |
||
76 |
// ros buildfarm |
||
77 |
2 |
} catch (const dg::ExceptionAbstract &aea) { |
|
78 |
✓✗✓✗ |
2 |
output << aea.getExceptionName(); |
79 |
✓✗ | 2 |
output2 << aea.what(); |
80 |
✓✗ | 2 |
res = (aea.getCode() == dg::ExceptionAbstract::TOOLS); |
81 |
} |
||
82 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✓ |
2 |
BOOST_CHECK(res); |
83 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✓ |
2 |
BOOST_CHECK(output.is_equal("Abstract")); |
84 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✓ |
2 |
BOOST_CHECK(output2.is_equal("value is not an int")); |
85 |
|||
86 |
// Check if the exception is working when calling boolValue |
||
87 |
// while we are having a none. |
||
88 |
2 |
res = false; |
|
89 |
try { |
||
90 |
✗✓ | 2 |
bool abool(anet); |
91 |
abool = !abool; // silence unused variable warnings to have a stable |
||
92 |
// release in the ros buildfarm |
||
93 |
2 |
} catch (const dg::ExceptionAbstract &aea) { |
|
94 |
✓✗ | 2 |
res = (aea.getCode() == dg::ExceptionAbstract::TOOLS); |
95 |
} |
||
96 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✓ |
2 |
BOOST_CHECK(res); |
97 |
|||
98 |
// Check if the exception is working when calling unsignedintValue |
||
99 |
// while we are having a none. |
||
100 |
2 |
res = false; |
|
101 |
try { |
||
102 |
✗✓ | 2 |
unsigned int aint(anet); |
103 |
aint++; // silence unused variable warnings to have a stable release in the |
||
104 |
// ros buildfarm |
||
105 |
2 |
} catch (const dg::ExceptionAbstract &aea) { |
|
106 |
✓✗ | 2 |
res = (aea.getCode() == dg::ExceptionAbstract::TOOLS); |
107 |
} |
||
108 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✓ |
2 |
BOOST_CHECK(res); |
109 |
|||
110 |
// Check if the exception is working when calling doubleValue |
||
111 |
// while we are having a none. |
||
112 |
2 |
res = false; |
|
113 |
try { |
||
114 |
✗✓ | 2 |
double adouble(anet); |
115 |
adouble++; // silence unused variable warnings to have a stable release in |
||
116 |
// the ros buildfarm |
||
117 |
2 |
} catch (const dg::ExceptionAbstract &aea) { |
|
118 |
✓✗ | 2 |
res = (aea.getCode() == dg::ExceptionAbstract::TOOLS); |
119 |
} |
||
120 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✓ |
2 |
BOOST_CHECK(res); |
121 |
|||
122 |
// Check if the exception is working when calling floatValue |
||
123 |
// while we are having a none. |
||
124 |
2 |
res = false; |
|
125 |
try { |
||
126 |
✗✓ | 2 |
float afloat(anet); |
127 |
afloat++; // silence unused variable warnings to have a stable release in |
||
128 |
// the ros buildfarm |
||
129 |
2 |
} catch (const dg::ExceptionAbstract &aea) { |
|
130 |
✓✗ | 2 |
res = (aea.getCode() == dg::ExceptionAbstract::TOOLS); |
131 |
} |
||
132 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✓ |
2 |
BOOST_CHECK(res); |
133 |
|||
134 |
// Check if the exception is working when calling stringValue |
||
135 |
// while we are having a none. |
||
136 |
2 |
res = false; |
|
137 |
try { |
||
138 |
✗✓ | 2 |
std::string astring(anet); |
139 |
2 |
} catch (const dg::ExceptionAbstract &aea) { |
|
140 |
✓✗ | 2 |
res = (aea.getCode() == dg::ExceptionAbstract::TOOLS); |
141 |
} |
||
142 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✓ |
2 |
BOOST_CHECK(res); |
143 |
|||
144 |
// Check if the exception is working when calling vectorValue |
||
145 |
// while we are having a none. |
||
146 |
2 |
res = false; |
|
147 |
try { |
||
148 |
✓✗ | 4 |
dg::Vector avector; |
149 |
✗✓ | 2 |
avector = anet; |
150 |
2 |
} catch (const dg::ExceptionAbstract &aea) { |
|
151 |
✓✗ | 2 |
res = (aea.getCode() == dg::ExceptionAbstract::TOOLS); |
152 |
} |
||
153 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✓ |
2 |
BOOST_CHECK(res); |
154 |
|||
155 |
// Check if the exception is working when calling matrixXdValue |
||
156 |
// while we are having a none. |
||
157 |
2 |
res = false; |
|
158 |
try { |
||
159 |
✓✗ | 4 |
Eigen::MatrixXd amatrixXd; |
160 |
✗✓ | 2 |
amatrixXd = anet; |
161 |
2 |
} catch (const dg::ExceptionAbstract &aea) { |
|
162 |
✓✗ | 2 |
res = (aea.getCode() == dg::ExceptionAbstract::TOOLS); |
163 |
} |
||
164 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✓ |
2 |
BOOST_CHECK(res); |
165 |
|||
166 |
// Check if the exception is working when calling matrix4dValue |
||
167 |
// while we are having a none. |
||
168 |
2 |
res = false; |
|
169 |
try { |
||
170 |
✓✗ | 2 |
Eigen::Matrix4d amatrix4d; |
171 |
✗✓ | 2 |
amatrix4d = anet; |
172 |
2 |
} catch (const dg::ExceptionAbstract &aea) { |
|
173 |
✓✗ | 2 |
res = (aea.getCode() == dg::ExceptionAbstract::TOOLS); |
174 |
} |
||
175 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✓ |
2 |
BOOST_CHECK(res); |
176 |
2 |
} |
|
177 |
|||
178 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗ |
4 |
BOOST_AUTO_TEST_CASE(value_unsigned_int) { |
179 |
using dg::command::Value; |
||
180 |
|||
181 |
2 |
unsigned int aint1(5); |
|
182 |
✓✗ | 4 |
Value value1(aint1); |
183 |
✓✗ | 4 |
Value value = value1; |
184 |
|||
185 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✓ |
2 |
BOOST_CHECK(value1 == value); |
186 |
|||
187 |
{ |
||
188 |
✓✗✓✗ |
4 |
output_test_stream output; |
189 |
✓✗ | 2 |
output << value1; |
190 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✓ |
2 |
BOOST_CHECK(output.is_equal("Type=unsigned int, value=5")); |
191 |
} |
||
192 |
|||
193 |
{ |
||
194 |
✓✗✓✗ |
4 |
output_test_stream output; |
195 |
✓✗ | 2 |
output << value; |
196 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✓ |
2 |
BOOST_CHECK(output.is_equal("Type=unsigned int, value=5")); |
197 |
} |
||
198 |
2 |
} |
|
199 |
|||
200 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗ |
4 |
BOOST_AUTO_TEST_CASE(value_int) { |
201 |
using dg::command::Value; |
||
202 |
|||
203 |
2 |
int aint1(5); |
|
204 |
✓✗ | 4 |
Value value1(aint1); |
205 |
✓✗ | 4 |
Value value = value1; |
206 |
|||
207 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✓ |
2 |
BOOST_CHECK(value1 == value); |
208 |
|||
209 |
{ |
||
210 |
✓✗✓✗ |
4 |
output_test_stream output; |
211 |
✓✗ | 2 |
output << value1; |
212 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✓ |
2 |
BOOST_CHECK(output.is_equal("Type=int, value=5")); |
213 |
} |
||
214 |
|||
215 |
{ |
||
216 |
✓✗✓✗ |
4 |
output_test_stream output; |
217 |
✓✗ | 2 |
output << value; |
218 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✓ |
2 |
BOOST_CHECK(output.is_equal("Type=int, value=5")); |
219 |
} |
||
220 |
2 |
} |
|
221 |
|||
222 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗ |
4 |
BOOST_AUTO_TEST_CASE(value_float) { |
223 |
using dg::command::Value; |
||
224 |
|||
225 |
2 |
float afloat1(0.5); |
|
226 |
✓✗ | 4 |
Value value1(afloat1); |
227 |
✓✗ | 4 |
Value value = value1; |
228 |
|||
229 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✓ |
2 |
BOOST_CHECK(value1 == value); |
230 |
|||
231 |
{ |
||
232 |
✓✗✓✗ |
4 |
output_test_stream output; |
233 |
✓✗ | 2 |
output << value1; |
234 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✓ |
2 |
BOOST_CHECK(output.is_equal("Type=float, value=0.5")); |
235 |
} |
||
236 |
|||
237 |
{ |
||
238 |
✓✗✓✗ |
4 |
output_test_stream output; |
239 |
✓✗ | 2 |
output << value; |
240 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✓ |
2 |
BOOST_CHECK(output.is_equal("Type=float, value=0.5")); |
241 |
} |
||
242 |
2 |
} |
|
243 |
|||
244 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗ |
4 |
BOOST_AUTO_TEST_CASE(value_double) { |
245 |
using dg::command::Value; |
||
246 |
|||
247 |
2 |
double adouble1(0.5); |
|
248 |
✓✗ | 4 |
Value value1(adouble1); |
249 |
✓✗ | 4 |
Value value = value1; |
250 |
|||
251 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✓ |
2 |
BOOST_CHECK(value1 == value); |
252 |
|||
253 |
{ |
||
254 |
✓✗✓✗ |
4 |
output_test_stream output; |
255 |
✓✗ | 2 |
output << value1; |
256 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✓ |
2 |
BOOST_CHECK(output.is_equal("Type=double, value=0.5")); |
257 |
} |
||
258 |
|||
259 |
{ |
||
260 |
✓✗✓✗ |
4 |
output_test_stream output; |
261 |
✓✗ | 2 |
output << value; |
262 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✓ |
2 |
BOOST_CHECK(output.is_equal("Type=double, value=0.5")); |
263 |
} |
||
264 |
2 |
} |
|
265 |
|||
266 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗ |
4 |
BOOST_AUTO_TEST_CASE(value_vector) { |
267 |
using dg::command::Value; |
||
268 |
|||
269 |
✓✗ | 4 |
dg::Vector avector1; |
270 |
✓✗ | 2 |
avector1.resize(2); |
271 |
✓✗ | 2 |
avector1[0] = 0.5; |
272 |
✓✗ | 2 |
avector1[1] = 1.5; |
273 |
✓✗ | 4 |
Value value1(avector1); |
274 |
✓✗ | 4 |
Value value = value1; |
275 |
|||
276 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✓ |
2 |
BOOST_CHECK(value1 == value); |
277 |
|||
278 |
{ |
||
279 |
✓✗✓✗ |
4 |
output_test_stream output; |
280 |
✓✗ | 2 |
output << value1; |
281 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✓ |
2 |
BOOST_CHECK(output.is_equal("Type=vector, value=0.5\n1.5")); |
282 |
} |
||
283 |
|||
284 |
{ |
||
285 |
✓✗✓✗ |
4 |
output_test_stream output; |
286 |
✓✗ | 2 |
output << value; |
287 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✓ |
2 |
BOOST_CHECK(output.is_equal("Type=vector, value=0.5\n1.5")); |
288 |
} |
||
289 |
2 |
} |
|
290 |
|||
291 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗ |
4 |
BOOST_AUTO_TEST_CASE(value_string) { |
292 |
using dg::command::Value; |
||
293 |
|||
294 |
✓✗ | 4 |
std::string str1("value #1"); |
295 |
✓✗ | 4 |
Value value1(str1); |
296 |
✓✗ | 4 |
Value value = value1; |
297 |
|||
298 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✓ |
2 |
BOOST_CHECK(value1 == value); |
299 |
|||
300 |
{ |
||
301 |
✓✗✓✗ |
4 |
output_test_stream output; |
302 |
✓✗ | 2 |
output << value1; |
303 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✓ |
2 |
BOOST_CHECK(output.is_equal("Type=string, value=value #1")); |
304 |
} |
||
305 |
|||
306 |
{ |
||
307 |
✓✗✓✗ |
4 |
output_test_stream output; |
308 |
✓✗ | 2 |
output << value; |
309 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✓ |
2 |
BOOST_CHECK(output.is_equal("Type=string, value=value #1")); |
310 |
} |
||
311 |
|||
312 |
✓✗ | 4 |
std::string str2("value #2"); |
313 |
✓✗ | 4 |
Value value2(str2); |
314 |
✓✗ | 2 |
value = value2; |
315 |
|||
316 |
{ |
||
317 |
✓✗✓✗ |
4 |
output_test_stream output; |
318 |
✓✗ | 2 |
output << value2; |
319 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✓ |
2 |
BOOST_CHECK(output.is_equal("Type=string, value=value #2")); |
320 |
} |
||
321 |
|||
322 |
{ |
||
323 |
✓✗✓✗ |
4 |
output_test_stream output; |
324 |
✓✗ | 2 |
output << value; |
325 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✓ |
2 |
BOOST_CHECK(output.is_equal("Type=string, value=value #2")); |
326 |
} |
||
327 |
2 |
} |
|
328 |
|||
329 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗ |
4 |
BOOST_AUTO_TEST_CASE(value_matrixXd) { |
330 |
using dg::command::Value; |
||
331 |
|||
332 |
✓✗ | 4 |
Eigen::MatrixXd avector1; |
333 |
✓✗ | 2 |
avector1.resize(2, 2); |
334 |
✓✗ | 2 |
avector1(0, 0) = 0.5; |
335 |
✓✗ | 2 |
avector1(0, 1) = 1.5; |
336 |
✓✗ | 2 |
avector1(1, 0) = 2.5; |
337 |
✓✗ | 2 |
avector1(1, 1) = 3.5; |
338 |
✓✗ | 4 |
Value value1(avector1); |
339 |
✓✗ | 4 |
Value value = value1; |
340 |
|||
341 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✓ |
2 |
BOOST_CHECK(value1 == value); |
342 |
|||
343 |
{ |
||
344 |
✓✗✓✗ |
4 |
output_test_stream output; |
345 |
✓✗ | 2 |
output << value1; |
346 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✓ |
2 |
BOOST_CHECK(output.is_equal("Type=matrixXd, value=0.5 1.5\n2.5 3.5")); |
347 |
} |
||
348 |
|||
349 |
{ |
||
350 |
✓✗✓✗ |
4 |
output_test_stream output; |
351 |
✓✗ | 2 |
output << value; |
352 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✓ |
2 |
BOOST_CHECK(output.is_equal("Type=matrixXd, value=0.5 1.5\n2.5 3.5")); |
353 |
} |
||
354 |
2 |
} |
|
355 |
|||
356 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗ |
4 |
BOOST_AUTO_TEST_CASE(value_matrix4d) { |
357 |
using dg::command::Value; |
||
358 |
|||
359 |
✓✗ | 2 |
Eigen::Matrix4d avector1; |
360 |
✓✗ | 2 |
avector1.setZero(); |
361 |
✓✗ | 2 |
avector1(0, 0) = 0.5; |
362 |
✓✗ | 2 |
avector1(0, 1) = 1.5; |
363 |
✓✗ | 2 |
avector1(1, 0) = 2.5; |
364 |
✓✗ | 2 |
avector1(1, 1) = 3.5; |
365 |
✓✗ | 4 |
Value value1(avector1); |
366 |
✓✗ | 4 |
Value value = value1; |
367 |
|||
368 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✓ |
2 |
BOOST_CHECK(value1 == value); |
369 |
|||
370 |
{ |
||
371 |
✓✗✓✗ |
4 |
output_test_stream output; |
372 |
✓✗ | 2 |
output << value1; |
373 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✓ |
2 |
BOOST_CHECK( |
374 |
output.is_equal("Type=matrix4d, value=0.5 1.5 0 0\n" |
||
375 |
"2.5 3.5 0 0\n 0 0 0 0\n" |
||
376 |
" 0 0 0 0")); |
||
377 |
} |
||
378 |
|||
379 |
{ |
||
380 |
✓✗✓✗ |
4 |
output_test_stream output; |
381 |
✓✗ | 2 |
output << value; |
382 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✓ |
2 |
BOOST_CHECK( |
383 |
output.is_equal("Type=matrix4d, value=0.5 1.5 0 0\n" |
||
384 |
"2.5 3.5 0 0\n 0 0 0 0\n" |
||
385 |
" 0 0 0 0")); |
||
386 |
} |
||
387 |
2 |
} |
|
388 |
|||
389 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗ |
4 |
BOOST_AUTO_TEST_CASE(value_values) { |
390 |
using namespace dynamicgraph::command; |
||
391 |
|||
392 |
✓✗ | 4 |
std::string s1("value #1"); |
393 |
2 |
double d1 = 0.3; |
|
394 |
|||
395 |
✓✗ | 4 |
Value vs1(s1); |
396 |
✓✗ | 4 |
Value vd1(d1); |
397 |
|||
398 |
4 |
Values values; |
|
399 |
✓✗ | 2 |
values.push_back(vs1); |
400 |
✓✗ | 2 |
values.push_back(vd1); |
401 |
|||
402 |
✓✗ | 4 |
Value vvalues(values); |
403 |
|||
404 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✓ |
2 |
BOOST_CHECK_EQUAL(vvalues.type(), Value::VALUES); |
405 |
|||
406 |
{ // Const ref |
||
407 |
✓✗ | 2 |
const Values &vs = vvalues.constValuesValue(); |
408 |
✓✗✓✗ ✓✗✓✗ ✗✓ |
2 |
BOOST_CHECK_EQUAL(vs.size(), values.size()); |
409 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✓ |
2 |
BOOST_CHECK(vs == values); |
410 |
} |
||
411 |
{ |
||
412 |
// Cast does not work. |
||
413 |
// dg::command::EitherType eitherType (vvalues); |
||
414 |
// Values vs = static_cast<Values>(eitherType); |
||
415 |
// BOOST_CHECK_EQUAL(vs.size(), values.size()); |
||
416 |
// BOOST_CHECK(vs == values); |
||
417 |
} { // Constructor |
||
418 |
✓✗ | 4 |
Value vvs(vvalues); |
419 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✓ |
2 |
BOOST_CHECK(vvs == vvalues); |
420 |
} |
||
421 |
|||
422 |
{ |
||
423 |
✓✗✓✗ |
4 |
output_test_stream output; |
424 |
✓✗ | 2 |
output << vvalues; |
425 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✓ |
2 |
BOOST_CHECK( |
426 |
output.is_equal("Type=values, value=[ " |
||
427 |
"Value(Type=string, value=value #1), " |
||
428 |
"Value(Type=double, value=0.3), " |
||
429 |
"]")); |
||
430 |
} |
||
431 |
2 |
} |
Generated by: GCOVR (Version 4.2) |