C:/nobackup/private/physical_svn/trunk/test/conversions/static_conversion_test.cpp

Go to the documentation of this file.
00001 
00002 /*=============================================================================
00003     physical quantities / units / constants
00004     Copyright (c) 2006, 2007 Martin Schulz
00005     http://physical.sourceforge.net
00006   
00007     This is private code by Martin Schulz.
00008   
00009     Use, modification and distribution is subject to the Boost Software
00010     License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
00011     http://www.boost.org/LICENSE_1_0.txt)
00012 =============================================================================*/
00013 
00014 #include <boost/test/auto_unit_test.hpp>
00015 
00016 
00017 #include "physical/fixedphysical.hpp"
00018 #include "physical/quantity.hpp"
00019 
00020 #include <boost/static_assert.hpp>
00021 #include <boost/type_traits/is_same.hpp>
00022 #include <boost/type_traits/is_convertible.hpp>
00023 
00024 namespace quantity=physical::quantity_si_double;
00025 
00026 
00027 BOOST_AUTO_UNIT_TEST( static_conversion_test ) {
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 };
00063 
00064 
00065 
00066 
00067 //#include "physical/unit.hpp"
00068 //namespace unit=physical::unit_double;
00069 #include <iostream>
00070 
00071 BOOST_AUTO_UNIT_TEST( static_unit_conversion_test ) {
00072    std::cout << "static_unit_conversion_test not implemented yet.\n" ;
00073 };

Generated on Mon Apr 2 22:25:06 2007 for physical_svn by  doxygen 1.5.1-p1
hosted on SourceForge.net Logo