#include <boost/test/auto_unit_test.hpp>
#include "physical/fixedphysical.hpp"
#include "physical/quantity.hpp"
#include <boost/static_assert.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/type_traits/is_convertible.hpp>
#include <iostream>
Include dependency graph for static_conversion_test.cpp:
Go to the source code of this file.
Functions | |
BOOST_AUTO_UNIT_TEST (static_conversion_test) | |
BOOST_AUTO_UNIT_TEST (static_unit_conversion_test) |
BOOST_AUTO_UNIT_TEST | ( | static_unit_conversion_test | ) |
BOOST_AUTO_UNIT_TEST | ( | static_conversion_test | ) |
Definition at line 27 of file static_conversion_test.cpp.
References BOOST_STATIC_ASSERT(), and mcs::units::value().
00027 { 00028 00029 BOOST_STATIC_ASSERT((boost::is_convertible<int, double>::value)); 00030 BOOST_STATIC_ASSERT((!boost::is_convertible<int, double*>::value)); 00031 00032 // some conversions of quantities: 00033 00034 // it should not be possible to convert time into length and the like 00035 BOOST_STATIC_ASSERT((!boost::is_convertible<quantity::time, quantity::length>::value)); 00036 BOOST_STATIC_ASSERT((!boost::is_convertible<quantity::area, quantity::length>::value)); 00037 BOOST_STATIC_ASSERT((!boost::is_convertible<quantity::volume, quantity::length>::value)); 00038 BOOST_STATIC_ASSERT((!boost::is_convertible<quantity::volume, quantity::area>::value)); 00039 00040 00041 // some different formulations of length: 00042 typedef physical::FixedPhysicalRatio<quantity::area, quantity::length>::type length1; 00043 BOOST_STATIC_ASSERT((boost::is_same<quantity::length::exponents, length1::exponents>::value)); 00044 BOOST_STATIC_ASSERT((boost::is_same<length1, quantity::length>::value)); 00045 BOOST_STATIC_ASSERT((boost::is_same<quantity::length, length1>::value)); 00046 00047 typedef physical::FixedPhysicalRatio<quantity::volume, quantity::area>::type length2; 00048 BOOST_STATIC_ASSERT((boost::is_same<quantity::length::exponents, length2::exponents>::value)); 00049 BOOST_STATIC_ASSERT((boost::is_same<length2, quantity::length>::value)); 00050 BOOST_STATIC_ASSERT((boost::is_same<quantity::length, length2>::value)); 00051 00052 typedef physical::FixedPhysicalProduct<quantity::velocity, quantity::time>::type length3; 00053 BOOST_STATIC_ASSERT((boost::is_same<quantity::length::exponents, length3::exponents>::value)); 00054 BOOST_STATIC_ASSERT((boost::is_same<length3, quantity::length>::value)); 00055 BOOST_STATIC_ASSERT((boost::is_same<quantity::length, length3>::value)); 00056 00057 00058 // conversion between float and double: 00059 BOOST_STATIC_ASSERT((boost::is_convertible<physical::quantity_si_float::length, physical::quantity_si_double::length>::value)); 00060 BOOST_STATIC_ASSERT((boost::is_convertible<physical::quantity_si_double::length, physical::quantity_si_float::length>::value)); 00061 00062 };
Generated on Mon Apr 2 22:25:06 2007 for physical_svn by 1.5.1-p1 | hosted on |