BOOST_CHECK_CLOSE apparent misbehavior
I get the following error Specification_test.cc(22): error in "specsimple": difference between spec(i, j){0.206788} and results[k]{0.206788} exceeds 1e-05% The numbers agree to all printed digits. I get a maximum relative error (assuming the printed values are rounded from extremes)*(see footnote) of .000001/.206787 = 4.8e-6 < 1e-5. Even doubling this is under the tolerance. As I read the documentation, this should pass. 1e-6 tolerance produces a lot more discrepancies; 1e-4 says they are all OK. Have I misunderstood something, or is something funny going on? In particular, the "%" after "1e-5" in the error message suggests the tolerances are supposed to be in percentage terms, i.e, 1e-5 implies a real tolerance of 1e-7. That would explain things, but I see nothing in the documentation to suggest the tolerance value is a percent. (Well, the docs do say the tolerance can be an integer.) The relevant line is BOOST_CHECK_CLOSE(spec(i, j), results[k], tol); All relevant quantities are doubles. It may be relevant that the program under test includes <cmath>. Debian package libboost-dev 1.31.0-7 on an Athlon system. # g++ --version g++.real (GCC) 3.3.4 (Debian 1:3.3.4-6sarge1) Linux kernel 2.4.26 * In fact, the results value is coded as 0.2067880 in the program, so my calculation likely gives double the possible discrepancy.
Have I misunderstood something, or is something funny going on? In particular, the "%" after "1e-5" in the error message suggests the tolerances are supposed to be in percentage terms, i.e, 1e-5 implies a real tolerance of 1e-7. That would explain things, but I see nothing in the documentation to suggest the tolerance value is a percent. (Well, the docs do say the tolerance can be an integer.)
This tool indeed changed recently to use percentage for tolerance definition. From close_at_tolerance doc: "To simplify things in most usage cases latest version of algorithm below opted to use percentage values for tolerance specification (instead of fractions of releated values). In other words now you use it to check that difference between two values does not exceed x percent.". You right BOOST_CHECK_CLOSE page did not gets updated. I will fix. Thank you. Gennadiy.
participants (2)
-
Gennadiy Rozental
-
Ross Boylan