Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r65775 - in sandbox/opaque/libs/opaque/test: . new_class
From: vicente.botet_at_[hidden]
Date: 2010-10-05 17:15:30


Author: viboes
Date: 2010-10-05 17:15:27 EDT (Tue, 05 Oct 2010)
New Revision: 65775
URL: http://svn.boost.org/trac/boost/changeset/65775

Log:
Opaque:
* Update Jamfile and add more tests

Added:
   sandbox/opaque/libs/opaque/test/new_class/hiding_less_than_fail.cpp (contents, props changed)
   sandbox/opaque/libs/opaque/test/new_class/hiding_plus_fail.cpp (contents, props changed)
   sandbox/opaque/libs/opaque/test/new_class/multiply_assign_fail.cpp (contents, props changed)
   sandbox/opaque/libs/opaque/test/new_class/plus_fail.cpp (contents, props changed)
   sandbox/opaque/libs/opaque/test/new_class/using_divide_pass.cpp (contents, props changed)
   sandbox/opaque/libs/opaque/test/new_class/using_multiply_assign_pass.cpp (contents, props changed)
   sandbox/opaque/libs/opaque/test/new_class/using_multiply_pass.cpp (contents, props changed)
   sandbox/opaque/libs/opaque/test/new_class/using_plus_pass.cpp (contents, props changed)
Removed:
   sandbox/opaque/libs/opaque/test/test.cpp
Text files modified:
   sandbox/opaque/libs/opaque/test/Jamfile.v2 | 56 ++++++++++++++++++++++++++++-----------
   1 files changed, 40 insertions(+), 16 deletions(-)

Modified: sandbox/opaque/libs/opaque/test/Jamfile.v2
==============================================================================
--- sandbox/opaque/libs/opaque/test/Jamfile.v2 (original)
+++ sandbox/opaque/libs/opaque/test/Jamfile.v2 2010-10-05 17:15:27 EDT (Tue, 05 Oct 2010)
@@ -19,9 +19,9 @@
 project
     : requirements
         <library>/boost/test//boost_unit_test_framework/<link>static
-
+
         # uncomment the line above if you build outside the Boost release
- #<include>$(BOOST_ROOT)
+ #<include>$(BOOST_ROOT)
         # uncomment the line above if you build outside the Boost release
         #<include>../../..
 # <toolset>msvc:<asynch-exceptions>on
@@ -29,9 +29,13 @@
         <define>BOOST_RATIO_USES_MPL_ASSERT
         <warnings>all
         <toolset>gcc:<cxxflags>-Wextra
- <toolset>gcc:<cxxflags>-Wno-long-long
- <toolset>gcc-mingw-4.5.0:<cxxflags>-Wno-missing-field-initializers
+ <toolset>gcc:<cxxflags>-Wno-long-long
+ <toolset>gcc-mingw-4.5.0:<cxxflags>-Wno-missing-field-initializers
+ #<toolset>gcc-mingw-4.5.0:<cxxflags>-Wnon-template-friend
+ #<toolset>gcc-mingw-4.5.0:<cxxflags>-Wno-non-template-friend
         <toolset>gcc-mingw-4.5.0:<cxxflags>-fdiagnostics-show-option
+ #<toolset>gcc-3.4.4:<cxxflags>-Wno-non-template-friend
+ #<toolset>gcc-4.3.4:<cxxflags>-Wno-non-template-friend
         <toolset>msvc:<cxxflags>/wd4127
     ;
 
@@ -39,7 +43,12 @@
         :
         [ run new_type_test.cpp ]
         [ run new_class_test.cpp ]
+ ;
+
+ test-suite "new_class"
+ :
         [ run new_class/regular_pass.cpp ]
+
         [ compile-fail new_class/assign_siblings_fail.cpp ]
         [ compile-fail new_class/assign_up_fail.cpp ]
         [ compile-fail new_class/assign_down_fail.cpp ]
@@ -47,29 +56,44 @@
         [ compile-fail new_class/copy_construct_from_non_convertible_fail.cpp ]
 
         [ run new_class/using_less_than_pass.cpp ]
