34#define BOOST_TEST_DYN_LINK
35#define BOOST_TEST_MODULE Main
36#include <boost/test/unit_test.hpp>
38#define BOOST_TEST_DYN_LINK
40# define BOOST_TEST_MODULE Main
42#include <boost/test/unit_test.hpp>
73BOOST_AUTO_TEST_CASE(maxExpBiPoly) {
75 for(
int i=2; i<=100; i++)
76 BOOST_TEST_CHECK(mjr::maxExpBiPoly((i+1)*(i+1)) == i);
78 for(
int i=2; i<=100; i++)
79 BOOST_TEST_CHECK(mjr::maxExpBiPoly((i+1)*(i+1)-1) == -3);
81 for(
int i=2; i<100; i++)
82 BOOST_TEST_CHECK(mjr::maxExpBiPoly((i+1)*(i+1)+1) == -3);
84 BOOST_TEST_CHECK(mjr::maxExpBiPoly((100+1)*(100+1)+1) == -1);
85 BOOST_TEST_CHECK(mjr::maxExpBiPoly((101+1)*(101+1)) == -1);
87 BOOST_TEST_CHECK(mjr::maxExpBiPoly(0) == -2);
91BOOST_AUTO_TEST_CASE(evalBiPoly, * boost::unit_test::tolerance(0.00001)) {
93 std::vector<double> BiPoly01 {1, 2, 3, 4, 5, 6, 7, 8, 9};
94 std::vector<double> BiPoly02 {9, 8, 7, 6, 5, 4, 3, 2, 1};
96 std::vector<double> BiPoly03 {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16};
97 std::vector<double> BiPoly04 {16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1};
101 BOOST_TEST_CHECK(mjr::math::bply::eval(BiPoly01, 0, 0) == 9);
102 BOOST_TEST_CHECK(mjr::math::bply::eval(BiPoly01, 0, 1) == 24);
103 BOOST_TEST_CHECK(mjr::math::bply::eval(BiPoly01, 1, 0) == 18);
104 BOOST_TEST_CHECK(mjr::math::bply::eval(BiPoly01, 1, 1) == 45);
105 BOOST_TEST_CHECK(mjr::math::bply::eval(BiPoly01, 2, 3) == 282);
107 BOOST_TEST_CHECK(mjr::math::bply::eval(BiPoly02, 0, 0) == 1);
108 BOOST_TEST_CHECK(mjr::math::bply::eval(BiPoly02, 0, 1) == 6);
109 BOOST_TEST_CHECK(mjr::math::bply::eval(BiPoly02, 1, 0) == 12);
110 BOOST_TEST_CHECK(mjr::math::bply::eval(BiPoly02, 1, 1) == 45);
111 BOOST_TEST_CHECK(mjr::math::bply::eval(BiPoly02, 2, 3) == 628);
113 BOOST_TEST_CHECK(mjr::math::bply::eval(BiPoly03, 0, 0) == 16);
114 BOOST_TEST_CHECK(mjr::math::bply::eval(BiPoly03, 0, 1) == 58);
115 BOOST_TEST_CHECK(mjr::math::bply::eval(BiPoly03, 1, 0) == 40);
116 BOOST_TEST_CHECK(mjr::math::bply::eval(BiPoly03, 1, 1) == 136);
117 BOOST_TEST_CHECK(mjr::math::bply::eval(BiPoly03, 2, 3) == 2630);
119 BOOST_TEST_CHECK(mjr::math::bply::eval(BiPoly04, 0, 0) == 1);
120 BOOST_TEST_CHECK(mjr::math::bply::eval(BiPoly04, 0, 1) == 10);
121 BOOST_TEST_CHECK(mjr::math::bply::eval(BiPoly04, 1, 0) == 28);
122 BOOST_TEST_CHECK(mjr::math::bply::eval(BiPoly04, 1, 1) == 136);
123 BOOST_TEST_CHECK(mjr::math::bply::eval(BiPoly04, 2, 3) == 7570);
127BOOST_AUTO_TEST_CASE(fmtInt) {
130 BOOST_TEST_CHECK(mjr::math::str::fmt_int(10 ) ==
"10");
131 BOOST_TEST_CHECK(mjr::math::str::fmt_int(10, 4 ) ==
" 10");
132 BOOST_TEST_CHECK(mjr::math::str::fmt_int(10, 4,
' ' ) ==
" 10");
133 BOOST_TEST_CHECK(mjr::math::str::fmt_int(10, 4,
' ', 10 ) ==
" 10");
134 BOOST_TEST_CHECK(mjr::math::str::fmt_int(10, 4,
' ', 10,
true) ==
" 10");
137 BOOST_TEST_CHECK(mjr::math::str::fmt_int(10, 0,
' ', 10,
true) ==
"10");
138 BOOST_TEST_CHECK(mjr::math::str::fmt_int(10, 1,
' ', 10,
true) ==
"10");
139 BOOST_TEST_CHECK(mjr::math::str::fmt_int(10, 2,
' ', 10,
true) ==
"10");
140 BOOST_TEST_CHECK(mjr::math::str::fmt_int(10, 3,
' ', 10,
true) ==
" 10");
141 BOOST_TEST_CHECK(mjr::math::str::fmt_int(10, 4,
' ', 10,
true) ==
" 10");
143 BOOST_TEST_CHECK(mjr::math::str::fmt_int(10, 0,
'X', 10,
true) ==
"10");
144 BOOST_TEST_CHECK(mjr::math::str::fmt_int(10, 1,
'X', 10,
true) ==
"10");
145 BOOST_TEST_CHECK(mjr::math::str::fmt_int(10, 2,
'X', 10,
true) ==
"10");
146 BOOST_TEST_CHECK(mjr::math::str::fmt_int(10, 3,
'X', 10,
true) ==
"X10");
147 BOOST_TEST_CHECK(mjr::math::str::fmt_int(10, 4,
'X', 10,
true) ==
"XX10");
149 BOOST_TEST_CHECK(mjr::math::str::fmt_int(10, 0,
' ', 10,
false) ==
"10");
150 BOOST_TEST_CHECK(mjr::math::str::fmt_int(10, 1,
' ', 10,
false) ==
"10");
151 BOOST_TEST_CHECK(mjr::math::str::fmt_int(10, 2,
' ', 10,
false) ==
"10");
152 BOOST_TEST_CHECK(mjr::math::str::fmt_int(10, 3,
' ', 10,
false) ==
"10 ");
153 BOOST_TEST_CHECK(mjr::math::str::fmt_int(10, 4,
' ', 10,
false) ==
"10 ");
155 BOOST_TEST_CHECK(mjr::math::str::fmt_int(10, 0,
'X', 10,
false) ==
"10");
156 BOOST_TEST_CHECK(mjr::math::str::fmt_int(10, 1,
'X', 10,
false) ==
"10");
157 BOOST_TEST_CHECK(mjr::math::str::fmt_int(10, 2,
'X', 10,
false) ==
"10");
158 BOOST_TEST_CHECK(mjr::math::str::fmt_int(10, 3,
'X', 10,
false) ==
"10X");
159 BOOST_TEST_CHECK(mjr::math::str::fmt_int(10, 4,
'X', 10,
false) ==
"10XX");
162 BOOST_TEST_CHECK(mjr::math::str::fmt_int(10, 0,
' ', 16,
true) ==
"a");
163 BOOST_TEST_CHECK(mjr::math::str::fmt_int(10, 1,
' ', 16,
true) ==
"a");
164 BOOST_TEST_CHECK(mjr::math::str::fmt_int(10, 2,
' ', 16,
true) ==
" a");
165 BOOST_TEST_CHECK(mjr::math::str::fmt_int(10, 3,
' ', 16,
true) ==
" a");
166 BOOST_TEST_CHECK(mjr::math::str::fmt_int(10, 4,
' ', 16,
true) ==
" a");
168 BOOST_TEST_CHECK(mjr::math::str::fmt_int(10, 0,
'X', 16,
true) ==
"a");
169 BOOST_TEST_CHECK(mjr::math::str::fmt_int(10, 1,
'X', 16,
true) ==
"a");
170 BOOST_TEST_CHECK(mjr::math::str::fmt_int(10, 2,
'X', 16,
true) ==
"Xa");
171 BOOST_TEST_CHECK(mjr::math::str::fmt_int(10, 3,
'X', 16,
true) ==
"XXa");
172 BOOST_TEST_CHECK(mjr::math::str::fmt_int(10, 4,
'X', 16,
true) ==
"XXXa");
174 BOOST_TEST_CHECK(mjr::math::str::fmt_int(10, 0,
' ', 16,
false) ==
"a");
175 BOOST_TEST_CHECK(mjr::math::str::fmt_int(10, 1,
' ', 16,
false) ==
"a");
176 BOOST_TEST_CHECK(mjr::math::str::fmt_int(10, 2,
' ', 16,
false) ==
"a ");
177 BOOST_TEST_CHECK(mjr::math::str::fmt_int(10, 3,
' ', 16,
false) ==
"a ");
178 BOOST_TEST_CHECK(mjr::math::str::fmt_int(10, 4,
' ', 16,
false) ==
"a ");
180 BOOST_TEST_CHECK(mjr::math::str::fmt_int(10, 0,
'X', 16,
false) ==
"a");
181 BOOST_TEST_CHECK(mjr::math::str::fmt_int(10, 1,
'X', 16,
false) ==
"a");
182 BOOST_TEST_CHECK(mjr::math::str::fmt_int(10, 2,
'X', 16,
false) ==
"aX");
183 BOOST_TEST_CHECK(mjr::math::str::fmt_int(10, 3,
'X', 16,
false) ==
"aXX");
184 BOOST_TEST_CHECK(mjr::math::str::fmt_int(10, 4,
'X', 16,
false) ==
"aXXX");
187 BOOST_TEST_CHECK(mjr::math::str::fmt_int(10, 0,
' ', 8,
true) ==
"12");
188 BOOST_TEST_CHECK(mjr::math::str::fmt_int(10, 1,
' ', 8,
true) ==
"12");
189 BOOST_TEST_CHECK(mjr::math::str::fmt_int(10, 2,
' ', 8,
true) ==
"12");
190 BOOST_TEST_CHECK(mjr::math::str::fmt_int(10, 3,
' ', 8,
true) ==
" 12");
191 BOOST_TEST_CHECK(mjr::math::str::fmt_int(10, 4,
' ', 8,
true) ==
" 12");
193 BOOST_TEST_CHECK(mjr::math::str::fmt_int(10, 0,
'X', 8,
true) ==
"12");
194 BOOST_TEST_CHECK(mjr::math::str::fmt_int(10, 1,
'X', 8,
true) ==
"12");
195 BOOST_TEST_CHECK(mjr::math::str::fmt_int(10, 2,
'X', 8,
true) ==
"12");
196 BOOST_TEST_CHECK(mjr::math::str::fmt_int(10, 3,
'X', 8,
true) ==
"X12");
197 BOOST_TEST_CHECK(mjr::math::str::fmt_int(10, 4,
'X', 8,
true) ==
"XX12");
199 BOOST_TEST_CHECK(mjr::math::str::fmt_int(10, 0,
' ', 8,
false) ==
"12");
200 BOOST_TEST_CHECK(mjr::math::str::fmt_int(10, 1,
' ', 8,
false) ==
"12");
201 BOOST_TEST_CHECK(mjr::math::str::fmt_int(10, 2,
' ', 8,
false) ==
"12");
202 BOOST_TEST_CHECK(mjr::math::str::fmt_int(10, 3,
' ', 8,
false) ==
"12 ");
203 BOOST_TEST_CHECK(mjr::math::str::fmt_int(10, 4,
' ', 8,
false) ==
"12 ");
205 BOOST_TEST_CHECK(mjr::math::str::fmt_int(10, 0,
'X', 8,
false) ==
"12");
206 BOOST_TEST_CHECK(mjr::math::str::fmt_int(10, 1,
'X', 8,
false) ==
"12");
207 BOOST_TEST_CHECK(mjr::math::str::fmt_int(10, 2,
'X', 8,
false) ==
"12");
208 BOOST_TEST_CHECK(mjr::math::str::fmt_int(10, 3,
'X', 8,
false) ==
"12X");
209 BOOST_TEST_CHECK(mjr::math::str::fmt_int(10, 4,
'X', 8,
false) ==
"12XX");