1 #include "ns3/int64x64.h"
3 #include "ns3/valgrind.h"
41 Printer (
const int64_t high,
const uint64_t low)
52 m_low (value.GetLow ())
68 os << std::fixed << std::setprecision (22)
73 os << std::hex << std::setfill (
'0')
74 <<
" (0x" << std::setw (16) << p.
m_high
75 <<
" 0x" << std::setw (16) << p.
m_low <<
")"
76 << std::dec << std::setfill (
' ');
85 virtual void DoRun (
void);
86 void Check (
const int64_t hi,
const uint64_t lo);
90 :
TestCase (
"Manipulate the high and low part of every number")
97 uint64_t tolerance = 0;
105 uint64_t vLow = value.
GetLow ();
106 bool pass = ( (value.
GetHigh () == hi)
107 && ( (
Max (vLow, lo) -
Min (vLow, lo)) <= tolerance)
111 << (pass ?
"pass " :
"FAIL ")
116 "High part does not match for hi:" << hi
119 "Low part does not match for hi: " << hi
126 std::cout << std::endl;
134 low =
HP_MAX_64 * std::numeric_limits<long double>::epsilon ();
139 Check ( 0, 0xffffffffffffffffULL - low);
143 Check ( 1, 0xffffffffffffffffULL - low);
147 Check (-1, 0xffffffffffffffffULL - low);
155 virtual void DoRun (
void);
156 void Check (
const std::string & str,
157 const int64_t hi,
const uint64_t lo,
158 const int64_t tolerance = 0);
161 :
TestCase (
"Parse int64x64_t numbers as strings")
166 const int64_t hi,
const uint64_t lo,
167 const int64_t tolerance )
170 std::istringstream iss;
175 std::string input =
"\"" + str +
"\"";
176 uint64_t vLow = value.
GetLow ();
177 bool pass = ( (value.GetHigh () == hi) &&
178 (
Max (vLow, lo) -
Min (vLow, lo) <= tolerance)
182 << (pass ?
"pass " :
"FAIL ")
183 << std::left << std::setw (28) << input << std::right
185 <<
" expected: " <<
Printer (hi, lo) <<
" +/- " << tolerance
189 "High parts do not match for input string \""
192 "Low parts do not match for input string \""
198 std::cout << std::endl;
202 int64_t tolerance = 0;
213 Check (
"+1.0", 1, 0);
214 Check (
"001.0", 1, 0);
215 Check (
"+001.0", 1, 0);
216 Check (
"020.0", 20, 0);
217 Check (
"+020.0", 20, 0);
218 Check (
"1.0000000", 1, 0);
219 Check (
"-1.0", -1, 0, tolerance);
220 Check (
"-1.0000", -1, 0, tolerance);
221 Check (
" 1.000000000000000000054", 1, 1, tolerance);
222 Check (
"-1.000000000000000000054", -2, -1, tolerance);
230 virtual void DoRun (
void);
231 void Check (
const std::string & str,
232 const int64_t tolerance = 0);
235 :
TestCase (
"Roundtrip int64x64_t numbers as strings")
240 const int64_t tolerance )
242 std::stringstream iss (str);
246 std::stringstream oss;
247 oss << std::scientific << std::setprecision (21) << expect;
251 bool pass =
Abs (value - expect) <=
int64x64_t (0, tolerance + 1);
253 std::string input =
"\"" + str +
"\"";
254 std::string output =
"\"" + oss.str () +
"\"";
259 << (pass ?
"pass " :
"FAIL ")
260 <<
" in: " << std::left << std::setw (28) << input
261 <<
" out: " << std::left << std::setw (28) << output
268 << (pass ?
"pass " :
"FAIL ")
269 <<
" in: " << std::left << std::setw (28) << input
270 << std::right <<
Printer (expect)
273 << std::setw (19) <<
" "
274 <<
" out: " << std::left << std::setw (28) << output
275 << std::right <<
Printer (value)
280 "Converted string does not match expected string");
286 std::cout << std::endl;
290 int64_t tolerance = 0;
297 Check (
"+1.000000000000000000000");
298 Check (
"+20.000000000000000000000");
299 Check (
"+0.000000000000000000000", tolerance);
300 Check (
"-1.000000000000000000000", tolerance);
301 Check (
"+1.084467440737095516158", tolerance);
302 Check (
"-2.084467440737095516158", tolerance);
303 Check (
"+3.184467440737095516179", tolerance);
304 Check (
"-4.184467440737095516179", tolerance);
312 virtual void DoRun (
void);
315 void Check (
const int test,
321 :
TestCase (
"Basic arithmetic operations")
330 Check (test, value, expect, zero);
338 bool pass =
Abs (value - expect) <= tolerance;
341 << (pass ?
"pass " :
"FAIL ")
342 << test <<
": " << value <<
" == " << expect
343 <<
" (+/- " << tolerance <<
")"
347 "Arithmetic failure in test case " << test);
359 std::cout << std::endl;
363 Check ( 0, zero - zero , zero );
364 Check ( 1, zero - one , -one );
365 Check ( 2, one - one , zero );
366 Check ( 3, one - two , -one );
367 Check ( 4, one - (-one ), two );
368 Check ( 5, (-one ) - (-two ), one );
369 Check ( 6, (-one ) - two , -thre );
371 Check ( 7, zero + zero , zero );
372 Check ( 8, zero + one , one );
373 Check ( 9, one + one , two );
374 Check (10, one + two , thre );
375 Check (11, one + (-one ), zero );
376 Check (12, (-one ) + (-two ), -thre );
377 Check (13, (-one ) + two , one );
379 Check (14, zero * zero , zero );
380 Check (15, zero * one , zero );
381 Check (16, zero * (-one ), zero );
382 Check (17, one * one , one );
383 Check (18, one * (-one ), -one );
384 Check (19, (-one ) * (-one ), one );
386 Check (20, (two * thre ) / thre , two );
391 Check (21, frac, 0.75);
392 Check (22, fplf2, 1.3125);
399 Check (23, zerof, frac);
402 Check (24, zerof - zerof, zero );
403 Check (25, zerof - onef, -one );
404 Check (26, onef - onef, zero );
405 Check (27, onef - twof, -one );
406 Check (28, onef - (-onef), twof + frac );
407 Check (29 , (-onef) - (-twof), one );
408 Check (30 , (-onef) - twof, -thref - frac );
410 Check (31, zerof + zerof, zerof + frac );
411 Check (32, zerof + onef, onef + frac );
412 Check (33, onef + onef, twof + frac );
413 Check (34, onef + twof, thref + frac );
414 Check (35, onef + (-onef), zero );
415 Check (36 , (-onef) + (-twof), -thref - frac );
416 Check (37, (-onef) + twof, one );
418 Check (38, zerof * zerof, frac * frac );
419 Check (39 , zero * onef, zero );
420 Check (40 , zerof * one, frac );
422 Check (41, zerof * onef, fplf2 );
423 Check (42, zerof * (-onef), -fplf2 );
424 Check (43, onef * onef, onef + fplf2 );
425 Check (44, onef * (-onef), -onef - fplf2 );
426 Check (45, (-onef) * (-onef), onef + fplf2 );
430 Check (46, (two * thre ) / thre , two );
431 Check (47, (twof * thref) / thref, twof );
434 Check (48, (two / thre) * thre, two , 2 * tol1 );
435 Check (49, (twof / thref) * thref, twof, 3 * tol1 );
441 int64x64_t (1999999999, 0xfffffffffffffffeULL));
458 virtual void DoRun (
void);
459 void Check (
const double result,
const double expect,
460 const std::string & msg);
464 :
TestCase (
"Test case for bug 455")
469 const std::string & msg)
471 bool pass = result == expect;
474 << (pass ?
"pass " :
"FAIL ")
476 <<
" exp: " << expect
486 std::cout << std::endl;
496 Check (a.GetDouble (), 2.5,
"Simple test for multiplication");
500 Check (a.GetDouble (), -2.5,
"Test sign, first operation negative");
504 Check (a.GetDouble (), 2.5,
"both operands negative");
508 Check (a.GetDouble (), -2.5,
"only second operand negative");
520 virtual void DoRun (
void);
521 void Check (
const double result,
const double expect,
522 const std::string & msg);
526 :
TestCase (
"Test case for bug 863")
531 const std::string & msg)
533 bool pass = result == expect;
536 << (pass ?
"pass " :
"FAIL ")
538 <<
" exp: " << expect
548 std::cout << std::endl;
558 Check (a.GetDouble (), 1.0,
"Simple test for division");
561 Check (a.GetDouble (), -0.5,
"Check that we actually convert doubles correctly");
564 Check (a.GetDouble (), -1.0,
"first argument negative");
568 Check (a.GetDouble (), -1.0,
"second argument negative");
572 Check (a.GetDouble (), 1.0,
"both arguments negative");
583 virtual void DoRun (
void);
584 void Check (
const uint64_t low,
const std::string & value,
585 const int64_t tolerance = 0);
589 :
TestCase (
"Test case for bug 1786")
594 const std::string & str,
595 const int64_t tolerance )
598 std::ostringstream oss;
599 oss << std::scientific << std::setprecision (22) << value;
603 bool pass = oss.str () == str;
606 << (pass ?
"pass " :
"FAIL ")
607 <<
" 0x" << std::hex << std::setw (16) << low << std::dec
608 <<
" = " << oss.str ();
611 std::cout <<
", expected " << str;
613 std::cout << std::endl;
616 "Fraction string not correct");
624 <<
" 0x" << std::hex << std::setw (16) << low << std::dec
625 <<
" = " << oss.str ()
626 <<
", expected " << str
634 std::cout << std::endl;
638 int64_t tolerance = 0;
649 Check ( 1ULL,
"+0.0000000000000000000542");
650 Check ( 2ULL,
"+0.0000000000000000001084");
651 Check ( 3ULL,
"+0.0000000000000000001626");
652 Check ( 4ULL,
"+0.0000000000000000002168");
653 Check ( 5ULL,
"+0.0000000000000000002710");
654 Check ( 6ULL,
"+0.0000000000000000003253");
655 Check ( 7ULL,
"+0.0000000000000000003795");
656 Check ( 8ULL,
"+0.0000000000000000004337");
657 Check ( 9ULL,
"+0.0000000000000000004879");
658 Check ( 0xAULL,
"+0.0000000000000000005421");
659 Check ( 0xFULL,
"+0.0000000000000000008132");
660 Check ( 0xF0ULL,
"+0.0000000000000000130104");
661 Check ( 0xF00ULL,
"+0.0000000000000002081668");
662 Check ( 0xF000ULL,
"+0.0000000000000033306691");
663 Check ( 0xF0000ULL,
"+0.0000000000000532907052");
664 Check ( 0xF00000ULL,
"+0.0000000000008526512829");
665 Check ( 0xF000000ULL,
"+0.0000000000136424205266");
666 Check ( 0xF0000000ULL,
"+0.0000000002182787284255");
667 Check ( 0xF00000000ULL,
"+0.0000000034924596548080");
668 Check ( 0xF000000000ULL,
"+0.0000000558793544769287");
669 Check ( 0xF0000000000ULL,
"+0.0000008940696716308594");
670 Check ( 0xF00000000000ULL,
"+0.0000143051147460937500");
671 Check ( 0xF000000000000ULL,
"+0.0002288818359375000000");
672 Check ( 0xF0000000000000ULL,
"+0.0036621093750000000000");
673 Check ( 0xF00000000000000ULL,
"+0.0585937500000000000000");
674 std::cout << std::endl;
675 Check (0x7FFFFFFFFFFFFFFDULL,
"+0.4999999999999999998374", tolerance);
676 Check (0x7FFFFFFFFFFFFFFEULL,
"+0.4999999999999999998916", tolerance);
677 Check (0x7FFFFFFFFFFFFFFFULL,
"+0.4999999999999999999458", tolerance);
678 Check (0x8000000000000000ULL,
"+0.5000000000000000000000");
679 Check (0x8000000000000001ULL,
"+0.5000000000000000000542", tolerance);
680 Check (0x8000000000000002ULL,
"+0.5000000000000000001084", tolerance);
681 Check (0x8000000000000003ULL,
"+0.5000000000000000001626", tolerance);
682 std::cout << std::endl;
683 Check (0xF000000000000000ULL,
"+0.9375000000000000000000");
684 Check (0xFF00000000000000ULL,
"+0.9960937500000000000000");
685 Check (0xFFF0000000000000ULL,
"+0.9997558593750000000000");
686 Check (0xFFFF000000000000ULL,
"+0.9999847412109375000000");
687 Check (0xFFFFF00000000000ULL,
"+0.9999990463256835937500");
688 Check (0xFFFFFF0000000000ULL,
"+0.9999999403953552246094");
689 Check (0xFFFFFFF000000000ULL,
"+0.9999999962747097015381");
690 Check (0xFFFFFFFF00000000ULL,
"+0.9999999997671693563461");
691 Check (0xFFFFFFFFF0000000ULL,
"+0.9999999999854480847716");
692 Check (0xFFFFFFFFFF000000ULL,
"+0.9999999999990905052982");
693 Check (0xFFFFFFFFFFF00000ULL,
"+0.9999999999999431565811");
694 Check (0xFFFFFFFFFFFF0000ULL,
"+0.9999999999999964472863");
695 Check (0xFFFFFFFFFFFFF000ULL,
"+0.9999999999999997779554");
696 Check (0xFFFFFFFFFFFFFF00ULL,
"+0.9999999999999999861222");
697 Check (0xFFFFFFFFFFFFFFF0ULL,
"+0.9999999999999999991326");
698 Check (0xFFFFFFFFFFFFFFF5ULL,
"+0.9999999999999999994037", tolerance);
699 Check (0xFFFFFFFFFFFFFFF6ULL,
"+0.9999999999999999994579", tolerance);
700 Check (0xFFFFFFFFFFFFFFF7ULL,
"+0.9999999999999999995121", tolerance);
701 Check (0xFFFFFFFFFFFFFFF8ULL,
"+0.9999999999999999995663", tolerance);
702 Check (0xFFFFFFFFFFFFFFF9ULL,
"+0.9999999999999999996205", tolerance);
703 Check (0xFFFFFFFFFFFFFFFAULL,
"+0.9999999999999999996747", tolerance);
704 Check (0xFFFFFFFFFFFFFFFBULL,
"+0.9999999999999999997289", tolerance);
705 Check (0xFFFFFFFFFFFFFFFCULL,
"+0.9999999999999999997832", tolerance);
706 Check (0xFFFFFFFFFFFFFFFDULL,
"+0.9999999999999999998374", tolerance);
707 Check (0xFFFFFFFFFFFFFFFEULL,
"+0.9999999999999999998916", tolerance);
708 Check (0xFFFFFFFFFFFFFFFFULL,
"+0.9999999999999999999458", tolerance);
716 virtual void DoRun (
void);
718 void Check (
const bool result,
const bool expect,
719 const std::string & msg);
722 :
TestCase (
"Basic compare operations")
727 const std::string & msg)
729 bool pass = result == expect;
732 << (pass ?
"pass " :
"FAIL ")
742 std::cout << std::endl;
757 Check ( zerof == zerof,
true,
"equality, zero");
758 Check ( onef == onef,
true,
"equality, positive");
759 Check ( mtwof == mtwof,
true,
"equality, negative");
760 Check ( zero == one,
false,
"equality false, zero");
761 Check ( one == two,
false,
"equality false, unsigned");
762 Check ( one == mone,
false,
"equality false, signed");
763 Check ( onef == one,
false,
"equality false, fraction");
764 std::cout << std::endl;
766 Check ( zerof != zerof,
false,
"inequality, zero");
767 Check ( onef != onef,
false,
"inequality, positive");
768 Check ( mtwof != mtwof,
false,
"inequality, negative");
769 Check ( zero != one,
true,
"inequality true, zero");
770 Check ( one != two,
true,
"inequality true, unsigned");
771 Check ( one != mone,
true,
"inequality true, signed");
772 Check ( onef != one,
true,
"inequality true, fraction");
773 std::cout << std::endl;
775 Check ( zerof < onef,
true,
"less, zerof");
776 Check ( zero < zerof,
true,
"less, zero");
777 Check ( one < onef,
true,
"less, positive");
778 Check ( monef < mone,
true,
"less, negative");
779 Check ( onef < one,
false,
"less, false, positive");
780 Check ( mtwo < mtwof,
false,
"less, false, negative");
781 std::cout << std::endl;
783 Check ( zerof <= zerof,
true,
"less equal, equal, zerof");
784 Check ( zero <= zerof,
true,
"less equal, less, zero");
785 Check ( onef <= onef,
true,
"less equal, equal, positive");
786 Check ( monef <= mone,
true,
"less equal, less, negative");
787 Check ( onef <= one,
false,
"less equal, false, positive");
788 Check ( mtwo <= mtwof,
false,
"less equal, false, negative");
789 std::cout << std::endl;
791 Check ( onef > zerof,
true,
"greater, zerof");
792 Check ( zerof > zero,
true,
"greater, zero");
793 Check ( onef > one,
true,
"greater, positive");
794 Check ( mone > monef,
true,
"greater, negative");
795 Check ( one > onef,
false,
"greater, false, positive");
796 Check ( mtwof > mtwo,
false,
"greater, false, negative");
797 std::cout << std::endl;
799 Check ( zerof >= zerof,
true,
"greater equal, equal, zerof");
800 Check ( zerof >= zero,
true,
"greater equal, greater, zero");
801 Check ( onef >= onef,
true,
"greater equal, equal, positive");
802 Check ( mone >= monef,
true,
"greater equal, greater, negative");
803 Check ( one >= onef,
false,
"greater equal, false, positive");
804 Check ( mtwof >= mtwo,
false,
"greater equal, false, negative");
805 std::cout << std::endl;
807 Check ( zero ==
false,
true,
"zero == false");
808 Check ( one ==
true,
true,
"one == true");
809 Check ( zerof !=
false,
true,
"zerof != false");
810 Check ( (!zero) ==
true,
true,
"!zero == true");
811 Check ( (!zerof) ==
false,
true,
"!zerof == false");
812 Check ( (!one) ==
false,
true,
"!one == false");
813 Check ( (+onef) == onef,
true,
"unary positive");
814 Check ( (-onef) == monef,
true,
"unary negative");
822 virtual void DoRun (
void);
823 void Check (
const int64_t factor);
826 const std::string & msg,
827 const double tolerance = 0);
831 :
TestCase (
"Invert and MulByInvert")
838 const std::string & msg,
839 const double tolerance )
841 bool pass =
Abs (result - expect) <= tolerance;
847 std::cout <<
"pass: " << factor <<
": ";
852 std::cout <<
"FAIL: " << factor <<
": "
853 <<
"(res: " << result
854 <<
" exp: " << expect
855 <<
" tol: " << tolerance <<
") ";
872 double tolerance = 0;
876 tolerance = 0.000000000000000001L;
880 CheckCase (factor, b, one,
"x * x^-1 == 1", tolerance);
884 CheckCase (factor, c, factorI,
"1 * x^-1 == 1 / x");
892 CheckCase (factor, e, -one,
"-x * x^-1 == -1", tolerance);
898 std::cout << std::endl;
918 Check (10000000000LL);
919 Check (100000000000LL);
920 Check (1000000000000LL);
921 Check (10000000000000LL);
922 Check (100000000000000LL);
923 Check (1000000000000000LL);
931 virtual void DoRun (
void);
932 void Check (
const int64_t intPart);
933 void Check (
const long double value,
934 const int64_t intPart,
943 :
TestCase (
"Construct from floating point.")
949 const int64_t intPart,
960 long double epsilon = std::numeric_limits<long double>::epsilon ();
961 long double margin = 0;
973 epsilon = std::numeric_limits<double>::epsilon ();
976 const int64x64_t tolerance = (margin + std::fabs (value)) * epsilon;
979 const bool skip = value ==
m_last;
980 const bool pass = delta <= tolerance;
983 std::ios_base::fmtflags ff = std::cout.flags ();
984 std::cout << std::fixed << std::setprecision (22);
987 << (skip ?
"skip " : (pass ?
"pass " :
"FAIL "))
988 << std::showpos << value <<
" == "
996 << std::left << std::setw (43) <<
" expected"
997 << std::right <<
Printer (expect)
1000 if (delta == tolerance)
1003 << std::left << std::setw (43) <<
" delta = tolerance"
1004 << std::right <<
Printer (delta)
1010 << std::left << std::setw (43) <<
" delta"
1011 << std::right <<
Printer (delta)
1014 << std::left << std::setw (43) <<
" +/-"
1015 << std::right <<
Printer (tolerance)
1028 "int64x64_t (long double) failed");
1030 std::cout.flags (ff);
1037 std::cout << std::endl;
1039 <<
"integer: " << intPart
1045 long double v = intPart;
1047 Check (v +0.0000000000000000000542L, intPart, 0x1ULL);
1048 Check (v +0.0000000000000000001084L, intPart, 0x2ULL);
1049 Check (v +0.0000000000000000001626L, intPart, 0x3ULL);
1050 Check (v +0.0000000000000000002168L, intPart, 0x4ULL);
1051 Check (v +0.0000000000000000002710L, intPart, 0x5ULL);
1052 Check (v +0.0000000000000000003253L, intPart, 0x6ULL);
1053 Check (v +0.0000000000000000003795L, intPart, 0x7ULL);
1054 Check (v +0.0000000000000000004337L, intPart, 0x8ULL);
1055 Check (v +0.0000000000000000004879L, intPart, 0x9ULL);
1056 Check (v +0.0000000000000000005421L, intPart, 0xAULL);
1057 Check (v +0.0000000000000000008132L, intPart, 0xFULL);
1058 Check (v +0.0000000000000000130104L, intPart, 0xF0ULL);
1059 Check (v +0.0000000000000002081668L, intPart, 0xF00ULL);
1060 Check (v +0.0000000000000033306691L, intPart, 0xF000ULL);
1061 Check (v +0.0000000000000532907052L, intPart, 0xF0000ULL);
1062 Check (v +0.0000000000008526512829L, intPart, 0xF00000ULL);
1063 Check (v +0.0000000000136424205266L, intPart, 0xF000000ULL);
1064 Check (v +0.0000000002182787284255L, intPart, 0xF0000000ULL);
1065 Check (v +0.0000000034924596548080L, intPart, 0xF00000000ULL);
1066 Check (v +0.0000000558793544769287L, intPart, 0xF000000000ULL);
1067 Check (v +0.0000008940696716308594L, intPart, 0xF0000000000ULL);
1068 Check (v +0.0000143051147460937500L, intPart, 0xF00000000000ULL);
1069 Check (v +0.0002288818359375000000L, intPart, 0xF000000000000ULL);
1070 Check (v +0.0036621093750000000000L, intPart, 0xF0000000000000ULL);
1071 Check (v +0.0585937500000000000000L, intPart, 0xF00000000000000ULL);
1072 std::cout << std::endl;
1073 Check (v +0.4999999999999999998374L, intPart, 0x7FFFFFFFFFFFFFFDULL);
1074 Check (v +0.4999999999999999998916L, intPart, 0x7FFFFFFFFFFFFFFEULL);
1075 Check (v +0.4999999999999999999458L, intPart, 0x7FFFFFFFFFFFFFFFULL);
1076 Check (v +0.5000000000000000000000L, intPart, 0x8000000000000000ULL);
1077 Check (v +0.5000000000000000000542L, intPart, 0x8000000000000001ULL);
1078 Check (v +0.5000000000000000001084L, intPart, 0x8000000000000002ULL);
1079 Check (v +0.5000000000000000001626L, intPart, 0x8000000000000003ULL);
1080 std::cout << std::endl;
1081 Check (v +0.9375000000000000000000L, intPart, 0xF000000000000000ULL);
1082 Check (v +0.9960937500000000000000L, intPart, 0xFF00000000000000ULL);
1083 Check (v +0.9997558593750000000000L, intPart, 0xFFF0000000000000ULL);
1084 Check (v +0.9999847412109375000000L, intPart, 0xFFFF000000000000ULL);
1085 Check (v +0.9999990463256835937500L, intPart, 0xFFFFF00000000000ULL);
1086 Check (v +0.9999999403953552246094L, intPart, 0xFFFFFF0000000000ULL);
1087 Check (v +0.9999999962747097015381L, intPart, 0xFFFFFFF000000000ULL);
1088 Check (v +0.9999999997671693563461L, intPart, 0xFFFFFFFF00000000ULL);
1089 Check (v +0.9999999999854480847716L, intPart, 0xFFFFFFFFF0000000ULL);
1090 Check (v +0.9999999999990905052982L, intPart, 0xFFFFFFFFFF000000ULL);
1091 Check (v +0.9999999999999431565811L, intPart, 0xFFFFFFFFFFF00000ULL);
1092 Check (v +0.9999999999999964472863L, intPart, 0xFFFFFFFFFFFF0000ULL);
1093 Check (v +0.9999999999999997779554L, intPart, 0xFFFFFFFFFFFFF000ULL);
1094 Check (v +0.9999999999999999861222L, intPart, 0xFFFFFFFFFFFFFF00ULL);
1095 Check (v +0.9999999999999999991326L, intPart, 0xFFFFFFFFFFFFFFF0ULL);
1096 Check (v +0.9999999999999999994037L, intPart, 0xFFFFFFFFFFFFFFF5ULL);
1097 Check (v +0.9999999999999999994579L, intPart, 0xFFFFFFFFFFFFFFF6ULL);
1098 Check (v +0.9999999999999999995121L, intPart, 0xFFFFFFFFFFFFFFF7ULL);
1099 Check (v +0.9999999999999999995663L, intPart, 0xFFFFFFFFFFFFFFF8ULL);
1100 Check (v +0.9999999999999999996205L, intPart, 0xFFFFFFFFFFFFFFF9ULL);
1101 Check (v +0.9999999999999999996747L, intPart, 0xFFFFFFFFFFFFFFFAULL);
1102 Check (v +0.9999999999999999997289L, intPart, 0xFFFFFFFFFFFFFFFBULL);
1103 Check (v +0.9999999999999999997832L, intPart, 0xFFFFFFFFFFFFFFFCULL);
1104 Check (v +0.9999999999999999998374L, intPart, 0xFFFFFFFFFFFFFFFDULL);
1105 Check (v +0.9999999999999999998916L, intPart, 0xFFFFFFFFFFFFFFFEULL);
1106 Check (v +0.9999999999999999999458L, intPart, 0xFFFFFFFFFFFFFFFFULL);
1109 <<
"integer: " << intPart
1118 std::cout << std::endl;
1123 std::ios_base::fmtflags ff = std::cout.flags ();
1124 std::cout << std::scientific << std::setprecision (21);
1141 std::cout.flags (ff);
1149 virtual void DoRun (
void);
1153 :
TestCase (
"Print the implementation")
1160 std::cout << std::endl;
1165 std::cout <<
"int64x64_t::implementation: ";
1171 default : std::cout <<
"unknown!";
1173 std::cout << std::endl;
1175 #if defined (INT64X64_USE_CAIRO) && !defined (PYTHON_SCAN)
1176 std::cout <<
"cairo_impl64: " <<
cairo_impl64 << std::endl;
1177 std::cout <<
"cairo_impl128: " <<
cairo_impl128 << std::endl;
1182 std::cout <<
"Running with valgrind" << std::endl;
long double implementation
virtual void DoRun(void)
Implementation to actually run this TestCase.
ns3::int64x64::test::Int64x64TestSuite g_int64x64TestSuite
uint64_t GetLow(void) const
Get the fractional portion of this value, unscaled.
std::ostream & operator<<(std::ostream &os, const Printer &p)
Int64x64Bug1786TestCase()
High precision numerical type, implementing Q64.64 fixed precision.
void CheckCase(const uint64_t factor, const int64x64_t result, const int64x64_t expect, const std::string &msg, const double tolerance=0)
void Check(const double result, const double expect, const std::string &msg)
virtual void DoRun(void)
Implementation to actually run this TestCase.
void Check(const int64_t factor)
void Check(const bool result, const bool expect, const std::string &msg)
const char * cairo_impl128
static int64x64_t Invert(const uint64_t v)
Compute the inverse of an integer value.
void Check(const int64_t intPart)
#define NS_TEST_EXPECT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report if not.
static enum impl_type implementation
Type tag for this implementation.
#define RUNNING_ON_VALGRIND
void MulByInvert(const int64x64_t &o)
Multiply this value by a Q0.128 value, presumably representing an inverse, completing a division oper...
Printer(const int64x64_t value)
double GetDouble(void) const
Get this value as a double.
int64x64_t Min(const int64x64_t &a, const int64x64_t &b)
Minimum.
void Check(const int test, const int64x64_t value, const int64x64_t expect)
virtual void DoRun(void)
Implementation to actually run this TestCase.
friend std::ostream & operator<<(std::ostream &os, const Printer &p)
virtual void DoRun(void)
Implementation to actually run this TestCase.
#define NS_TEST_ASSERT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report and abort if not.
void Check(const int64_t hi, const uint64_t lo)
int64x64_t Max(const int64x64_t &a, const int64x64_t &b)
Maximum.
virtual void DoRun(void)
Implementation to actually run this TestCase.
virtual void DoRun(void)
Implementation to actually run this TestCase.
#define NS_TEST_ASSERT_MSG_EQ_TOL(actual, limit, tol, msg)
Test that actual and expected (limit) values are equal to plus or minus some tolerance and report and...
#define NS_TEST_EXPECT_MSG_EQ_TOL(actual, limit, tol, msg)
Test that actual and expected (limit) values are equal to plus or minus some tolerance and report if ...
int64x64_t Abs(const int64x64_t &value)
Absolute value.
virtual void DoRun(void)
Implementation to actually run this TestCase.
virtual void DoRun(void)
Implementation to actually run this TestCase.
TestCase * GetParent() const
void AddTestCase(TestCase *testCase) NS_DEPRECATED
Add an individual child TestCase case to this TestCase.
Native int128_t implementation.
const char * cairo_impl64
#define HP_MAX_64
Floating point value of HP_MASK_LO + 1 We really want:
Printer(const int64_t high, const uint64_t low)
virtual void DoRun(void)
Implementation to actually run this TestCase.
int64_t GetHigh(void) const
Get the integer portion.
void Check(const double result, const double expect, const std::string &msg)
std::string GetName(void) const
cairo wideint implementation
Int64x64ArithmeticTestCase()
This test suite implements a Unit Test.
void Check(const uint64_t low, const std::string &value, const int64_t tolerance=0)
Int64x64CompareTestCase()