- [ run new_class/using_less_than_equal_pass.cpp ]
- [ run new_class/using_greater_than_pass.cpp ]
- [ run new_class/using_greater_than_equal_pass.cpp ]
- [ run new_class/using_equal_pass.cpp ]
- [ run new_class/using_not_equal_pass.cpp ]
-
         [ compile-fail new_class/less_than_fail.cpp ]
+ [ compile-fail new_class/hiding_less_than_fail.cpp ]
+
+ [ run new_class/using_less_than_equal_pass.cpp ]
         [ compile-fail new_class/less_than_equal_fail.cpp ]
+
+ [ run new_class/using_greater_than_pass.cpp ]
         [ compile-fail new_class/greater_than_fail.cpp ]
+
+ [ run new_class/using_greater_than_equal_pass.cpp ]
         [ compile-fail new_class/greater_than_equal_fail.cpp ]
+
+ [ run new_class/using_equal_pass.cpp ]
         [ compile-fail new_class/equal_fail.cpp ]
+
+ [ run new_class/using_not_equal_pass.cpp ]
         [ compile-fail new_class/not_equal_fail.cpp ]
 
+
         [ run new_class/using_plus_assign_pass.cpp ]
         [ compile-fail new_class/plus_assign_fail.cpp ]
+
         [ run new_class/using_minus_assign_pass.cpp ]
         [ compile-fail new_class/minus_assign_fail.cpp ]
-
- ;
 
- test-suite "opaque"
- :
- [ run test.cpp ]
+ [ run new_class/using_multiply_assign_pass.cpp ]
+ [ compile-fail new_class/multiply_assign_fail.cpp ]
+
+ [ run new_class/using_plus_pass.cpp ]
+ [ compile-fail new_class/plus_fail.cpp ]
+ #[ compile-fail new_class/hiding_plus_fail.cpp ]
+
+ [ run new_class/using_multiply_pass.cpp ]
+ #[ compile-fail new_class/multiply_fail.cpp ]
+
+ [ run new_class/using_divide_pass.cpp ]
+ #[ compile-fail new_class/divide_fail.cpp ]
+
         ;
 
    test-suite "public"
@@ -82,7 +106,7 @@
         :
         [ run private_opaque_test.cpp ]
         [ compile-fail private_opaque_explicit_conversion_fail.cpp ]
-
+
         ;
 
    test-suite "compile_fail"

Added: sandbox/opaque/libs/opaque/test/new_class/hiding_less_than_fail.cpp
==============================================================================
--- (empty file)
+++ sandbox/opaque/libs/opaque/test/new_class/hiding_less_than_fail.cpp 2010-10-05 17:15:27 EDT (Tue, 05 Oct 2010)
@@ -0,0 +1,54 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (C) Copyright Vicente J. Botet Escriba 2010. 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)
+//
+// See http://www.boost.org/libs/opaque for documentation.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+#include <boost/opaque/opaque.hpp>
+
+#include <boost/test/unit_test.hpp>
+
+using namespace boost;
+
+typedef int UT;
+typedef short UT2;
+
+// NEW_CLASS(NT,UT,((opaque::using_equality_comparable1<>)))
+struct NT :
+ boost::new_class<NT, UT
+ , boost::mpl::vector<
+ boost::opaque::using_less_than<>,
+ boost::opaque::hiding_less_than<>
+ >
+ >
+{
+ typedef
+ boost::new_class<NT, UT
+ , boost::mpl::vector<
+ boost::opaque::using_less_than<>,
+ boost::opaque::hiding_less_than<>
+ >
+ >
+ base_type;
+
+ NT(){}
+ explicit NT(unsigned v) : base_type(v) {}
+ template <typename W>
+ explicit NT(W w)
+ : base_type(w)
+ {}
+ NT(NT const& r)
+ : base_type(r.val_)
+ {}
+};
+
+
+void fail() {
+ NT a1(1), b2(2);
+ bool b = (a1 < b2);
+}
+

