50 const std::vector<TEST_RESCALE_I64_CASE> rescale_i64_cases = {
51 { 10LL, 10LL, 1LL, 100LL },
52 { 10LL, 10LL, -1LL, -100LL },
53 { 10LL, -10LL, 1LL, -100LL },
54 { 10LL, -10LL, -1LL, 100LL },
56 { 1LL, 9LL, 1LL, 9LL },
57 { 1LL, 9LL, -1LL, -9LL },
58 { 1LL, -9LL, 1LL, -9LL },
59 { 1LL, -9LL, -1LL, 9LL },
61 { 10LL, 10LL, 2LL, 50LL },
62 { 10LL, 10LL, -2LL, -50LL },
63 { 10LL, -10LL, 2LL, -50LL },
64 { 10LL, -10LL, -2LL, 50LL },
66 { 1LL, 9LL, 2LL, 5LL },
67 { 1LL, 9LL, -2LL, -5LL },
68 { 1LL, -9LL, 2LL, -5LL },
69 { 1LL, -9LL, -2LL, 5LL },
71 { 1LL, 17LL, 4LL, 4LL },
72 { 1LL, 17LL, -4LL, -4LL },
73 { 1LL, -17LL, 4LL, -4LL },
74 { 1LL, -17LL, -4LL, 4LL },
76 { 1LL, 19LL, 4LL, 5LL },
77 { 1LL, 19LL, -4LL, -5LL },
78 { 1LL, -19LL, 4LL, -5LL },
79 { 1LL, -19LL, -4LL, 5LL },
81 { 1LL, 0LL, 4LL, 0LL },
82 { 1LL, 0LL, -4LL, 0LL },
83 { -1LL, 0LL, 4LL, 0LL },
84 { -1LL, 0LL, -4LL, 0LL },
87 { 3037000499LL, 3037000499LL, 1LL, 9223372030926249001LL },
88 { 3037000499LL, 3037000499LL, -1LL, -9223372030926249001LL },
89 { 3037000499LL, -3037000499LL, 1LL, -9223372030926249001LL },
90 { 3037000499LL, -3037000499LL, -1LL, 9223372030926249001LL },
93 { 9603838834LL, 9603838834LL, 10LL, 9223372034944647956LL },
94 { 9603838834LL, 9603838834LL, -10LL, -9223372034944647956LL },
95 { 9603838834LL, -9603838834LL, 10LL, -9223372034944647956LL },
96 { 9603838834LL, -9603838834LL, -10LL, 9223372034944647956LL },
99 { INT64_MAX, 10LL, 10LL, INT64_MAX },
100 { INT64_MAX, 10LL, -10LL, -INT64_MAX },
101 { INT64_MAX, -10LL, 10LL, -INT64_MAX },
102 { INT64_MAX, -10LL, -10LL, INT64_MAX },
104 { INT64_MAX, 10LL, INT64_MAX, 10LL },
105 { INT64_MAX, 10LL, -INT64_MAX, -10LL },
106 { INT64_MAX, -10LL, INT64_MAX, -10LL },
107 { INT64_MAX, -10LL, -INT64_MAX, 10LL },
109 { INT64_MAX, INT64_MAX, INT64_MAX, INT64_MAX },
110 { INT64_MAX, INT64_MAX, -INT64_MAX, -INT64_MAX },
111 { INT64_MAX, -INT64_MAX, INT64_MAX, -INT64_MAX },
112 { INT64_MAX, -INT64_MAX, -INT64_MAX, INT64_MAX },
117 int64_t calculated =
rescale( entry.m_numerator, entry.m_value, entry.m_denominator );
120 msg <<
"rescale<int64_t>( " << entry.m_numerator <<
", " << entry.m_value <<
", "
121 << entry.m_denominator <<
" ) failed. ";
122 msg <<
"\nExpected: " << entry.m_result;
123 msg <<
"\nGot: " << calculated;
125 BOOST_CHECK_MESSAGE( calculated == entry.m_result, msg );
Test suite for KiCad math code.
BOOST_AUTO_TEST_SUITE(CadstarPartParser)
BOOST_AUTO_TEST_SUITE_END()
BOOST_AUTO_TEST_CASE(test_rescale_int64)
Declare the test suite.
T rescale(T aNumerator, T aValue, T aDenominator)
Scale a number (value) by rational (numerator/denominator).