1 // Boost.Units - A C++ library for zero-overhead dimensional analysis and 2 // unit/quantity manipulation and conversion 3 // 4 // Copyright (C) 2003-2008 Matthias Christian Schabel 5 // Copyright (C) 2008 Steven Watanabe 6 // 7 // Distributed under the Boost Software License, Version 1.0. (See 8 // accompanying file LICENSE_1_0.txt or copy at 9 // http://www.boost.org/LICENSE_1_0.txt) 10 11 /** 12 \file 13 14 \brief test_header.hpp 15 16 \details 17 Unit system for test purposes. 18 19 Output: 20 @verbatim 21 @endverbatim 22 **/ 23 24 #ifndef BOOST_UNITS_TEST_HEADER_HPP 25 #define BOOST_UNITS_TEST_HEADER_HPP 26 27 #include <boost/test/minimal.hpp> 28 29 #include <boost/units/base_dimension.hpp> 30 #include <boost/units/derived_dimension.hpp> 31 #include <boost/units/static_constant.hpp> 32 #include <boost/units/quantity.hpp> 33 #include <boost/units/io.hpp> 34 #include <boost/units/base_unit.hpp> 35 #include <boost/units/make_system.hpp> 36 37 #include <boost/units/physical_dimensions/length.hpp> 38 #include <boost/units/physical_dimensions/mass.hpp> 39 #include <boost/units/physical_dimensions/time.hpp> 40 41 #define BOOST_UNITS_CHECK_CLOSE(a, b) (BOOST_CHECK((std::abs((a) - (b)) < .0000001))) 42 43 namespace boost { 44 45 namespace units { 46 47 //struct length_base_dimension : boost::units::base_dimension<length_base_dimension,1> { }; ///> base dimension of length 48 //struct mass_base_dimension : boost::units::base_dimension<mass_base_dimension,2> { }; ///> base dimension of mass 49 //struct time_base_dimension : boost::units::base_dimension<time_base_dimension,3> { }; ///> base dimension of time 50 51 typedef length_base_dimension::dimension_type length_dimension; 52 typedef mass_base_dimension::dimension_type mass_dimension; 53 typedef time_base_dimension::dimension_type time_dimension; 54 55 typedef derived_dimension<length_base_dimension,2>::type area_dimension; 56 typedef derived_dimension<mass_base_dimension,1, 57 length_base_dimension,2, 58 time_base_dimension,-2>::type energy_dimension; 59 typedef derived_dimension<mass_base_dimension,-1, 60 length_base_dimension,-2, 61 time_base_dimension,2>::type inverse_energy_dim; 62 typedef derived_dimension<length_base_dimension,1, 63 time_base_dimension,-1>::type velocity_dimension; 64 typedef derived_dimension<length_base_dimension,3>::type volume_dimension; 65 66 /// placeholder class defining test unit system 67 struct length_unit : base_unit<length_unit, length_dimension, 4> {}; 68 struct mass_unit : base_unit<mass_unit, mass_dimension, 5> {}; 69 struct time_unit : base_unit<time_unit, time_dimension, 6> {}; 70 71 typedef make_system<length_unit, mass_unit, time_unit>::type system; 72 73 /// unit typedefs 74 typedef unit<dimensionless_type,system> dimensionless; 75 76 typedef unit<length_dimension,system> length; 77 typedef unit<mass_dimension,system> mass; 78 typedef unit<time_dimension,system> time; 79 80 typedef unit<area_dimension,system> area; 81 typedef unit<energy_dimension,system> energy; 82 typedef unit<inverse_energy_dim,system> inverse_energy; 83 typedef unit<velocity_dimension,system> velocity; 84 typedef unit<volume_dimension,system> volume; 85 86 /// unit constants 87 BOOST_UNITS_STATIC_CONSTANT(meter,length); 88 BOOST_UNITS_STATIC_CONSTANT(meters,length); 89 BOOST_UNITS_STATIC_CONSTANT(kilogram,mass); 90 BOOST_UNITS_STATIC_CONSTANT(kilograms,mass); 91 BOOST_UNITS_STATIC_CONSTANT(second,time); 92 BOOST_UNITS_STATIC_CONSTANT(seconds,time); 93 94 BOOST_UNITS_STATIC_CONSTANT(square_meter,area); 95 BOOST_UNITS_STATIC_CONSTANT(square_meters,area); 96 BOOST_UNITS_STATIC_CONSTANT(joule,energy); 97 BOOST_UNITS_STATIC_CONSTANT(joules,energy); 98 BOOST_UNITS_STATIC_CONSTANT(meter_per_second,velocity); 99 BOOST_UNITS_STATIC_CONSTANT(meters_per_second,velocity); 100 BOOST_UNITS_STATIC_CONSTANT(cubic_meter,volume); 101 BOOST_UNITS_STATIC_CONSTANT(cubic_meters,volume); 102 103 template<> struct base_unit_info<length_unit> 104 { nameboost::units::base_unit_info105 static std::string name() { return "meter"; } symbolboost::units::base_unit_info106 static std::string symbol() { return "m"; } 107 }; 108 //] 109 110 template<> struct base_unit_info<mass_unit> 111 { nameboost::units::base_unit_info112 static std::string name() { return "kilogram"; } symbolboost::units::base_unit_info113 static std::string symbol() { return "kg"; } 114 }; 115 116 template<> struct base_unit_info<time_unit> 117 { nameboost::units::base_unit_info118 static std::string name() { return "second"; } symbolboost::units::base_unit_info119 static std::string symbol() { return "s"; } 120 }; 121 122 } // namespace units 123 124 } // namespace boost 125 126 #endif // BOOST_UNITS_TEST_HEADER_HPP 127