Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r50025 - trunk/libs/units/test
From: steven_at_[hidden]
Date: 2008-11-29 15:45:13


Author: steven_watanabe
Date: 2008-11-29 15:45:12 EST (Sat, 29 Nov 2008)
New Revision: 50025
URL: http://svn.boost.org/trac/boost/changeset/50025

Log:
Switch to BOOST_CHECK_CLOSE_FRACTION
Text files modified:
   trunk/libs/units/test/Jamfile.v2 | 2 +-
   trunk/libs/units/test/test_conversion.cpp | 32 ++++++++++++++++++--------------
   2 files changed, 19 insertions(+), 15 deletions(-)

Modified: trunk/libs/units/test/Jamfile.v2
==============================================================================
--- trunk/libs/units/test/Jamfile.v2 (original)
+++ trunk/libs/units/test/Jamfile.v2 2008-11-29 15:45:12 EST (Sat, 29 Nov 2008)
@@ -27,7 +27,7 @@
 run test_implicit_conversion.cpp ;
 run test_quantity.cpp ;
 run test_unit.cpp ;
-run test_conversion.cpp ;
+run test_conversion.cpp test_framework ;
 run test_base_dimension.cpp ;
 run test_absolute.cpp ;
 run test_default_conversion.cpp ;

Modified: trunk/libs/units/test/test_conversion.cpp
==============================================================================
--- trunk/libs/units/test/test_conversion.cpp (original)
+++ trunk/libs/units/test/test_conversion.cpp 2008-11-29 15:45:12 EST (Sat, 29 Nov 2008)
@@ -27,9 +27,11 @@
 
 #include <iostream>
 
-#include <boost/test/minimal.hpp>
+#define BOOST_TEST_MAIN
 
-#define BOOST_UNITS_CHECK_CLOSE(a, b) (BOOST_CHECK((std::abs((a) - (b)) < .0000001)))
+#include <boost/test/unit_test.hpp>
+
+#define BOOST_UNITS_CHECK_CLOSE(a, b) BOOST_CHECK_CLOSE_FRACTION(a, b, .0000001)
 
 namespace bu = boost::units;
 
@@ -50,35 +52,39 @@
 typedef bu::divide_typeof_helper<bu::multiply_typeof_helper<cgs_mass,mixed_length>::type,
                                  bu::multiply_typeof_helper<cgs_time,cgs_time>::type >::type mixed_energy_2;
 
-int test_main(int,char *[])
-{
+BOOST_AUTO_TEST_CASE(test_conversion) {
+ BOOST_CHECK_EQUAL(1, 1);
     bu::quantity<mixed_length> a1(2.0 * mixed_length());
     bu::quantity<si_area> a2(a1);
 
- BOOST_CHECK((std::abs(a2.value() - .02) < .0001));
+ BOOST_UNITS_CHECK_CLOSE(a2.value(), .02);
 
     bu::quantity<mixed_length> a3(a2);
 
- BOOST_CHECK((std::abs(a3.value() - 2.0) < .0001));
+ BOOST_UNITS_CHECK_CLOSE(a3.value(), 2.0);
 
     bu::quantity<mixed_energy_1> e1(2.0 * mixed_energy_1());
     bu::quantity<mixed_energy_2> e2(e1);
 
- BOOST_CHECK((std::abs(e2.value() - 20.0) < .0001));
+ BOOST_UNITS_CHECK_CLOSE(e2.value(), 20.0);
 
     bu::quantity<bu::si::energy> e3(e1);
- BOOST_CHECK((std::abs(e3.value() - .0002) < .0001));
+ BOOST_UNITS_CHECK_CLOSE(e3.value(), .0002);
     bu::quantity<mixed_energy_2> e4(e3);
- BOOST_CHECK((std::abs(e4.value() - 20.0) < .0001));
+ BOOST_UNITS_CHECK_CLOSE(e4.value(), 20.0);
 
     bu::quantity<bu::cgs::force> F0 = 20 * bu::cgs::dyne;
- BOOST_CHECK((std::abs(F0.value() - 20.0) < .0001));
+ BOOST_UNITS_CHECK_CLOSE(F0.value(), 20.0);
 
     bu::quantity<bu::si::force> F3(F0);
- BOOST_CHECK((std::abs(F3.value() - 2.0e-4) < .000000001));
+ BOOST_UNITS_CHECK_CLOSE(F3.value(), 2.0e-4);
 
     bu::quantity<bu::si::force> F5(20 * bu::cgs::dyne);
- BOOST_CHECK((std::abs(F5.value() - 2.0e-4) < .000000001));
+ BOOST_UNITS_CHECK_CLOSE(F5.value(), 2.0e-4);
+
+}
+
+BOOST_AUTO_TEST_CASE(test_dimensionless_conversions) {
 
     bu::quantity<bu::si::dimensionless> dimensionless_test1(1.0*bu::cgs::dyne/bu::si::newton);
     BOOST_CHECK(dimensionless_test1 == 1e-5);
@@ -94,6 +100,4 @@
     bu::quantity<bu::divide_typeof_helper<bu::si::length, bu::cgs::length>::type> dimensionless_test4(2.0 * bu::si::meters / bu::cgs::centimeters);
     bu::quantity<bu::divide_typeof_helper<bu::cgs::mass, bu::si::mass>::type> dimensionless_test5(dimensionless_test4);
     BOOST_UNITS_CHECK_CLOSE(dimensionless_test5.value(), 2e5);
-
- return(0);
 }


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk