4 #define BOOST_TEST_DYN_LINK
5 #define BOOST_TEST_MODULE FixedPointConverterTest
6 #include <boost/test/unit_test.hpp>
7 using namespace boost::unit_test_framework;
24 #define HEX_TO_DOUBLE(INPUT) static_cast<double>(INPUT)
25 #define SIGNED_HEX_TO_DOUBLE(INPUT) static_cast<double>(static_cast<int32_t>(INPUT))
26 #define SIGNED_HEX_TO_INT64(INPUT) static_cast<int64_t>(static_cast<int32_t>(INPUT))
28 #define CHECK_SIGNED_FIXED_POINT_NO_FRACTIONAL \
29 checkToFixedPoint(converter, 0.25, 0); \
30 checkToFixedPoint(converter, -0.25, 0); \
31 checkToFixedPoint(converter, 0.75, 1); \
32 checkToFixedPoint(converter, -0.75, -1); \
33 checkToFixedPoint(converter, 3.25, 3); \
34 checkToFixedPoint(converter, -3.25, -3); \
35 checkToFixedPoint(converter, 5.75, 6); \
36 checkToFixedPoint(converter, -5.75, -6);
52 #define DEF_TYPENAME(name) \
54 inline const char* typeName<name>(void) { \
72 BOOST_CHECK_EQUAL(converter.
scalarToCooked<T>(input), std::numeric_limits<T>::min());
77 BOOST_CHECK_EQUAL(converter.
scalarToCooked<T>(input), std::numeric_limits<T>::max());
82 std::stringstream message;
83 message <<
"testToCooked failed for type " << typeName<T>() <<
" with input " << std::hex <<
"0x" << input << std::hex
84 <<
", expected 0x" << expectedValue << std::dec;
86 BOOST_TEST_CHECKPOINT(message.str());
90 message << std::hex <<
", output 0x" << output << std::dec;
92 BOOST_CHECK_MESSAGE(output == expectedValue, message.str());
97 std::stringstream message;
98 message <<
"testToRaw failed for type " << typeName<T>() <<
" with input 0x" << std::hex << input <<
", expected 0x"
99 << expectedValue << std::dec;
101 BOOST_TEST_CHECKPOINT(message.str());
103 uint32_t result = converter.
toRaw(input);
105 message << std::hex <<
", output 0x" << result << std::dec;
107 BOOST_CHECK_MESSAGE(result == expectedValue, message.str());
110 BOOST_AUTO_TEST_SUITE(FixedPointConverterTestSuite)
135 checkToCookedOverflowNeg<unsigned int>(converter, 0xAAAAAAAA);
136 checkToCooked(converter, 0x55555555, (
unsigned int)0x55555555);
137 checkToCookedOverflowNeg<short>(converter, 0xAAAAAAAA);
138 checkToCookedOverflowPos<short>(converter, 0x55555555);
139 checkToCookedOverflowNeg<unsigned short>(converter, 0xAAAAAAAA);
140 checkToCookedOverflowPos<unsigned short>(converter, 0x55555555);
151 checkToRaw(converter, (
int)0x55555555, 0x55555555);
152 checkToRaw(converter, (
int)0xAAAAAAAA, 0xAAAAAAAA);
153 checkToRaw(converter, (
unsigned int)0x55555555, 0x55555555);
154 checkToRaw(converter, (
unsigned int)0xAAAAAAAA, 0x7FFFFFFF);
156 checkToRaw(converter, (
short)0xAAAA, 0xFFFFAAAA);
157 checkToRaw(converter, (
unsigned short)0x5555, 0x5555);
158 checkToRaw(converter, (
unsigned short)0xAAAA, 0xAAAA);
159 checkToRaw(converter, (int64_t)0x5555, 0x5555);
160 checkToRaw(converter, (int64_t)0xFFFFFFFFFFFFAAAA, 0xFFFFAAAA);
161 checkToRaw(converter, (int64_t)0xFFFFFFFAAAAAAAAA,
163 checkToRaw(converter, (int64_t)0xFFFFFFFFF, 0x7FFFFFFF);
167 checkToCooked(converter, 0x55555555, std::string(
"1431655765"));
168 checkToRaw(converter, std::string(
"1431655765"), 0x55555555);
180 checkToCookedOverflowPos<int>(converter, 0xAAAAAAAA);
182 checkToCooked(converter, 0xAAAAAAAA, (
unsigned int)0xAAAAAAAA);
183 checkToCooked(converter, 0x55555555, (
unsigned int)0x55555555);
184 checkToCookedOverflowPos<short>(converter, 0xAAAAAAAA);
185 checkToCookedOverflowPos<unsigned short>(converter, 0x55555555);
198 checkToRaw(converter, (
int)0x55555555, 0x55555555);
200 checkToRaw(converter, (
unsigned int)0x55555555, 0x55555555);
201 checkToRaw(converter, (
unsigned int)0xAAAAAAAA, 0xAAAAAAAA);
204 checkToRaw(converter, (
unsigned short)0x5555, 0x5555);
205 checkToRaw(converter, (
unsigned short)0xAAAA, 0xAAAA);
206 checkToRaw(converter, (int64_t)0x5555, 0x5555);
209 checkToRaw(converter, (int64_t)0x100000000, 0xFFFFFFFF);
213 checkToCooked(converter, 0x55555555, std::string(
"1431655765"));
214 checkToRaw(converter, std::string(
"1431655765"), 0x55555555);
216 checkToCooked(converter, 0xAAAAAAAA, std::string(
"2863311530"));
217 checkToRaw(converter, std::string(
"2863311530"), 0xAAAAAAAA);
230 checkToCookedOverflowNeg<unsigned int>(converter, 0xAAAA);
234 checkToCookedOverflowNeg<unsigned short>(converter, 0xAAAA);
237 checkToCooked(converter, 0xAAAA,
static_cast<int64_t
>(
static_cast<int16_t
>(0xAAAA)));
240 checkToCookedOverflowNeg<uint64_t>(converter, 0xAAAA);
251 checkToRaw(converter, (
int)0x55555555, 0x7FFF);
252 checkToRaw(converter, (
int)0xAAAAAAAA, 0x8000);
253 checkToRaw(converter, (
unsigned int)0x55555555, 0x7FFF);
254 checkToRaw(converter, (
unsigned int)0xAAAAAAAA, 0x7FFF);
257 checkToRaw(converter, (
unsigned short)0x5555, 0x5555);
258 checkToRaw(converter, (
unsigned short)0xAAAA, 0x7FFF);
259 checkToRaw(converter, (int64_t)0x5555, 0x5555);
260 checkToRaw(converter,
static_cast<int64_t
>(
static_cast<int16_t
>(0xAAAA)), 0xAAAA);
261 checkToRaw(converter, (int64_t)0x555555, 0x7FFF);
262 checkToRaw(converter,
static_cast<int64_t
>(
static_cast<int32_t
>(0xAAAAAAAA)), 0x8000);
263 checkToRaw(converter, (uint64_t)0x5555, 0x5555);
265 checkToRaw(converter, (uint64_t)0xF555, 0x7FFF);
278 checkToCookedOverflowPos<short>(converter, 0xAAAA);
296 checkToRaw(converter, (
int)0x55555555, 0xFFFF);
298 checkToRaw(converter, (
unsigned int)0x55555555, 0xFFFF);
299 checkToRaw(converter, (
unsigned int)0xAAAAAAAA, 0xFFFF);
302 checkToRaw(converter, (
unsigned short)0x5555, 0x5555);
303 checkToRaw(converter, (
unsigned short)0xAAAA, 0xAAAA);
304 checkToRaw(converter, (int64_t)0x5555, 0x5555);
305 checkToRaw(converter,
static_cast<int64_t
>(
static_cast<int16_t
>(0xAAAA)), 0);
306 checkToRaw(converter, (int64_t)0x555555, 0xFFFF);
307 checkToRaw(converter, (uint64_t)0x5555, 0x5555);
309 checkToRaw(converter, (uint64_t)0xFF555, 0xFFFF);
320 checkToCookedOverflowNeg<unsigned int>(converter, 0xAA);
324 checkToCookedOverflowNeg<unsigned short>(converter, 0xAA);
327 checkToCooked(converter, 0xAA,
static_cast<int64_t
>(
static_cast<int8_t
>(0xAA)));
329 checkToCookedOverflowNeg<uint64_t>(converter, 0xAA);
342 checkToRaw(converter, (
unsigned int)0x55555555, 0x7F);
343 checkToRaw(converter, (
unsigned int)0xAAAAAAAA, 0x7F);
346 checkToRaw(converter, (
unsigned short)0x5555, 0x7F);
347 checkToRaw(converter, (
unsigned short)0xAAAA, 0x7F);
350 checkToRaw(converter,
static_cast<int64_t
>(
static_cast<int8_t
>(0xAA)), 0xAA);
352 checkToRaw(converter,
static_cast<int64_t
>(
static_cast<int32_t
>(0xAAAAAAAA)), 0x80);
387 checkToRaw(converter, (
unsigned int)0x55555555, 0xFF);
388 checkToRaw(converter, (
unsigned int)0xAAAAAAAA, 0xFF);
391 checkToRaw(converter, (
unsigned short)0x5555, 0xFF);
392 checkToRaw(converter, (
unsigned short)0xAAAA, 0xFF);
394 checkToRaw(converter,
static_cast<int64_t
>(
static_cast<int16_t
>(0xAAAA)), 0);
395 checkToRaw(converter, (int64_t)0x555555, 0xFF);
398 checkToRaw(converter, (uint64_t)0xFF555, 0xFF);
408 checkToCookedOverflowPos<int>(converter, 0x000AAAAA);
411 checkToCookedOverflowNeg<unsigned int>(converter, 0xFFFAAAAA);
412 checkToCooked(converter, 0x00055555, (
unsigned int)0x55555000);
413 checkToCooked(converter, 0x000AAAAA, (
unsigned int)0xAAAAA000);
414 checkToCooked(converter, 0xAAAAAAAA, (int64_t)0xFFFFFAAAAAAAA000);
415 checkToCooked(converter, 0x55555555, (int64_t)0x55555555000);
416 checkToCooked(converter, 0x55555555, (uint64_t)0x55555555000);
417 checkToCookedOverflowNeg<uint64_t>(converter, 0xAAAAAAAA);
428 checkToRaw(converter, (
int)0x55555555, 0x00055555);
429 checkToRaw(converter, (
int)0xAAAAAAAA, 0xFFFAAAAB);
430 checkToRaw(converter, (
unsigned int)0x55555555, 0x00055555);
431 checkToRaw(converter, (
unsigned int)0xAAAAAAAA, 0x000AAAAB);
432 checkToRaw(converter, (
short)0x5555, 0x00000005);
433 checkToRaw(converter, (
short)0xAAAA, 0xFFFFFFFB);
434 checkToRaw(converter, (
unsigned short)0x5555, 0x00000005);
435 checkToRaw(converter, (
unsigned short)0xAAAA, 0x0000000B);
436 checkToRaw(converter, (int64_t)0x55555555, 0x00055555);
437 checkToRaw(converter,
static_cast<int64_t
>(
static_cast<int32_t
>(0xAAAAAAAA)), 0XFFFAAAAB);
438 checkToRaw(converter, (int64_t)0x5555555555555, 0x7fffffff);
439 checkToRaw(converter, (int64_t)0xFFFFA55555555555, 0x80000000);
440 checkToRaw(converter, (uint64_t)0x55555, 0x00000055);
441 checkToRaw(converter, (uint64_t)0x5555555555555, 0X7FFFFFFF);
451 checkToCookedOverflowPos<int>(converter, 0x000AAAAA);
453 checkToCooked(converter, 0x00055555, (
unsigned int)0x55555000);
454 checkToCooked(converter, 0x000AAAAA, (
unsigned int)0xAAAAA000);
455 checkToCookedOverflowPos<unsigned short>(converter, 0x000AAAAA);
458 checkToCooked(converter, 0xAAAAAAAA, (int64_t)0xAAAAAAAA000);
460 checkToCooked(converter, 0xAAAAAAAA, (uint64_t)0xAAAAAAAA000);
471 checkToRaw(converter, (
int)0x55555555, 0x00055555);
473 checkToRaw(converter, (
unsigned int)0x55555555, 0x00055555);
474 checkToRaw(converter, (
unsigned int)0xAAAAAAAA, 0x000AAAAB);
475 checkToRaw(converter, (
short)0x5555, 0x00000005);
477 checkToRaw(converter, (
unsigned short)0x5555, 0x00000005);
478 checkToRaw(converter, (
unsigned short)0xAAAA, 0x0000000B);
479 checkToRaw(converter, (int64_t)0x55555555, 0x00055555);
480 checkToRaw(converter,
static_cast<int64_t
>(
static_cast<int32_t
>(0xAAAAAAAA)), 0x0);
481 checkToRaw(converter, (int64_t)0x5555555555555, 0xFFFFFFFF);
482 checkToRaw(converter, (uint64_t)0x55555, 0x00000055);
483 checkToRaw(converter, (uint64_t)0x5555555555555, 0XFFFFFFFF);
492 checkToCookedOverflowNeg<int>(converter, 0xAAAAAAAA);
493 checkToCookedOverflowPos<int>(converter, 0x55555555);
495 checkToCookedOverflowNeg<unsigned int>(converter, 0xAAAAAAAA);
496 checkToCooked(converter, 0x55555555, (
unsigned int)0xAAAAAAAA);
497 checkToCooked(converter, 0x22222202, (
unsigned int)0x44444404);
498 checkToCooked(converter, 0x7FFFFFFF, (
unsigned int)0xFFFFFFFE);
499 checkToCooked(converter, 0xAAAAAAAA, (int64_t)0xFFFFFFFF55555554);
513 checkToRaw(converter, (
int)0x55555554, 0x2AAAAAAA);
514 checkToRaw(converter, (
int)0x55555555, 0x2AAAAAAB);
515 checkToRaw(converter, (
int)0x55555556, 0x2AAAAAAB);
516 checkToRaw(converter, (
int)0xAAAAAAAA, 0xD5555555);
517 checkToRaw(converter, (
unsigned int)0x55555555, 0x2AAAAAAB);
518 checkToRaw(converter, (
unsigned int)0xAAAAAAAA, 0x55555555);
519 checkToRaw(converter, (
short)0x5555, 0x00002AAB);
520 checkToRaw(converter, (
short)0xAAAA, 0xFFFFD555);
521 checkToRaw(converter, (
unsigned short)0x5555, 0x00002AAB);
522 checkToRaw(converter, (
unsigned short)0xAAAA, 0x00005555);
523 checkToRaw(converter,
static_cast<int64_t
>(
static_cast<int32_t
>(0xAAAAAAAA)), 0xD5555555);
524 checkToRaw(converter,
static_cast<uint64_t
>(0xAAAAAAAA), 0x55555555);
535 checkToCooked(converter, 0x55555555, (
unsigned int)0xAAAAAAAA);
536 checkToCooked(converter, 0x22222202, (
unsigned int)0x44444404);
550 checkToRaw(converter, (
int)0x55555555, 0x2AAAAAAB);
552 checkToRaw(converter, (
unsigned int)0x55555555, 0x2AAAAAAB);
553 checkToRaw(converter, (
unsigned int)0xAAAAAAAA, 0x55555555);
554 checkToRaw(converter, (
short)0x5555, 0x00002AAB);
556 checkToRaw(converter, (
unsigned short)0x5555, 0x00002AAB);
557 checkToRaw(converter, (
unsigned short)0xAAAA, 0x00005555);
565 checkToCookedOverflowNeg<int16_t>(converter, 0xAAAAAAAA);
566 checkToCookedOverflowPos<int16_t>(converter, 0x55555555);
568 checkToCookedOverflowNeg<unsigned int>(converter, 0xAAAA);
572 checkToCooked(converter, 0xAAAAAAAA, (int64_t)0xFFFFFFFFFFFF5554);
589 checkToRaw(converter, (
int)0xFFFFAAAA, 0xD555);
590 checkToRaw(converter, (
unsigned int)0x5555, 0x2AAB);
591 checkToRaw(converter, (
unsigned int)0xAAAA, 0x5555);
592 checkToRaw(converter, (
short)0x5555, 0x00002AAB);
594 checkToRaw(converter, (
unsigned short)0x5555, 0x00002AAB);
595 checkToRaw(converter, (
unsigned short)0xAAAA, 0x00005555);
596 checkToRaw(converter,
static_cast<int64_t
>(
static_cast<int32_t
>(0xFFFFAAAA)), 0xD555);
597 checkToRaw(converter,
static_cast<uint64_t
>(0xAAAA), 0x5555);
624 checkToRaw(converter, (
unsigned int)0x5555, 0x2AAB);
625 checkToRaw(converter, (
unsigned int)0xAAAA, 0x5555);
626 checkToRaw(converter, (
short)0x5555, 0x00002AAB);
628 checkToRaw(converter, (
unsigned short)0x5555, 0x00002AAB);
629 checkToRaw(converter, (
unsigned short)0xAAAA, 0x00005555);
646 checkToCooked(converter, 0x55555555, (
unsigned int)0x2AAAAAAB);
647 checkToCooked(converter, 0x22222202, (
unsigned int)0x11111101);
648 checkToCooked(converter, 0xAAAAAAAA, (int64_t)0xFFFFFFFFD5555555);
661 checkToRaw(converter, (
int)0x55555555, 0x7FFFFFFF);
662 checkToRaw(converter, (
int)0xAAAAAAAA, 0x80000000);
663 checkToRaw(converter, (
int)0x22222202, 0x44444404);
664 checkToRaw(converter, (
int)0xE2222202, 0xC4444404);
665 checkToRaw(converter, (
unsigned int)0x55555555, 0x7FFFFFFF);
666 checkToRaw(converter, (
unsigned int)0xAAAAAAAA, 0x7FFFFFFF);
667 checkToRaw(converter, (
unsigned int)0x22222202, 0x44444404);
668 checkToRaw(converter, (
unsigned int)0xE2222202, 0x7FFFFFFF);
669 checkToRaw(converter, (
short)0x5555, 0x0000AAAA);
670 checkToRaw(converter, (
short)0xAAAA, 0xFFFF5554);
671 checkToRaw(converter, (
unsigned short)0x5555, 0x0000AAAA);
672 checkToRaw(converter, (
unsigned short)0xAAAA, 0x00015554);
673 checkToRaw(converter,
static_cast<int64_t
>(
static_cast<int32_t
>(0xFAAAAAAA)), 0XF5555554);
674 checkToRaw(converter,
static_cast<uint64_t
>(0xAAAAAAA), 0X15555554);
686 checkToCooked(converter, 0xAAAAAAAA, (
unsigned int)0x55555555);
687 checkToCooked(converter, 0x55555555, (
unsigned int)0x2AAAAAAB);
688 checkToCooked(converter, 0x22222202, (
unsigned int)0x11111101);
702 checkToRaw(converter, (
int)0x55555555, 0xAAAAAAAA);
704 checkToRaw(converter, (
int)0x22222202, 0x44444404);
706 checkToRaw(converter, (
unsigned int)0x55555555, 0xAAAAAAAA);
707 checkToRaw(converter, (
unsigned int)0xAAAAAAAA, 0xFFFFFFFF);
708 checkToRaw(converter, (
unsigned int)0x22222202, 0x44444404);
709 checkToRaw(converter, (
unsigned int)0xE2222202, 0xFFFFFFFF);
710 checkToRaw(converter, (
short)0x5555, 0x0000AAAA);
712 checkToRaw(converter, (
unsigned short)0x5555, 0x0000AAAA);
713 checkToRaw(converter, (
unsigned short)0xAAAA, 0x00015554);
714 checkToRaw(converter,
static_cast<int64_t
>(
static_cast<int32_t
>(0xFAAAAAAA)), 0x0);
715 checkToRaw(converter,
static_cast<uint64_t
>(0xFAAAAAAA), 0XFFFFFFFF);
736 checkToCooked(converter, 0x55555555, (
unsigned int)0x00AAAAAB);
737 checkToCooked(converter, 0x22220222, (
unsigned int)0x00444404);
749 checkToRaw(converter, (
int)0x55555555, 0x7FFFFFFF);
750 checkToRaw(converter, (
int)0xAAAAAAAA, 0x80000000);
751 checkToRaw(converter, (
int)0x00888808, 0x44440400);
752 checkToRaw(converter, (
int)0xFF888808, 0xC4440400);
753 checkToRaw(converter, (
unsigned int)0x55555555, 0x7FFFFFFF);
754 checkToRaw(converter, (
unsigned int)0xAAAAAAAA, 0x7FFFFFFF);
755 checkToRaw(converter, (
unsigned int)0x00888808, 0x44440400);
756 checkToRaw(converter, (
unsigned int)0xFF888808, 0x7FFFFFFF);
757 checkToRaw(converter, (
short)0x5555, 0x002AAA80);
758 checkToRaw(converter, (
short)0xAAAA, 0xFFD55500);
759 checkToRaw(converter, (
unsigned short)0x5555, 0x002AAA80);
760 checkToRaw(converter, (
unsigned short)0xAAAA, 0x00555500);
763 checkToRaw(converter, std::string(
"0.25"), 0x20);
775 checkToCooked(converter, 0xAAAAAAAA, (
unsigned int)0x01555555);
776 checkToCooked(converter, 0x55555555, (
unsigned int)0x00AAAAAB);
777 checkToCooked(converter, 0x22220222, (
unsigned int)0x00444404);
789 checkToRaw(converter, (
int)0x55555555, 0xFFFFFFFF);
791 checkToRaw(converter, (
int)0x00888808, 0x44440400);
793 checkToRaw(converter, (
unsigned int)0x55555555, 0xFFFFFFFF);
794 checkToRaw(converter, (
unsigned int)0xAAAAAAAA, 0xFFFFFFFF);
795 checkToRaw(converter, (
unsigned int)0x00888808, 0x44440400);
796 checkToRaw(converter, (
unsigned int)0xFF888808, 0xFFFFFFFF);
797 checkToRaw(converter, (
short)0x5555, 0x002AAA80);
799 checkToRaw(converter, (
unsigned short)0x5555, 0x002AAA80);
800 checkToRaw(converter, (
unsigned short)0xAAAA, 0x00555500);
812 checkToCookedOverflowNeg<unsigned int>(converter, 0xAAAAAAAA);
817 checkToCookedOverflowNeg<unsigned short>(converter, 0xAAAAAAAA);
836 checkToRaw(converter, (
int)0x55555555, 0x7FFFFFFF);
837 checkToRaw(converter, (
int)0xAAAAAAAA, 0x80000000);
840 checkToRaw(converter, (
unsigned int)0x55555555, 0x7FFFFFFF);
841 checkToRaw(converter, (
short)0x5555, 0x7FFFFFFF);
842 checkToRaw(converter, (
short)0xAAAA, 0x80000000);
844 checkToRaw(converter, (
unsigned short)0x5555, 0x7FFFFFFF);
880 checkToRaw(converter, (
int)0x55555555, 0xFFFFFFFF);
883 checkToRaw(converter, (
unsigned int)0x55555555, 0xFFFFFFFF);
884 checkToRaw(converter, (
unsigned int)1, 0x80000000);
885 checkToRaw(converter, (
short)0x5555, 0xFFFFFFFF);
888 checkToRaw(converter, (
unsigned short)0x5555, 0xFFFFFFFF);
889 checkToRaw(converter, (
unsigned short)1, 0x80000000);
921 checkToRaw(converter, (
int)0x55555555, 0x7FFFFFFF);
922 checkToRaw(converter, (
int)0xAAAAAAAA, 0x80000000);
927 checkToRaw(converter, (
short)0x5555, 0x7FFFFFFF);
928 checkToRaw(converter, (
short)0xAAAA, 0x80000000);
962 checkToRaw(converter, (
int)0x55555555, 0xFFFFFFFF);
966 checkToRaw(converter, (
unsigned int)0x55555555, 0xFFFFFFFF);
967 checkToRaw(converter, (
short)0x5555, 0xFFFFFFFF);
970 checkToRaw(converter, (
unsigned short)0x5555, 0xFFFFFFFF);
1001 checkToRaw(converter, (
int)0x55555555, 0x7FFFFFFF);
1002 checkToRaw(converter, (
int)0xAAAAAAAA, 0x80000000);
1005 checkToRaw(converter, (
unsigned int)0x55555555, 0x7FFFFFFF);
1006 checkToRaw(converter, (
short)0x5555, 0x7FFFFFFF);
1007 checkToRaw(converter, (
short)0xAAAA, 0x80000000);
1008 checkToRaw(converter, (
short)-1, 0x80000000);
1009 checkToRaw(converter, (
unsigned short)0x5555, 0x7FFFFFFF);
1010 checkToRaw(converter, (int64_t)0xFFFFFFFAAAAAAAAA, 0x80000000);
1011 checkToRaw(converter, (uint64_t)0xAAAAAAAAA, 0x7FFFFFFF);
1040 checkToRaw(converter, (
int)0x55555555, 0xFFFFFFFF);
1044 checkToRaw(converter, (
unsigned int)0x55555555, 0xFFFFFFFF);
1045 checkToRaw(converter, (
short)0x5555, 0xFFFFFFFF);
1048 checkToRaw(converter, (
unsigned short)0x5555, 0xFFFFFFFF);
1064 checkToCooked(converter, 0x15555, (
unsigned int)0x15555000);
1076 checkToRaw(converter, (
int)0xEAAAA000, 0x2AAAA);
1077 checkToRaw(converter, (
int)0x15555000, 0x15555);
1078 checkToRaw(converter, (
unsigned int)0x15555000, 0x15555);
1079 checkToRaw(converter, (
short)0xA000, 0x3FFFA);
1080 checkToRaw(converter, (
short)0x5000, 0x00005);
1081 checkToRaw(converter, (
unsigned short)0xA000, 0x0000A);
1098 checkToCooked(converter, 0x2AAAA, (
unsigned int)0x2AAAA000);
1099 checkToCooked(converter, 0x15555, (
unsigned int)0x15555000);
1112 checkToRaw(converter, (
int)0x15555000, 0x15555);
1113 checkToRaw(converter, (
unsigned int)0x15555000, 0x15555);
1115 checkToRaw(converter, (
short)0x5000, 0x00005);
1116 checkToRaw(converter, (
unsigned short)0xA000, 0x0000A);
1134 checkToCooked(converter, 0x2AAAA, (int64_t)0xFFFFFFFFFFFEAAAA);
1148 checkToRaw(converter, (
int)0xFFFEAAAA, 0x2AAAA);
1149 checkToRaw(converter, (
int)0x00015555, 0x15555);
1150 checkToRaw(converter, (
unsigned int)0x00015555, 0x15555);
1151 checkToRaw(converter, (
short)0xA000, 0x3A000);
1152 checkToRaw(converter, (
short)0x5000, 0x05000);
1153 checkToRaw(converter, (
unsigned short)0xA000, 0x0A000);
1155 checkToRaw(converter, (int64_t)0xFFFFFFFFFFFFA000, 0x3A000);
1156 checkToRaw(converter, (int64_t)0xA000, 0xA000);
1157 checkToRaw(converter, (uint64_t)0xA000, 0x0A000);
1187 checkToRaw(converter, (
int)0x00015555, 0x15555);
1188 checkToRaw(converter, (
unsigned int)0x00015555, 0x15555);
1190 checkToRaw(converter, (
short)0x5000, 0x05000);
1191 checkToRaw(converter, (
unsigned short)0xA000, 0x0A000);
1218 checkToRaw(converter, (
int)0xFFFFFD55, 0x2AA80);
1220 checkToRaw(converter, (
unsigned int)0x2AA, 0x15500);
1221 checkToRaw(converter, (
short)0xFFAA, 0x3D500);
1222 checkToRaw(converter, (
short)0x0055, 0x02A80);
1223 checkToRaw(converter, (
unsigned short)0x0055, 0x02A80);
1257 checkToRaw(converter, (
unsigned int)0x02AA, 0x15500);
1259 checkToRaw(converter, (
short)0x0055, 0x02A80);
1260 checkToRaw(converter, (
unsigned short)0x0055, 0x02A80);
1404 BOOST_CHECK(defaultConverter.
getNBits() == 32);
1406 BOOST_CHECK(defaultConverter.
isSigned() ==
true);
1409 BOOST_CHECK(customConverter.
getNBits() == 13);
1411 BOOST_CHECK(customConverter.
isSigned() ==
false);
1446 checkToCookedOverflowNeg<int16_t>(converter, 0xAAAAAAAA);
1447 checkToCookedOverflowPos<int16_t>(converter, 0x55555555);
1456 checkToRaw(converter, (int16_t)0x7FFF, 0x7FFF);
1457 checkToRaw(converter, (int16_t)0x8000, 0xFFFF8000);
1458 checkToRaw(converter, (int16_t)0xFFFF, 0xFFFFFFFF);
1482 checkToRaw(converter, (int32_t)0x1FFFF, 0x1FFFF);
1483 checkToRaw(converter, (int32_t)0x20000, 0x1FFFF);
1485 checkToRaw(converter, (int32_t)-0x20000, 0x20000);
1495 checkToCookedOverflowNeg<uint32_t>(converter, 0xFFFFFFFF);
1496 checkToCookedOverflowNeg<uint16_t>(converter, 0xFFFFFFFA);
1497 checkToCookedOverflowNeg<uint16_t>(converter, 0xAAAAAAAA);
1504 checkToRaw(converter, (uint32_t)0x7FFFFFFF, 0x7FFFFFFF);
1505 checkToRaw(converter, (uint32_t)0x80000000, 0x7FFFFFFF);
1506 checkToRaw(converter, (uint32_t)0xFFFFFFFF, 0x7FFFFFFF);
1514 checkToCookedOverflowNeg<uint16_t>(converter, 0xFFFFFFFF);
1518 checkToCookedOverflowNeg<int16_t>(converter, 0x55555555);
1524 checkToRaw(converter, (uint16_t)0x7FFF, 0x7FFF);
1525 checkToRaw(converter, (uint16_t)0x8000, 0x8000);
1526 checkToRaw(converter, (uint16_t)0xFFFF, 0xFFFF);
1598 checkToCooked(converter, 0xFFFF, 65535. * pow(2., -(1021 - 16)));
1602 BOOST_CHECK(!std::isinf(65535. * pow(2., -(1021 - 16))));
1610 checkToCooked(converter, 0xFFFF, 65535. * pow(2., 1024 - 16));
1614 BOOST_CHECK(pow(2., -(1024 - 16)) > 0.);
1630 BOOST_AUTO_TEST_SUITE_END()