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
17Test unit class.
18
19Output:
20@verbatim
21@endverbatim
22**/
23
24#include "test_header.hpp"
25
26#include <boost/units/pow.hpp>
27
28namespace bu = boost::units;
29
30int main()
31{
32 BOOST_CONSTEXPR_OR_CONST bu::dimensionless D;
33
34 BOOST_CONSTEXPR_OR_CONST bu::length L;
35 BOOST_CONSTEXPR_OR_CONST bu::mass M;
36 BOOST_CONSTEXPR_OR_CONST bu::time T;
37
38 BOOST_TEST(+L == L);
39 BOOST_TEST(-L == L);
40 BOOST_TEST(L+L == L);
41 BOOST_TEST(L-L == L);
42
43 BOOST_TEST(+M == M);
44 BOOST_TEST(-M == M);
45 BOOST_TEST(M+M == M);
46 BOOST_TEST(M-M == M);
47
48 BOOST_CONSTEXPR_OR_CONST bu::area A;
49 BOOST_CONSTEXPR_OR_CONST bu::energy E;
50 BOOST_CONSTEXPR_OR_CONST bu::velocity V;
51
52 BOOST_TEST(L*L == A);
53 BOOST_TEST(A == L*L);
54
55 BOOST_TEST(L/L == D);
56 BOOST_TEST(D == L/L);
57
58 BOOST_TEST(L/T == V);
59 BOOST_TEST(V == L/T);
60
61 BOOST_TEST(M*L*L/T/T == E);
62 BOOST_TEST(M*(L/T)*(L/T) == E);
63 BOOST_TEST(M*bu::pow<2>(L/T) == E);
64 BOOST_TEST(bu::root<2>(E/M) == V);
65
66 return boost::report_errors();
67}
68

source code of boost/libs/units/test/test_unit.cpp