Added: sandbox/opaque/libs/opaque/test/new_class/hiding_plus_fail.cpp
==============================================================================
--- (empty file)
+++ sandbox/opaque/libs/opaque/test/new_class/hiding_plus_fail.cpp 2010-10-05 17:15:27 EDT (Tue, 05 Oct 2010)
@@ -0,0 +1,54 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (C) Copyright Vicente J. Botet Escriba 2010. 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)
+//
+// See http://www.boost.org/libs/opaque for documentation.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+#include <boost/opaque/opaque.hpp>
+
+#include <boost/test/unit_test.hpp>
+
+using namespace boost;
+
+typedef int UT;
+typedef short UT2;
+
+// NEW_CLASS(NT,UT,((opaque::using_equality_comparable1<>)))
+struct NT :
+ boost::new_class<NT, UT
+ , boost::mpl::vector<
+ boost::opaque::using_plus,
+ boost::opaque::hiding_plus
+ >
+ >
+{
+ typedef
+ boost::new_class<NT, UT
+ , boost::mpl::vector<
+ boost::opaque::using_plus,
+ boost::opaque::hiding_plus
+ >
+ >
+ base_type;
+
+ NT(){}
+ explicit NT(unsigned v) : base_type(v) {}
+ template <typename W>
+ explicit NT(W w)
+ : base_type(w)
+ {}
+ NT(NT const& r)
+ : base_type(r.val_)
+ {}
+};
+
+
+void fail() {
+ NT a1(1), b2(2);
+ NT c = (a1 + b2);
+}
+

Added: sandbox/opaque/libs/opaque/test/new_class/multiply_assign_fail.cpp
==============================================================================
--- (empty file)
+++ sandbox/opaque/libs/opaque/test/new_class/multiply_assign_fail.cpp 2010-10-05 17:15:27 EDT (Tue, 05 Oct 2010)
@@ -0,0 +1,40 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (C) Copyright Vicente J. Botet Escriba 2010. 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)
+//
+// See http://www.boost.org/libs/opaque for documentation.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+#include <boost/opaque/opaque.hpp>
+
+using namespace boost;
+
+typedef unsigned UT;
+
+// NEW_CLASS(NT1,UT)
+struct NT1 : boost::new_class<NT1, UT>
+{
+ typedef
+ boost::new_class<NT1, UT>
+ base_type;
+
+ NT1(){}
+ explicit NT1(unsigned v) : base_type(v) {}
+ template <typename W>
+ explicit NT1(W w)
+ : base_type(w)
+ {}
+ NT1(NT1 const& r)
+ : base_type(r.val_)
+ {}
+};
+
+void fail() {
+ NT1 a1(1), b2(2);
+ a1 *= b2;
+}
+
+

Added: sandbox/opaque/libs/opaque/test/new_class/plus_fail.cpp
==============================================================================
--- (empty file)
+++ sandbox/opaque/libs/opaque/test/new_class/plus_fail.cpp 2010-10-05 17:15:27 EDT (Tue, 05 Oct 2010)
@@ -0,0 +1,50 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (C) Copyright Vicente J. Botet Escriba 2010. 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)
+//
+// See http://www.boost.org/libs/opaque for documentation.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+#include <boost/opaque/opaque.hpp>
+
+#include <boost/test/unit_test.hpp>
+
+using namespace boost;
+
+typedef int UT;
+typedef short UT2;
+
+// NEW_CLASS(NT,UT,((opaque::using_equality_comparable1<>)))
+struct NT :
+ boost::new_class<NT, UT
+ , boost::mpl::vector<
+ >
+ >
+{
+ typedef
+ boost::new_class<NT, UT
+ , boost::mpl::vector<
+ >
+ >
+ base_type;
+
+ NT(){}
+ explicit NT(unsigned v) : base_type(v) {}
+ template <typename W>
+ explicit NT(W w)
+ : base_type(w)
+ {}
+ NT(NT const& r)
+ : base_type(r.val_)
+ {}
+};
+
+
+void fail() {
+ NT a1(1), b2(2);
+ NT c = (a1 + b2);
+}
+

