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/pow.hpp>
27 
28 namespace bu = boost::units;
29 
test_main(int,char * [])30 int test_main(int,char *[])
31 {
32     const bu::dimensionless D;
33 
34     const bu::length        L;
35     const bu::mass          M;
36     const bu::time          T;
37 
38     BOOST_CHECK(+L == L);
39     BOOST_CHECK(-L == L);
40     BOOST_CHECK(L+L == L);
41     BOOST_CHECK(L-L == L);
42 
43     BOOST_CHECK(+M == M);
44     BOOST_CHECK(-M == M);
45     BOOST_CHECK(M+M == M);
46     BOOST_CHECK(M-M == M);
47 
48     const bu::area          A;
49     const bu::energy        E;
50     const bu::velocity      V;
51 
52     BOOST_CHECK(L*L == A);
53     BOOST_CHECK(A == L*L);
54 
55     BOOST_CHECK(L/L == D);
56     BOOST_CHECK(D == L/L);
57 
58     BOOST_CHECK(L/T == V);
59     BOOST_CHECK(V == L/T);
60 
61     BOOST_CHECK(M*L*L/T/T == E);
62     BOOST_CHECK(M*(L/T)*(L/T) == E);
63     BOOST_CHECK(M*bu::pow<2>(L/T) == E);
64     BOOST_CHECK(bu::root<2>(E/M) == V);
65 
66     return 0;
67 }
68