30 using namespace pwiz::util;
32 using namespace pwiz::data;
33 using namespace pwiz::data::diff_impl;
39 if (
os_) *
os_ <<
"diff_string(\"" << a <<
"\", \"" << b <<
"\")" << endl;
43 if (
os_) *
os_ <<
"a-b: " << a_b <<
"\nb-a: " << b_a << endl;
51 template <
typename integral_type>
54 if (
os_) *
os_ <<
"diff_integral(\"" << a <<
"\", \"" << b <<
"\")" << endl;
56 integral_type a_b, b_a;
59 unit_assert(a_b == integral_type() && b_a == integral_type());
61 unit_assert(a_b != integral_type() || b_a != integral_type());
64 template <
typename integral_type>
67 testIntegralReally<int>(1, 1);
68 testIntegralReally<int>(-1, 1);
69 testIntegralReally<int>(-1, -1);
70 testIntegralReally<int>(1, 0);
71 testIntegralReally<int>(-1, 0);
74 template <
typename floating_type>
75 void testFloating(floating_type a, floating_type b, floating_type precision)
77 floating_type a_b, b_a;
82 unit_assert(a_b == floating_type() && b_a == floating_type());
84 unit_assert(a_b == fabs(a - b) && b_a == fabs(a - b));
90 if (
os_) *
os_ <<
"testCV()\n";
109 if (
os_) *
os_ << diff << endl;
121 if (
os_) *
os_ <<
"testUserParam()\n";
135 b.
value =
"value_changed";
138 if (
os_) *
os_ << diff << endl;
151 if (
os_) *
os_ <<
"testCVParam()\n";
163 b.
value =
"value_changed";
166 if (
os_) *
os_ << diff << endl;
175 if (
os_) *
os_ << diff << endl;
185 if (
os_) *
os_ << diff << endl;
188 c.
value =
"410000.0";
191 if (
os_) *
os_ << diff << endl;
197 if (
os_) *
os_ << diff << endl;
205 if (
os_) *
os_ <<
"testParamContainer()\n";
230 if (
os_) *
os_ << diff << endl;
252 if (
os_) *
os_ <<
"testParamGroup()\n";
255 a.userParams.push_back(
UserParam(
"common"));
261 a.userParams.push_back(
UserParam(
"different",
"1"));
265 if (
os_) *
os_ << diff << endl;
281 testIntegral<short>();
282 testIntegral<long>();
283 testIntegral<unsigned int>();
284 testIntegral<unsigned short>();
285 testIntegral<unsigned long>();
287 testFloating<float>(1.f, 1.f, 1.e-6f);
288 testFloating<float>(1.f, 1.0000000001f, 1.e-6f);
289 testFloating<float>(1.f, 1.00001f, 1.e-6f);
290 testFloating<float>(4.f, 4.2f, 1.f);
292 testFloating<double>(1, 1, 1
e-6);
293 testFloating<double>(1, 1.0000000001, 1
e-6);
294 testFloating<double>(1, 1.00001, 1
e-6);
295 testFloating<double>(4, 4.2, 1);
304 int main(
int argc,
char* argv[])
310 if (argc>1 && !strcmp(argv[1],
"-v"))
os_ = &cout;