Added: sandbox/opaque/libs/opaque/test/new_class/using_divide_pass.cpp
==============================================================================
--- (empty file)
+++ sandbox/opaque/libs/opaque/test/new_class/using_divide_pass.cpp 2010-10-05 17:15:27 EDT (Tue, 05 Oct 2010)
@@ -0,0 +1,107 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (C) Copyright Vicente J. Botet Escriba 2010. 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)
+//
+// See http://www.boost.org/libs/opaque for documentation.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+#include <boost/opaque/opaque.hpp>
+
+#include <boost/test/unit_test.hpp>
+
+using namespace boost;
+using namespace boost::unit_test;
+
+typedef int UT;
+typedef short UT2;
+
+// NEW_CLASS(NT,UT,((opaque::using_equality_comparable1<>)))
+struct NT :
+ boost::new_class<NT, UT
+ , boost::mpl::vector<
+ boost::opaque::using_divide
+ >
+ >
+{
+ typedef
+ boost::new_class<NT, UT
+ , boost::mpl::vector<
+ boost::opaque::using_divide
+ >
+ >
+ base_type;
+
+ NT(){}
+ explicit NT(unsigned v) : base_type(v) {}
+ template <typename W>
+ explicit NT(W w)
+ : base_type(w)
+ {}
+ NT(NT const& r)
+ : base_type(r.val_)
+ {}
+};
+
+
+void size_test() {
+ BOOST_CHECK(sizeof(NT)==sizeof(UT));
+}
+#if 0
+void default_constructor_test() {
+ NT a;
+}
+void copy_from_ut_test() {
+ UT ut(1);
+ NT a(ut);
+ BOOST_CHECK(a.underlying()==ut);
+}
+void copy_from_ut2_test() {
+ UT2 ut(1);
+ NT a(ut);
+ BOOST_CHECK(a.underlying()==ut);
+}
+void copy_constructor_test() {
+ NT a(1);
+ NT b(a);
+ BOOST_CHECK(a.underlying()==b.underlying());
+}
+
+void assign_test() {
+ NT a1, a2(2);
+ a1=a2; // OK
+ BOOST_CHECK(a1.underlying()==a2.underlying());
+}
+
+void opaque_static_cast_test() {
+ NT a(1);
+ UT2 i;
+ i=opaque_static_cast<UT2>(a);
+ BOOST_CHECK(i==a.underlying());
+}
+#endif
+void divide_test() {
+ NT a2(2), b3(3), c6(6);
+ a2 = c6 / b3;
+ BOOST_CHECK(a2.underlying()=2);
+}
+
+test_suite* init_unit_test_suite(int, char*[])
+{
+ test_suite* test = BOOST_TEST_SUITE("new_class.using_devide_pass");
+
+ test->add(BOOST_TEST_CASE(&size_test));
+#if 0
+ test->add(BOOST_TEST_CASE(&default_constructor_test));
+ test->add(BOOST_TEST_CASE(&copy_from_ut_test));
+ test->add(BOOST_TEST_CASE(&copy_from_ut2_test));
+ test->add(BOOST_TEST_CASE(&copy_constructor_test));
+ test->add(BOOST_TEST_CASE(&assign_test));
+ test->add(BOOST_TEST_CASE(&opaque_static_cast_test));
+#endif
+ test->add(BOOST_TEST_CASE(&divide_test));
+
+ return test;
+}

