4 #define BOOST_TEST_DYN_LINK
5 #define BOOST_TEST_MODULE DeviceTest
6 #include <boost/test/unit_test.hpp>
7 using namespace boost::unit_test_framework;
17 #define VALID_SDM "sdm://./pci:pcieunidummys6;undefined"
18 #define VALID_SDM_WITH_PARAMS "sdm://./dummy=goodMapFile.map"
19 #define INVALID_SDM "://./pci:pcieunidummys6;" // no sdm at the start
20 #define INVALID_SDM_2 "sdm://./pci:pcieunidummys6;;" // more than one semi-colons(;)
21 #define INVALID_SDM_3 "sdm://./pci::pcieunidummys6;" // more than one colons(:)
22 #define INVALID_SDM_4 "sdm://./dummy=goodMapFile.map=MapFile.map" // more than one equals to(=)
23 #define INVALID_SDM_5 "sdm://.pci:pcieunidummys6;" // no slash (/) after host.
24 #define VALID_PCI_STRING "/dev/mtcadummys0"
25 #define VALID_DUMMY_STRING "testfile.map"
26 #define VALID_DUMMY_STRING_2 "testfile.mapp"
27 #define INVALID_DEVICE_STRING "/mtcadummys0"
28 #define INVALID_DEVICE_STRING_2 "/dev"
29 #define INVALID_DEVICE_STRING_3 "testfile.mappp"
40 BOOST_CHECK_EQUAL(r.backendType,
"myBackendType");
41 BOOST_CHECK_EQUAL(r.address,
"some/weired*address 234");
42 BOOST_CHECK_EQUAL(r.parameters.size(), 2);
43 BOOST_CHECK_EQUAL(r.parameters[
"par1"],
"someValue with spaces");
44 BOOST_CHECK_EQUAL(r.parameters[
"map"],
"file");
49 "someValue with spaces & map = file ) ");
50 BOOST_CHECK_EQUAL(r.backendType,
"myBackendType");
51 BOOST_CHECK_EQUAL(r.address,
"some/weired*address 234");
52 BOOST_CHECK_EQUAL(r.parameters.size(), 2);
53 BOOST_CHECK_EQUAL(r.parameters[
"par1"],
"someValue with spaces");
54 BOOST_CHECK_EQUAL(r.parameters[
"map"],
"file");
59 BOOST_CHECK_EQUAL(r.backendType,
"someStrangeBackendType");
60 BOOST_CHECK_EQUAL(r.address,
"");
61 BOOST_CHECK_EQUAL(r.parameters.size(), 0);
66 BOOST_CHECK_EQUAL(r.backendType,
"pci");
67 BOOST_CHECK_EQUAL(r.address,
"pcieunis6");
68 BOOST_CHECK_EQUAL(r.parameters.size(), 0);
73 BOOST_CHECK_EQUAL(r.backendType,
"pci");
74 BOOST_CHECK_EQUAL(r.address,
"pcieunis6");
75 BOOST_CHECK_EQUAL(r.parameters.size(), 0);
80 BOOST_CHECK_EQUAL(r.backendType,
"pci");
81 BOOST_CHECK_EQUAL(r.address,
"pcieunis6");
82 BOOST_CHECK_EQUAL(r.parameters.size(), 0);
87 BOOST_CHECK_EQUAL(r.backendType,
"logicalNameMapper");
88 BOOST_CHECK_EQUAL(r.address,
"");
89 BOOST_CHECK_EQUAL(r.parameters.size(), 1);
90 BOOST_CHECK_EQUAL(r.parameters[
"map"],
"myMapFile.xlmap");
95 BOOST_CHECK_EQUAL(r.backendType,
"logicalNameMapper");
96 BOOST_CHECK_EQUAL(r.address,
"");
97 BOOST_CHECK_EQUAL(r.parameters.size(), 1);
98 BOOST_CHECK_EQUAL(r.parameters[
"map"],
"myMapFile.xlmap");
103 BOOST_CHECK_EQUAL(r.backendType,
"logicalNameMapper");
104 BOOST_CHECK_EQUAL(r.address,
"");
105 BOOST_CHECK_EQUAL(r.parameters.size(), 2);
106 BOOST_CHECK_EQUAL(r.parameters[
"map"],
"myMapFile.xlmap");
107 BOOST_CHECK_EQUAL(r.parameters[
"a"],
"b");
112 BOOST_CHECK_EQUAL(r.backendType,
"x");
113 BOOST_CHECK_EQUAL(r.address,
"");
114 BOOST_CHECK_EQUAL(r.parameters.size(), 1);
115 BOOST_CHECK_EQUAL(r.parameters[
"a"],
"b=c");
121 BOOST_CHECK_EQUAL(r.backendType,
"x");
122 BOOST_CHECK_EQUAL(r.address,
"address?withQuestionmark");
123 BOOST_CHECK_EQUAL(r.parameters.size(), 3);
124 BOOST_CHECK_EQUAL(r.parameters[
"para"],
"value&with&ersand&");
125 BOOST_CHECK_EQUAL(r.parameters[
"x"],
"y\\");
126 BOOST_CHECK_EQUAL(r.parameters[
"y"],
")");
131 "anotherCdd=with(dummycdd)otherText)");
132 BOOST_CHECK_EQUAL(r.backendType,
"nested");
133 BOOST_CHECK_EQUAL(r.address,
"(pci:pcieunis6?map=dummy.map)");
134 BOOST_CHECK_EQUAL(r.parameters.size(), 1);
135 BOOST_CHECK_EQUAL(r.parameters[
"anotherCdd"],
"with(dummycdd)otherText");
159 BOOST_CHECK(sdm.
host ==
".");
161 BOOST_CHECK(sdm.
instance ==
"pcieunidummys6");
163 BOOST_CHECK(sdm.
protocol ==
"undefined");
166 BOOST_CHECK(sdm.
host ==
".");
169 BOOST_CHECK(sdm.
parameters.front() ==
"goodMapFile.map");
220 BOOST_CHECK(deviceInfo.deviceName ==
"DUMMYD0");
232 std::vector<std::string> expectedListOfAliases{
"PCIE1",
"PCIE0",
"PCIE2",
"PCIE3",
"PCIE0",
"DUMMYD0",
"DUMMYD1",
233 "DUMMYD2",
"DUMMYD3",
"DUMMYD9",
"PERFTEST",
"mskrebot",
"mskrebot1",
"OLD_PCIE",
"SEQUENCES",
234 "INVALID_SEQUENCES",
"PCIE_DOUBLEMAP",
"REBOT_DOUBLEMAP",
"REBOT_INVALID_HOST"};
241 BOOST_CHECK(returnedListOfAliases.size() == expectedListOfAliases.size());
242 for(
auto alias : expectedListOfAliases) {
243 BOOST_CHECK(alias == returnedListOfAliases.at(index++));
251 BOOST_TEST(ChimeraTK::userTypeToUserType<std::string>(myBool) ==
"true");
252 BOOST_TEST(ChimeraTK::userTypeToUserType<int32_t>(myBool) == 1);
255 BOOST_TEST(ChimeraTK::userTypeToUserType<std::string>(myBool) ==
"false");
256 BOOST_TEST(ChimeraTK::userTypeToUserType<int32_t>(myBool) == 0);
258 BOOST_TEST(ChimeraTK::userTypeToUserType<ChimeraTK::Boolean>(std::string(
"false")) ==
false);
259 BOOST_TEST(ChimeraTK::userTypeToUserType<ChimeraTK::Boolean>(std::string(
"False")) ==
false);
260 BOOST_TEST(ChimeraTK::userTypeToUserType<ChimeraTK::Boolean>(std::string(
"fAlSe")) ==
false);
261 BOOST_TEST(ChimeraTK::userTypeToUserType<ChimeraTK::Boolean>(std::string(
"0")) ==
false);
263 BOOST_TEST(ChimeraTK::userTypeToUserType<ChimeraTK::Boolean>(std::string(
"")) ==
false);
264 BOOST_TEST(ChimeraTK::userTypeToUserType<ChimeraTK::Boolean>(std::string(
"true")) ==
true);
265 BOOST_TEST(ChimeraTK::userTypeToUserType<ChimeraTK::Boolean>(std::string(
"TRUE")) ==
true);
266 BOOST_TEST(ChimeraTK::userTypeToUserType<ChimeraTK::Boolean>(std::string(
"anyOtherString")) ==
true);
272 BOOST_CHECK_NO_THROW(ChimeraTK::userTypeToUserType<uint64_t>(std::string(
"banana")));
273 BOOST_CHECK_NO_THROW(ChimeraTK::userTypeToUserType<uint64_t>(std::string(
"0xG")));
275 BOOST_TEST(ChimeraTK::userTypeToUserType<ChimeraTK::Boolean>(std::string(
"0x0")) ==
false);
276 BOOST_TEST(ChimeraTK::userTypeToUserType<ChimeraTK::Boolean>(std::string(
"0X1")) ==
true);
277 BOOST_TEST(ChimeraTK::userTypeToUserType<ChimeraTK::Boolean>(std::string(
"0x00BA0000F0cacc1a")) ==
279 BOOST_CHECK_NO_THROW(ChimeraTK::userTypeToUserType<ChimeraTK::Boolean>(std::string(
"0xDung")));
280 BOOST_CHECK_NO_THROW(ChimeraTK::userTypeToUserType<ChimeraTK::Boolean>(std::string(
"0x")));
284 BOOST_TEST(
static_cast<int32_t
>(ChimeraTK::userTypeToUserType<int8_t>(std::string(
"0x66"))) == 0x66);
286 static_cast<int32_t
>(ChimeraTK::userTypeToUserType<int8_t>(std::string(
"0X7F"))) == INT8_MAX);
287 BOOST_TEST(
static_cast<int32_t
>(ChimeraTK::userTypeToUserType<int8_t>(std::string(
"0x00BA0000F0cacc1a"))) ==
289 BOOST_CHECK_NO_THROW(ChimeraTK::userTypeToUserType<int8_t>(std::string(
"0xDung")));
290 BOOST_CHECK_NO_THROW(ChimeraTK::userTypeToUserType<int8_t>(std::string(
"0x")));
292 BOOST_TEST(
static_cast<uint32_t
>(ChimeraTK::userTypeToUserType<uint8_t>(std::string(
"0x66"))) == 0x66);
294 static_cast<uint32_t
>(ChimeraTK::userTypeToUserType<uint8_t>(std::string(
"0XFF"))) == UINT8_MAX);
295 BOOST_TEST(
static_cast<uint32_t
>(ChimeraTK::userTypeToUserType<uint8_t>(std::string(
"0x0"))) == 0);
296 BOOST_TEST(
static_cast<uint32_t
>(ChimeraTK::userTypeToUserType<uint8_t>(std::string(
"0x00BA0000F0cacc1a"))) ==
298 BOOST_CHECK_NO_THROW(ChimeraTK::userTypeToUserType<uint8_t>(std::string(
"0xDung")));
299 BOOST_CHECK_NO_THROW(ChimeraTK::userTypeToUserType<uint8_t>(std::string(
"0x")));
301 BOOST_TEST(ChimeraTK::userTypeToUserType<int16_t>(std::string(
"0x6666")) == 0x6666);
302 BOOST_TEST(ChimeraTK::userTypeToUserType<int16_t>(std::string(
"0X7FFF")) == INT16_MAX);
304 ChimeraTK::userTypeToUserType<int16_t>(std::string(
"0x00BA0000F0cacc1a")) == INT16_MAX);
305 BOOST_CHECK_NO_THROW(ChimeraTK::userTypeToUserType<int16_t>(std::string(
"0xDung")));
306 BOOST_CHECK_NO_THROW(ChimeraTK::userTypeToUserType<int16_t>(std::string(
"0x")));
308 BOOST_TEST(ChimeraTK::userTypeToUserType<uint16_t>(std::string(
"0x6666")) == 0x6666);
309 BOOST_TEST(ChimeraTK::userTypeToUserType<uint16_t>(std::string(
"0XFFFF")) == UINT16_MAX);
310 BOOST_TEST(ChimeraTK::userTypeToUserType<uint16_t>(std::string(
"0x0")) == 0);
312 ChimeraTK::userTypeToUserType<uint16_t>(std::string(
"0x00BA0000F0cacc1a")) == UINT16_MAX);
313 BOOST_CHECK_NO_THROW(ChimeraTK::userTypeToUserType<uint16_t>(std::string(
"0xDung")));
314 BOOST_CHECK_NO_THROW(ChimeraTK::userTypeToUserType<uint16_t>(std::string(
"0x")));
317 ChimeraTK::userTypeToUserType<int32_t>(std::string(
"0x66666666")) == 0x6666
'6666); // 0x6666'6666=1717986918 mid+
318 BOOST_TEST(ChimeraTK::userTypeToUserType<int32_t>(std::string(
"0X7FFFFFFF")) == INT32_MAX);
320 ChimeraTK::userTypeToUserType<int32_t>(std::string(
"0x00BA0000F0cacc1a")) == INT32_MAX);
321 BOOST_CHECK_NO_THROW(ChimeraTK::userTypeToUserType<int32_t>(std::string(
"0xDung")));
322 BOOST_CHECK_NO_THROW(ChimeraTK::userTypeToUserType<int32_t>(std::string(
"0x")));
324 BOOST_TEST(ChimeraTK::userTypeToUserType<uint32_t>(std::string(
"0x66666666")) == 0x6666
'6666); // mid+
325 BOOST_TEST(ChimeraTK::userTypeToUserType<uint32_t>(std::string("0XFFFFFFFF")) == UINT32_MAX); // max, big X
326 BOOST_TEST(ChimeraTK::userTypeToUserType<uint32_t>(std::string("0x0")) == 0); // min
328 ChimeraTK::userTypeToUserType<uint32_t>(std::string("0x00BA0000F0cacc1a")) == UINT32_MAX); // overflow, mixed case
329 BOOST_CHECK_NO_THROW(ChimeraTK::userTypeToUserType<uint32_t>(std::string("0xDung"))); // invalid
330 BOOST_CHECK_NO_THROW(ChimeraTK::userTypeToUserType<uint32_t>(std::string("0x"))); // empty test
332 BOOST_TEST(ChimeraTK::userTypeToUserType<int64_t>(std::string("0x6666666666666666")) ==
333 0x6666'6666
'6666'6666);
334 BOOST_TEST(ChimeraTK::userTypeToUserType<int64_t>(std::string(
"0X7FFFFFFFFFFFFFFF")) == INT64_MAX);
336 ChimeraTK::userTypeToUserType<int64_t>(std::string(
"0x100BA0000F0cacc1a")) == INT64_MAX);
338 BOOST_CHECK_NO_THROW(
339 ChimeraTK::userTypeToUserType<int64_t>(std::string(
"0xdung")));
340 BOOST_CHECK_NO_THROW(ChimeraTK::userTypeToUserType<int64_t>(std::string(
"0x")));
343 ChimeraTK::userTypeToUserType<uint64_t>(std::string(
"0xC0CAC01AADD511FE")) == 0xC0CA
'C01A'ADD5
'11FE); // mid+
344 BOOST_TEST(ChimeraTK::userTypeToUserType<uint64_t>(std::string("0XFFFFFFFFFFFFFFFF")) == UINT64_MAX); // max, big X
345 BOOST_TEST(ChimeraTK::userTypeToUserType<uint64_t>(std::string("0x0")) == 0); // min
346 BOOST_TEST(ChimeraTK::userTypeToUserType<uint64_t>(std::string("0xFFFFFFFFFF0cacc1a")) ==
347 UINT64_MAX); // overflow, mixed case
348 BOOST_CHECK_NO_THROW(ChimeraTK::userTypeToUserType<uint64_t>(std::string("0xDung"))); // invalid
349 BOOST_CHECK_NO_THROW(ChimeraTK::userTypeToUserType<uint64_t>(std::string("0x"))); // empty test
351 BOOST_CHECK_CLOSE(ChimeraTK::userTypeToUserType<float>(std::string("0x66666666")), 1.71799e9, 1.71799e5);
352 BOOST_CHECK_NO_THROW(ChimeraTK::userTypeToUserType<float>(std::string("0xDung"))); // invalid
353 BOOST_CHECK_NO_THROW(ChimeraTK::userTypeToUserType<float>(std::string("0x"))); // empty test
356 ChimeraTK::userTypeToUserType<double>(std::string("0x6666666666666666")), 7.3786976e18, 7.3786976e14); // mid+
357 BOOST_CHECK_NO_THROW(ChimeraTK::userTypeToUserType<double>(std::string("0xDung"))); // invalid
358 BOOST_CHECK_NO_THROW(ChimeraTK::userTypeToUserType<double>(std::string("0x"))); // empty test
360 BOOST_TEST(ChimeraTK::userTypeToUserType<std::string>(std::string("0xDung")) == "0xDung");
363 /**********************************************************************************************************************/
365 BOOST_AUTO_TEST_CASE(testUserTypeToUserType_DecString) {
366 BOOST_TEST(ChimeraTK::userTypeToUserType<ChimeraTK::Boolean>(std::string("0")) == false); // mid+, min
367 BOOST_TEST(ChimeraTK::userTypeToUserType<ChimeraTK::Boolean>(std::string("1")) == true); // max
368 BOOST_TEST(ChimeraTK::userTypeToUserType<ChimeraTK::Boolean>(std::string("2")) == true); // overflow
370 ChimeraTK::userTypeToUserType<ChimeraTK::Boolean>(std::string("-7378697629483820646")) == true); // underflow
371 // invalid case is done in testUserTypeToUserType_Boolean
373 BOOST_TEST(static_cast<int32_t>(ChimeraTK::userTypeToUserType<int8_t>(std::string("102"))) == 102); // mid+
374 BOOST_TEST(static_cast<int32_t>(ChimeraTK::userTypeToUserType<int8_t>(std::string("-102"))) == -102); // mid-
375 BOOST_TEST(static_cast<int32_t>(ChimeraTK::userTypeToUserType<int8_t>(std::string("127"))) == INT8_MAX); // max
376 BOOST_TEST(static_cast<int32_t>(ChimeraTK::userTypeToUserType<int8_t>(std::string("-128"))) == INT8_MIN); // min
377 BOOST_TEST(static_cast<int32_t>(ChimeraTK::userTypeToUserType<int8_t>(std::string("300"))) == INT8_MAX); // overflow
378 BOOST_TEST(static_cast<int32_t>(ChimeraTK::userTypeToUserType<int8_t>(std::string("-300"))) == INT8_MIN); // underflow
379 // FIXME make this pass
381 // static_cast<int32_t>(ChimeraTK::userTypeToUserType<int8_t>(std::string("73786976294838206460"))) == INT8_MAX);
384 // FIXME make this pass
386 // static_cast<int32_t>(ChimeraTK::userTypeToUserType<int8_t>(std::string("-73786976294838206460"))) == INT8_MIN);
389 BOOST_CHECK_NO_THROW(ChimeraTK::userTypeToUserType<int8_t>(std::string("banana"))); // invalid
391 BOOST_TEST(static_cast<int32_t>(ChimeraTK::userTypeToUserType<uint8_t>(std::string("102"))) == 102); // mid+
392 BOOST_TEST(static_cast<int32_t>(ChimeraTK::userTypeToUserType<uint8_t>(std::string("255"))) == UINT8_MAX); // max
393 BOOST_TEST(static_cast<int32_t>(ChimeraTK::userTypeToUserType<uint8_t>(std::string("0"))) == 0); // min
394 BOOST_TEST(static_cast<int32_t>(ChimeraTK::userTypeToUserType<uint8_t>(std::string("300"))) == UINT8_MAX); // overflow
395 BOOST_TEST(static_cast<int32_t>(ChimeraTK::userTypeToUserType<uint8_t>(std::string("-5"))) == 0); // underflow pass
396 BOOST_CHECK_NO_THROW(ChimeraTK::userTypeToUserType<uint8_t>(std::string("banana"))); // invalid
398 BOOST_TEST(ChimeraTK::userTypeToUserType<int16_t>(std::string("26214")) == 26214); // mid+
399 BOOST_TEST(ChimeraTK::userTypeToUserType<int16_t>(std::string("-26214")) == -26214); // mid-
400 BOOST_TEST(ChimeraTK::userTypeToUserType<int16_t>(std::string("32767")) == INT16_MAX); // max
401 BOOST_TEST(ChimeraTK::userTypeToUserType<int16_t>(std::string("-32768")) == INT16_MIN); // min
402 BOOST_TEST(ChimeraTK::userTypeToUserType<int16_t>(std::string("73786976294838206460")) == INT16_MAX); // overflow
403 BOOST_TEST(ChimeraTK::userTypeToUserType<int16_t>(std::string("-73786976294838206460")) == INT16_MIN); // underflow
404 BOOST_CHECK_NO_THROW(ChimeraTK::userTypeToUserType<int16_t>(std::string("banana"))); // invalid
406 BOOST_TEST(ChimeraTK::userTypeToUserType<uint16_t>(std::string("26214")) == 26214); // mid+
407 BOOST_TEST(ChimeraTK::userTypeToUserType<uint16_t>(std::string("65535")) == UINT16_MAX); // max
408 BOOST_TEST(ChimeraTK::userTypeToUserType<uint16_t>(std::string("0")) == 0); // min
409 BOOST_TEST(ChimeraTK::userTypeToUserType<uint16_t>(std::string("73786976294838206460")) == UINT16_MAX); // overflow
410 // FIXME make this pass
411 // BOOST_TEST(ChimeraTK::userTypeToUserType<uint16_t>(std::string("-73786976294838206460")) == 0); // underflow
412 // FIXME make this pass
413 // BOOST_TEST(ChimeraTK::userTypeToUserType<uint16_t>(std::string("-5")) == 0); // underflow fail -5 = 65531.
415 BOOST_CHECK_NO_THROW(ChimeraTK::userTypeToUserType<uint16_t>(std::string("banana"))); // invalid
417 BOOST_TEST(ChimeraTK::userTypeToUserType<int32_t>(std::string("1717986918")) == 1717986918); // mid+
418 BOOST_TEST(ChimeraTK::userTypeToUserType<int32_t>(std::string("-1717986918")) == -1717986918); // mid-
419 BOOST_TEST(ChimeraTK::userTypeToUserType<int32_t>(std::string("2147483647")) == INT32_MAX); // max
420 BOOST_TEST(ChimeraTK::userTypeToUserType<int32_t>(std::string("-2147483648")) == INT32_MIN); // min
421 BOOST_TEST(ChimeraTK::userTypeToUserType<int32_t>(std::string("73786976294838206460")) == INT32_MAX); // overflow
422 BOOST_TEST(ChimeraTK::userTypeToUserType<int32_t>(std::string("-73786976294838206460")) == INT32_MIN); // underflow
423 BOOST_TEST(ChimeraTK::userTypeToUserType<int32_t>(std::string("banana")) == 0); // invalid
425 BOOST_TEST(ChimeraTK::userTypeToUserType<uint32_t>(std::string("1717986918")) == 1717986918); // mid+
426 BOOST_TEST(ChimeraTK::userTypeToUserType<uint32_t>(std::string("4294967295")) == UINT32_MAX); // max
427 BOOST_TEST(ChimeraTK::userTypeToUserType<uint32_t>(std::string("0")) == 0); // min
428 BOOST_TEST(ChimeraTK::userTypeToUserType<uint32_t>(std::string("73786976294838206460")) == UINT32_MAX); // overflow
429 // FIXME make this pass
430 // BOOST_TEST(ChimeraTK::userTypeToUserType<uint32_t>(std::string("-73786976294838206460")) == 0); // underflow
431 // FIXME make this pass
432 // BOOST_TEST(ChimeraTK::userTypeToUserType<uint32_t>(std::string("-5")) == 0); // underflow
433 BOOST_TEST(ChimeraTK::userTypeToUserType<uint32_t>(std::string("banana")) == 0); // invalid
435 BOOST_TEST(ChimeraTK::userTypeToUserType<int64_t>(std::string("7378697629483820646")) == 7378697629483820646); // mid+
437 ChimeraTK::userTypeToUserType<int64_t>(std::string("-7378697629483820646")) == -7378697629483820646); // mid-
438 BOOST_TEST(ChimeraTK::userTypeToUserType<int64_t>(std::string("9223372036854775807")) == INT64_MAX); // max
439 BOOST_TEST(ChimeraTK::userTypeToUserType<int64_t>(std::string("-9223372036854775808")) == INT64_MIN); // min
440 BOOST_TEST(ChimeraTK::userTypeToUserType<int64_t>(std::string("9223372036854775810")) == INT64_MAX); // overflow
441 BOOST_TEST(ChimeraTK::userTypeToUserType<int64_t>(std::string("-9223372036854775810")) == INT64_MIN); // underflow
442 // The previous two lines are likely to run out of room and report 0
443 BOOST_TEST(ChimeraTK::userTypeToUserType<int64_t>(std::string("banana")) == 0); // invalid
446 ChimeraTK::userTypeToUserType<uint64_t>(std::string("7378697629483820646")) == 7378697629483820646); // mid+
447 BOOST_TEST(ChimeraTK::userTypeToUserType<uint64_t>(std::string("18446744073709551615")) == UINT64_MAX); // max
448 BOOST_TEST(ChimeraTK::userTypeToUserType<uint64_t>(std::string("0")) == 0); // min
449 BOOST_TEST(ChimeraTK::userTypeToUserType<uint64_t>(std::string("18446744073709551625")) == UINT64_MAX); // overflow
450 // FIXME make this pass
451 // BOOST_TEST(ChimeraTK::userTypeToUserType<uint64_t>(std::string("-18446744073709551625")) == 0); // underflow
452 // FIXME make this pass
453 // BOOST_TEST(ChimeraTK::userTypeToUserType<uint64_t>(std::string("-5")) == 0); // underflow
454 BOOST_TEST(ChimeraTK::userTypeToUserType<uint64_t>(std::string("banana")) == 0); // invalid
456 BOOST_CHECK_CLOSE(ChimeraTK::userTypeToUserType<float>(std::string("3.14159")), 3.14159, 3.14159 / 1000.0); // mid+
458 ChimeraTK::userTypeToUserType<float>(std::string("-3.14159e3")), -3.14159e3, 3.14159e3 / 1000.0); // mid-
459 BOOST_CHECK_CLOSE(ChimeraTK::userTypeToUserType<float>(std::string("3.40282e38")), std::numeric_limits<float>::max(),
460 std::numeric_limits<float>::max() / 1000.); // max
461 BOOST_CHECK_CLOSE(ChimeraTK::userTypeToUserType<float>(std::string("-3.40282e38")),
462 (-std::numeric_limits<float>::max()), std::numeric_limits<float>::max() / 1000.); // min
463 BOOST_CHECK_CLOSE(ChimeraTK::userTypeToUserType<float>(std::string("5.40282e39")), std::numeric_limits<float>::max(),
464 std::numeric_limits<float>::max() / 1000.); // overflow
465 BOOST_CHECK_CLOSE(ChimeraTK::userTypeToUserType<float>(std::string("-5.40282e39")),
466 (-std::numeric_limits<float>::max()), std::numeric_limits<float>::max() / 1000.); // underflow
467 BOOST_TEST(ChimeraTK::userTypeToUserType<float>(std::string("banana")) == 0.f); // invalid
469 ChimeraTK::userTypeToUserType<float>(std::string("5")), 5.0f, 5.0 / 1000.); // float-int conversion good
471 BOOST_CHECK_CLOSE(ChimeraTK::userTypeToUserType<double>(std::string("2.718281828459")), 2.718281828459,
472 2.718281828459 / 1000.0); // mid+
473 BOOST_CHECK_CLOSE(ChimeraTK::userTypeToUserType<double>(std::string("-2.718281828459e3")), -2.718281828459e3,
474 2.718281828459e3 / 1000.0); // mid-
475 BOOST_CHECK_CLOSE(ChimeraTK::userTypeToUserType<double>(std::string("1.7976931e+308")),
476 std::numeric_limits<double>::max(), std::numeric_limits<double>::max() / 1000.); // max
477 BOOST_CHECK_CLOSE(ChimeraTK::userTypeToUserType<double>(std::string("-1.7976931e+308")),
478 (-std::numeric_limits<double>::max()), std::numeric_limits<double>::max() / 1000.); // min
479 BOOST_CHECK_CLOSE(ChimeraTK::userTypeToUserType<double>(std::string("1.8976931e+309")),
480 std::numeric_limits<double>::max(), std::numeric_limits<double>::max() / 1000.); // overflow
481 BOOST_CHECK_CLOSE(ChimeraTK::userTypeToUserType<double>(std::string("-1.8976931e+309")),
482 (-std::numeric_limits<double>::max()), std::numeric_limits<double>::max() / 1000.); // underflow
484 ChimeraTK::userTypeToUserType<double>(std::string("5")), 5.0, 5.0 / 1000.); // double-int conversion good
485 BOOST_TEST(ChimeraTK::userTypeToUserType<double>(std::string("banana")) == 0.0); // invalid
487 BOOST_TEST(ChimeraTK::userTypeToUserType<std::string>(std::string("Any\r\nthing")) == "Any\r\nthing");