4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
6 // The contents of this file are subject to the Fraunhofer FOKUS Public License
7 // Version 1.0 (the "License"); you may not use this file except in compliance
8 // with the License. You may obtain a copy of the License at
9 // http://senf.berlios.de/license.html
11 // The Fraunhofer FOKUS Public License Version 1.0 is based on,
12 // but modifies the Mozilla Public License Version 1.1.
13 // See the full license text for the amendments.
15 // Software distributed under the License is distributed on an "AS IS" basis,
16 // WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
17 // for the specific language governing rights and limitations under the License.
19 // The Original Code is Fraunhofer FOKUS code.
21 // The Initial Developer of the Original Code is Fraunhofer-Gesellschaft e.V.
22 // (registered association), Hansastraße 27 c, 80686 Munich, Germany.
23 // All Rights Reserved.
26 // Stefan Bund <g0dil@berlios.de>
29 \brief RestrictedInt.test unit tests */
31 //#include "RestrictedInt.test.hh"
32 //#include "RestrictedInt.test.ih"
35 #include "RestrictedInt.hh"
37 #include <senf/Utils/auto_unit_test.hh>
38 #include <boost/test/test_tools.hpp>
41 //-/////////////////////////////////////////////////////////////////////////////////////////////////
45 typedef senf::RestrictedInt<int,TestIntTag> TestInt;
48 SENF_AUTO_UNIT_TEST(restrictedInt)
53 BOOST_CHECK_EQUAL( i1, TestInt(0) );
54 BOOST_CHECK_EQUAL( i2, TestInt(10) );
56 BOOST_CHECK_EQUAL( i1+i2, TestInt(10) );
60 BOOST_CHECK_EQUAL( i2-i1, TestInt(4) );
64 BOOST_CHECK_EQUAL( -i1, TestInt(-6) );
65 BOOST_CHECK( static_cast<bool>(i1) );
66 BOOST_CHECK( static_cast<bool>(!i2) );
68 BOOST_CHECK_EQUAL( i1 ++, TestInt(6) );
69 BOOST_CHECK_EQUAL( ++ i1, TestInt(8) );
71 BOOST_CHECK_EQUAL( i1 * TestInt(2), TestInt(16) );
72 BOOST_CHECK_EQUAL( i1, TestInt(8) );
73 BOOST_CHECK_EQUAL( i1 / TestInt(2), TestInt(4) );
74 BOOST_CHECK_EQUAL( i1, TestInt(8) );
75 BOOST_CHECK_EQUAL( i1 >> TestInt(1), TestInt(4) );
76 BOOST_CHECK_EQUAL( i1, TestInt(8) );
77 BOOST_CHECK_EQUAL( i1 << TestInt(1), TestInt(16) );
78 BOOST_CHECK_EQUAL( i1, TestInt(8) );
79 BOOST_CHECK_EQUAL( i1 & TestInt(2), TestInt(0) );
80 BOOST_CHECK_EQUAL( i1, TestInt(8) );
81 BOOST_CHECK_EQUAL( i1 | TestInt(2), TestInt(10) );
82 BOOST_CHECK_EQUAL( i1, TestInt(8) );
83 BOOST_CHECK_EQUAL( i1 ^ TestInt(2), TestInt(10) );
84 BOOST_CHECK_EQUAL( i1, TestInt(8) );
86 BOOST_CHECK_EQUAL( ~~i1, i1 );
87 SENF_CHECK_NOT_EQUAL( ~i1, i1 );
89 BOOST_CHECK( i1 > i2 );
90 BOOST_CHECK( i2 < i1 );
91 BOOST_CHECK( i1 >= i2 );
92 BOOST_CHECK( i2 <= i1 );
93 BOOST_CHECK( i1 == TestInt(8) );
94 BOOST_CHECK( i1 != i2 );
96 BOOST_CHECK_EQUAL( i1.value(), 8 );
100 BOOST_CHECK_EQUAL( ss.str(), "8" );
102 BOOST_CHECK_EQUAL( i2, TestInt(8) );
105 //-/////////////////////////////////////////////////////////////////////////////////////////////////
112 // comment-column: 40
113 // c-file-style: "senf"
114 // indent-tabs-mode: nil
115 // ispell-local-dictionary: "american"
116 // compile-command: "scons -u test"