Added: sandbox/opaque/libs/opaque/test/new_class/using_multiply_assign_pass.cpp
==============================================================================
--- (empty file)
+++ sandbox/opaque/libs/opaque/test/new_class/using_multiply_assign_pass.cpp 2010-10-05 17:15:27 EDT (Tue, 05 Oct 2010)
@@ -0,0 +1,107 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (C) Copyright Vicente J. Botet Escriba 2010. 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)
+//
+// See http://www.boost.org/libs/opaque for documentation.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+#include <boost/opaque/opaque.hpp>
+
+#include <boost/test/unit_test.hpp>
+
+using namespace boost;
+using namespace boost::unit_test;
+
+typedef int UT;
+typedef short UT2;
+
+// NEW_CLASS(NT,UT,((opaque::using_equality_comparable1<>)))
+struct NT :
+ boost::new_class<NT, UT
+ , boost::mpl::vector<
+ boost::opaque::using_multiply_assign
+ >
+ >
+{
+ typedef
+ boost::new_class<NT, UT
+ , boost::mpl::vector<
+ boost::opaque::using_multiply_assign
+ >
+ >
+ base_type;
+
+ NT(){}
+ explicit NT(unsigned v) : base_type(v) {}
+ template <typename W>
+ explicit NT(W w)
+ : base_type(w)
+ {}
+ NT(NT const& r)
+ : base_type(r.val_)
+ {}
+};
+
+
+void size_test() {
+ BOOST_CHECK(sizeof(NT)==sizeof(UT));
+}
+#if 0
+void default_constructor_test() {
+ NT a;
+}
+void copy_from_ut_test() {
+ UT ut(1);
+ NT a(ut);
+ BOOST_CHECK(a.underlying()==ut);
+}
+void copy_from_ut2_test() {
+ UT2 ut(1);
+ NT a(ut);
+ BOOST_CHECK(a.underlying()==ut);
+}
+void copy_constructor_test() {
+ NT a(1);
+ NT b(a);
+ BOOST_CHECK(a.underlying()==b.underlying());
+}
+
+void assign_test() {
+ NT a1, a2(2);
+ a1=a2; // OK
+ BOOST_CHECK(a1.underlying()==a2.underlying());
+}
+
+void opaque_static_cast_test() {
+ NT a(1);
+ UT2 i;
+ i=opaque_static_cast<UT2>(a);
+ BOOST_CHECK(i==a.underlying());
+}
+#endif
+void multiply_assign_test() {
+ NT a1(2), b2(3);
+ a1 *= b2;
+ BOOST_CHECK(a1.underlying()=6);
+}
+
+test_suite* init_unit_test_suite(int, char*[])
+{
+ test_suite* test = BOOST_TEST_SUITE("new_class.using_multiply_assign_pass");
+
+ test->add(BOOST_TEST_CASE(&size_test));
+#if 0
+ test->add(BOOST_TEST_CASE(&default_constructor_test));
+ test->add(BOOST_TEST_CASE(&copy_from_ut_test));
+ test->add(BOOST_TEST_CASE(&copy_from_ut2_test));
+ test->add(BOOST_TEST_CASE(&copy_constructor_test));
+ test->add(BOOST_TEST_CASE(&assign_test));
+ test->add(BOOST_TEST_CASE(&opaque_static_cast_test));
+#endif
+ test->add(BOOST_TEST_CASE(&multiply_assign_test));
+
+ return test;
+}

Added: sandbox/opaque/libs/opaque/test/new_class/using_multiply_pass.cpp
==============================================================================
--- (empty file)
+++ sandbox/opaque/libs/opaque/test/new_class/using_multiply_pass.cpp 2010-10-05 17:15:27 EDT (Tue, 05 Oct 2010)
@@ -0,0 +1,107 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (C) Copyright Vicente J. Botet Escriba 2010. 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)
+//
+// See http://www.boost.org/libs/opaque for documentation.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+#include <boost/opaque/opaque.hpp>
+
+#include <boost/test/unit_test.hpp>
+
+using namespace boost;
+using namespace boost::unit_test;
+
+typedef int UT;
+typedef short UT2;
+
+// NEW_CLASS(NT,UT,((opaque::using_equality_comparable1<>)))
+struct NT :
+ boost::new_class<NT, UT
+ , boost::mpl::vector<
+ boost::opaque::using_multiply
+ >
+ >
+{
+ typedef
+ boost::new_class<NT, UT
+ , boost::mpl::vector<
+ boost::opaque::using_multiply
+ >
+ >
+ base_type;
+
+ NT(){}
+ explicit NT(unsigned v) : base_type(v) {}
+ template <typename W>
+ explicit NT(W w)
+ : base_type(w)
+ {}
+ NT(NT const& r)
+ : base_type(r.val_)
+ {}
+};
+
+
+void size_test() {
+ BOOST_CHECK(sizeof(NT)==sizeof(UT));
+}
+#if 0
+void default_constructor_test() {
+ NT a;
+}
+void copy_from_ut_test() {
+ UT ut(1);
+ NT a(ut);
+ BOOST_CHECK(a.underlying()==ut);
+}
+void copy_from_ut2_test() {
+ UT2 ut(1);
+ NT a(ut);
+ BOOST_CHECK(a.underlying()==ut);
+}
+void copy_constructor_test() {
+ NT a(1);
+ NT b(a);
+ BOOST_CHECK(a.underlying()==b.underlying());
+}
+
+void assign_test() {
+ NT a1, a2(2);
+ a1=a2; // OK
+ BOOST_CHECK(a1.underlying()==a2.underlying());
+}
+
+void opaque_static_cast_test() {
+ NT a(1);
+ UT2 i;
+ i=opaque_static_cast<UT2>(a);
+ BOOST_CHECK(i==a.underlying());
+}
+#endif
+void multiply_test() {
+ NT a2(2), b3(3), c6(2);
+ c6 = a2 * b3;
+ BOOST_CHECK(c6.underlying()=6);
+}
+
+test_suite* init_unit_test_suite(int, char*[])
+{
+ test_suite* test = BOOST_TEST_SUITE("new_class.using_multiply_pass");
+
+ test->add(BOOST_TEST_CASE(&size_test));
+#if 0
+ test->add(BOOST_TEST_CASE(&default_constructor_test));
+ test->add(BOOST_TEST_CASE(&copy_from_ut_test));
+ test->add(BOOST_TEST_CASE(&copy_from_ut2_test));
+ test->add(BOOST_TEST_CASE(&copy_constructor_test));
+ test->add(BOOST_TEST_CASE(&assign_test));
+ test->add(BOOST_TEST_CASE(&opaque_static_cast_test));
+#endif
+ test->add(BOOST_TEST_CASE(&multiply_test));
+
+ return test;
+}

