|
Boost-Commit : |
From: steven_at_[hidden]
Date: 2008-05-27 23:40:01
Author: steven_watanabe
Date: 2008-05-27 23:40:00 EDT (Tue, 27 May 2008)
New Revision: 45853
URL: http://svn.boost.org/trac/boost/changeset/45853
Log:
Added failing test for a system with base units whose dimensions are more complex. MUST FIX
Added:
sandbox/units/libs/units/test/test_complicated_system.cpp (contents, props changed)
Text files modified:
sandbox/units/libs/units/test/Jamfile.v2 | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
Modified: sandbox/units/libs/units/test/Jamfile.v2
==============================================================================
--- sandbox/units/libs/units/test/Jamfile.v2 (original)
+++ sandbox/units/libs/units/test/Jamfile.v2 2008-05-27 23:40:00 EDT (Tue, 27 May 2008)
@@ -30,6 +30,7 @@
[ compile test_dimensionless_ice1.cpp : : ]
[ compile test_dimensionless_ice2.cpp : : ]
[ compile test_mixed_value_types.cpp : : ]
+ [ compile test_complicated_system.cpp : : ]
[ run test_dimensionless_quantity.cpp : : : : ]
[ run test_implicit_conversion.cpp : : : : ]
[ run test_quantity.cpp : : : : ]
Added: sandbox/units/libs/units/test/test_complicated_system.cpp
==============================================================================
--- (empty file)
+++ sandbox/units/libs/units/test/test_complicated_system.cpp 2008-05-27 23:40:00 EDT (Tue, 27 May 2008)
@@ -0,0 +1,57 @@
+// Boost.Units - A C++ library for zero-overhead dimensional analysis and
+// unit/quantity manipulation and conversion
+//
+// Copyright (C) 2003-2008 Matthias Christian Schabel
+// Copyright (C) 2007-2008 Steven Watanabe
+//
+// Distributed under the Boost Software License, Version 1.0. (See
+// accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#include <boost/type_traits/is_same.hpp>
+#include <boost/mpl/assert.hpp>
+
+#include <boost/units/base_unit.hpp>
+#include <boost/units/derived_dimension.hpp>
+#include <boost/units/make_system.hpp>
+#include <boost/units/operators.hpp>
+#include <boost/units/reduce_unit.hpp>
+#include <boost/units/unit.hpp>
+
+#include <boost/units/physical_dimensions/current.hpp>
+#include <boost/units/physical_dimensions/electric_potential.hpp>
+#include <boost/units/physical_dimensions/energy.hpp>
+#include <boost/units/physical_dimensions/force.hpp>
+#include <boost/units/physical_dimensions/length.hpp>
+#include <boost/units/physical_dimensions/time.hpp>
+
+// the base units in the system will be:
+//
+// volts = kg m^2 s^-2 C^-1
+// newtons = kg m s^-2
+// joules = kg m^2 s^-2
+
+// we will find the representation of m^-1 C^-1 = V N J^-2 = m^-1 C^-1
+
+struct volt : boost::units::base_unit<volt, boost::units::electric_potential_dimension, 1> {};
+struct newton : boost::units::base_unit<newton, boost::units::force_dimension, 2> {};
+struct joule : boost::units::base_unit<joule, boost::units::electric_potential_dimension, 3> {};
+
+typedef boost::units::make_system<volt, newton, joule>::type complicated_system;
+
+typedef boost::units::derived_dimension<
+ boost::units::length_base_dimension, -1,
+ boost::units::time_base_dimension, -1,
+ boost::units::current_base_dimension, 1
+>::type dimension;
+
+typedef boost::units::reduce_unit<boost::units::unit<dimension, complicated_system> >::type reduced;
+
+typedef boost::units::divide_typeof_helper<
+ boost::units::multiply_typeof_helper<volt::unit_type, newton::unit_type>::type,
+ boost::units::power_typeof_helper<joule::unit_type, boost::units::static_rational<2> >::type
+>::type expected;
+
+int main() {
+ BOOST_MPL_ASSERT((boost::is_same<reduced, expected>));
+}
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