• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_units_1.cpp
15 
16 \details
17 Test unit class.
18 
19 Output:
20 @verbatim
21 @endverbatim
22 **/
23 
24 #include "test_header.hpp"
25 
26 #include <boost/units/cmath.hpp>
27 #include <boost/units/scale.hpp>
28 #include <boost/units/make_scaled_unit.hpp>
29 
30 namespace bu = boost::units;
31 
32 static const double E_ = 2.718281828459045235360287471352662497757;
33 
34 typedef bu::make_scaled_unit<bu::length,
35                              bu::scale<10, bu::static_rational<-3> > >::type milli_meter_unit;
36 
37 typedef bu::make_scaled_unit<bu::area,
38                              bu::scale<10, bu::static_rational<-6> > >::type micro_meter2_unit;
39 
test_main(int,char * [])40 int test_main(int,char *[])
41 {
42     const bu::quantity<micro_meter2_unit> E1 = E_*micro_meter2_unit();
43     const bu::quantity<milli_meter_unit>  E2 = sqrt(E1);
44 
45     BOOST_CHECK(E1.value() == E_);
46     BOOST_CHECK(E2.value() == sqrt(E_));
47     return 0;
48 }
49