Added: sandbox/opaque/libs/opaque/test/new_class/using_plus_pass.cpp
==============================================================================
--- (empty file)
+++ sandbox/opaque/libs/opaque/test/new_class/using_plus_pass.cpp 2010-10-05 17:15:27 EDT (Tue, 05 Oct 2010)
@@ -0,0 +1,107 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (C) Copyright Vicente J. Botet Escriba 2010. 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)
+//
+// See http://www.boost.org/libs/opaque for documentation.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+#include <boost/opaque/opaque.hpp>
+
+#include <boost/test/unit_test.hpp>
+
+using namespace boost;
+using namespace boost::unit_test;
+
+typedef int UT;
+typedef short UT2;
+
+// NEW_CLASS(NT,UT,((opaque::using_equality_comparable1<>)))
+struct NT :
+ boost::new_class<NT, UT
+ , boost::mpl::vector<
+ boost::opaque::using_plus
+ >
+ >
+{
+ typedef
+ boost::new_class<NT, UT
+ , boost::mpl::vector<
+ boost::opaque::using_plus
+ >
+ >
+ base_type;
+
+ NT(){}
+ explicit NT(unsigned v) : base_type(v) {}
+ template <typename W>
+ explicit NT(W w)
+ : base_type(w)
+ {}
+ NT(NT const& r)
+ : base_type(r.val_)
+ {}
+};
+
+
+void size_test() {
+ BOOST_CHECK(sizeof(NT)==sizeof(UT));
+}
+#if 0
+void default_constructor_test() {
+ NT a;
+}
+void copy_from_ut_test() {
+ UT ut(1);
+ NT a(ut);
+ BOOST_CHECK(a.underlying()==ut);
+}
+void copy_from_ut2_test() {
+ UT2 ut(1);
+ NT a(ut);
+ BOOST_CHECK(a.underlying()==ut);
+}
+void copy_constructor_test() {
+ NT a(1);
+ NT b(a);
+ BOOST_CHECK(a.underlying()==b.underlying());
+}
+
+void assign_test() {
+ NT a1, a2(2);
+ a1=a2; // OK
+ BOOST_CHECK(a1.underlying()==a2.underlying());
+}
+
+void opaque_static_cast_test() {
+ NT a(1);
+ UT2 i;
+ i=opaque_static_cast<UT2>(a);
+ BOOST_CHECK(i==a.underlying());
+}
+#endif
+void plus_test() {
+ NT a2, b3(3), c6(6);
+ a2 = c6 + b3;
+ BOOST_CHECK(a2.underlying()=9);
+}
+
+test_suite* init_unit_test_suite(int, char*[])
+{
+ test_suite* test = BOOST_TEST_SUITE("new_class.using_plus_pass");
+
+ test->add(BOOST_TEST_CASE(&size_test));
+#if 0
+ test->add(BOOST_TEST_CASE(&default_constructor_test));
+ test->add(BOOST_TEST_CASE(&copy_from_ut_test));
+ test->add(BOOST_TEST_CASE(&copy_from_ut2_test));
+ test->add(BOOST_TEST_CASE(&copy_constructor_test));
+ test->add(BOOST_TEST_CASE(&assign_test));
+ test->add(BOOST_TEST_CASE(&opaque_static_cast_test));
+#endif
+ test->add(BOOST_TEST_CASE(&plus_test));
+
+ return test;
+}

Deleted: sandbox/opaque/libs/opaque/test/test.cpp
==============================================================================
--- sandbox/opaque/libs/opaque/test/test.cpp 2010-10-05 17:15:27 EDT (Tue, 05 Oct 2010)
+++ (empty file)
@@ -1,110 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////
-//
-// (C) Copyright Vicente J. Botet Escriba 2010. 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)
-//
-// See http://www.boost.org/libs/opaque for documentation.
-//
-//////////////////////////////////////////////////////////////////////////////
-
-#include <boost/opaque/opaque.hpp>
-
-#include <boost/test/unit_test.hpp>
-
-using namespace boost;
-using namespace boost::unit_test;
-
-
-//~ struct game_score: private_opaque_type<game_score, unsigned>
-//~ {
- //~ // forward constructors
- //~ game_score(){}
- //~ template <typename T>
- //~ // explicit game_score(T v) : public_opaque_type<game_score, unsigned>(v) {}
- //~ explicit game_score(T v) : private_opaque_type<game_score, unsigned>(v) {}
- //~ //BOOST_OPAQUE_PRIVATE_OPERATIONS(game_score,unsigned);
-//~ };
-
-BOOST_OPAQUE_PRIVATE_TYPEDEF(unsigned,game_score);
-
-game_score accumulate( game_score g1, game_score g2 ) {
- return g1 + g2;
-}
-
-//~ struct serial_number: public_opaque_type<serial_number, unsigned>
-//~ {
- //~ // forward constructors
- //~ serial_number(){}
- //~ template <typename T>
- //~ explicit serial_number(T v) : public_opaque_type<serial_number, unsigned>(v) {}
-//~ };
-BOOST_OPAQUE_PUBLIC_TYPEDEF(unsigned,serial_number);
-
-
-serial_number next_id( serial_number n ) {
- //return static_cast<serial_number>(n + 1u);
- // return opaque_static_cast<serial_number>(n + 1u);
- return n + serial_number(1u);
-}
-
-void accumulate_test() {
- game_score gs1(1), gs2(2), res;
- res= accumulate(gs1,gs2);
- BOOST_CHECK(gs1<gs2);
- BOOST_CHECK(gs1<=gs2);
- BOOST_CHECK(gs2>=gs1);
- BOOST_CHECK(res==game_score(3));
- BOOST_CHECK(game_score(3)==res);
-
- game_score res2;
- res2=res+res;
- BOOST_CHECK(res+res==game_score(6));
-}
-
-void next_id_test() {
- serial_number sn(1), res;
- res= next_id(sn);
- BOOST_CHECK(res==serial_number(2));
- BOOST_CHECK(serial_number(2)==res);
-
- BOOST_CHECK(res+res==serial_number(4));
-
- BOOST_CHECK(sn<res);
-}
-
-//~ void mix_test_fail() {
- //~ game_score sn(1), res;
- //~ res= next_id(sn);
- //~ BOOST_CHECK(serial_number(3)==game_score(3));
-//~ }
-
-// Listing 7
-BOOST_OPAQUE_PUBLIC_TYPEDEF(double,mass1_leng2_per_time2);
-BOOST_OPAQUE_PUBLIC_TYPEDEF(mass1_leng2_per_time2,energy);
-BOOST_OPAQUE_PUBLIC_TYPEDEF(energy,kinetic_energy);
-BOOST_OPAQUE_PUBLIC_TYPEDEF(energy,potential_energy);
-BOOST_OPAQUE_PUBLIC_TYPEDEF(energy,heat_energy);
-
-void public_multiple_levels_test() {
- energy e;
- potential_energy p, q;
-
- p = p + q; // ok
- e = e + q; // ok
- e = p + e; // ok
-}
-
-
-test_suite* init_unit_test_suite(int, char*[])
-{
- test_suite* test = BOOST_TEST_SUITE("ex1");
- test->add(BOOST_TEST_CASE(&accumulate_test));
- test->add(BOOST_TEST_CASE(&next_id_test));
- test->add(BOOST_TEST_CASE(&public_multiple_levels_test));
-
-
- return test;
-}
-
-


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