|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r65753 - in sandbox/opaque/libs/opaque/test: . new_class
From: vicente.botet_at_[hidden]
Date: 2010-10-04 16:08:21
Author: viboes
Date: 2010-10-04 16:08:16 EDT (Mon, 04 Oct 2010)
New Revision: 65753
URL: http://svn.boost.org/trac/boost/changeset/65753
Log:
Opaque:
* Added new_class tests
Added:
sandbox/opaque/libs/opaque/test/new_class/minus_assign_fail.cpp (contents, props changed)
sandbox/opaque/libs/opaque/test/new_class/not_equal_fail.cpp (contents, props changed)
sandbox/opaque/libs/opaque/test/new_class/plus_assign_fail.cpp (contents, props changed)
sandbox/opaque/libs/opaque/test/new_class/using_minus_assign_pass.cpp (contents, props changed)
sandbox/opaque/libs/opaque/test/new_class/using_not_equal_pass.cpp (contents, props changed)
sandbox/opaque/libs/opaque/test/new_class/using_plus_assign_pass.cpp (contents, props changed)
Text files modified:
sandbox/opaque/libs/opaque/test/Jamfile.v2 | 7 +++++++
sandbox/opaque/libs/opaque/test/new_class/using_equal_pass.cpp | 2 +-
sandbox/opaque/libs/opaque/test/new_class/using_greater_than_pass.cpp | 2 +-
sandbox/opaque/libs/opaque/test/new_class/using_less_than_equal_pass.cpp | 2 +-
4 files changed, 10 insertions(+), 3 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-04 16:08:16 EDT (Mon, 04 Oct 2010)
@@ -51,12 +51,19 @@
[ 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/less_than_equal_fail.cpp ]
[ compile-fail new_class/greater_than_fail.cpp ]
[ compile-fail new_class/greater_than_equal_fail.cpp ]
[ compile-fail new_class/equal_fail.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 ]
;
Added: sandbox/opaque/libs/opaque/test/new_class/minus_assign_fail.cpp
==============================================================================
--- (empty file)
+++ sandbox/opaque/libs/opaque/test/new_class/minus_assign_fail.cpp 2010-10-04 16:08:16 EDT (Mon, 04 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/not_equal_fail.cpp
==============================================================================
--- (empty file)
+++ sandbox/opaque/libs/opaque/test/new_class/not_equal_fail.cpp 2010-10-04 16:08:16 EDT (Mon, 04 Oct 2010)
@@ -0,0 +1,41 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (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;
+typedef std::string NUT;
+
+// 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);
+ bool b =(a1 != b2);
+}
+
+
Added: sandbox/opaque/libs/opaque/test/new_class/plus_assign_fail.cpp
==============================================================================
--- (empty file)
+++ sandbox/opaque/libs/opaque/test/new_class/plus_assign_fail.cpp 2010-10-04 16:08:16 EDT (Mon, 04 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;
+}
+
+
Modified: sandbox/opaque/libs/opaque/test/new_class/using_equal_pass.cpp
==============================================================================
--- sandbox/opaque/libs/opaque/test/new_class/using_equal_pass.cpp (original)
+++ sandbox/opaque/libs/opaque/test/new_class/using_equal_pass.cpp 2010-10-04 16:08:16 EDT (Mon, 04 Oct 2010)
@@ -90,7 +90,7 @@
test_suite* init_unit_test_suite(int, char*[])
{
- test_suite* test = BOOST_TEST_SUITE("new_class.less_than_pass");
+ test_suite* test = BOOST_TEST_SUITE("new_class.equal_pass");
test->add(BOOST_TEST_CASE(&size_test));
#if 0
Modified: sandbox/opaque/libs/opaque/test/new_class/using_greater_than_pass.cpp
==============================================================================
--- sandbox/opaque/libs/opaque/test/new_class/using_greater_than_pass.cpp (original)
+++ sandbox/opaque/libs/opaque/test/new_class/using_greater_than_pass.cpp 2010-10-04 16:08:16 EDT (Mon, 04 Oct 2010)
@@ -91,7 +91,7 @@
test_suite* init_unit_test_suite(int, char*[])
{
- test_suite* test = BOOST_TEST_SUITE("new_class.less_than_pass");
+ test_suite* test = BOOST_TEST_SUITE("new_class.greater_than_pass");
test->add(BOOST_TEST_CASE(&size_test));
#if 0
Modified: sandbox/opaque/libs/opaque/test/new_class/using_less_than_equal_pass.cpp
==============================================================================
--- sandbox/opaque/libs/opaque/test/new_class/using_less_than_equal_pass.cpp (original)
+++ sandbox/opaque/libs/opaque/test/new_class/using_less_than_equal_pass.cpp 2010-10-04 16:08:16 EDT (Mon, 04 Oct 2010)
@@ -91,7 +91,7 @@
test_suite* init_unit_test_suite(int, char*[])
{
- test_suite* test = BOOST_TEST_SUITE("new_class.less_than_pass");
+ test_suite* test = BOOST_TEST_SUITE("new_class.less_than_equal_pass");
test->add(BOOST_TEST_CASE(&size_test));
#if 0
Added: sandbox/opaque/libs/opaque/test/new_class/using_minus_assign_pass.cpp
==============================================================================
--- (empty file)
+++ sandbox/opaque/libs/opaque/test/new_class/using_minus_assign_pass.cpp 2010-10-04 16:08:16 EDT (Mon, 04 Oct 2010)
@@ -0,0 +1,108 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (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_minus_assign
+ >
+ >
+{
+ typedef
+ boost::new_class<NT, UT
+ , boost::mpl::vector<
+ boost::opaque::using_minus_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 minus_assign_test() {
+ NT a1(1), b2(2), c2(2);
+ a1-=b2;
+ BOOST_CHECK(a1.underlying()=3);
+}
+
+test_suite* init_unit_test_suite(int, char*[])
+{
+ test_suite* test = BOOST_TEST_SUITE("new_class.using_minus_assign_pass");
+
+ test->add(BOOST_TEST_CASE(&size_test));
+#if 0
+ test->add(BOOST_TEST_CASE(&default_constructor_test));
+ test->add(BOOST_TEST_CASE(©_from_ut_test));
+ test->add(BOOST_TEST_CASE(©_from_ut2_test));
+ test->add(BOOST_TEST_CASE(©_constructor_test));
+ test->add(BOOST_TEST_CASE(&assign_test));
+ test->add(BOOST_TEST_CASE(&opaque_static_cast_test));
+#endif
+
+ test->add(BOOST_TEST_CASE(&minus_assign_test));
+
+ return test;
+}
Added: sandbox/opaque/libs/opaque/test/new_class/using_not_equal_pass.cpp
==============================================================================
--- (empty file)
+++ sandbox/opaque/libs/opaque/test/new_class/using_not_equal_pass.cpp 2010-10-04 16:08:16 EDT (Mon, 04 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_not_equal<>
+ >
+ >
+{
+ typedef
+ boost::new_class<NT, UT
+ , boost::mpl::vector<
+ boost::opaque::using_not_equal<>
+ >
+ >
+ 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 not_equal_test() {
+ NT a1(1), b2(2), c2(2);
+ BOOST_CHECK(a1!=c2);
+ BOOST_CHECK((b2!=c2)==false);
+}
+
+test_suite* init_unit_test_suite(int, char*[])
+{
+ test_suite* test = BOOST_TEST_SUITE("new_class.not_equal_pass");
+
+ test->add(BOOST_TEST_CASE(&size_test));
+#if 0
+ test->add(BOOST_TEST_CASE(&default_constructor_test));
+ test->add(BOOST_TEST_CASE(©_from_ut_test));
+ test->add(BOOST_TEST_CASE(©_from_ut2_test));
+ test->add(BOOST_TEST_CASE(©_constructor_test));
+ test->add(BOOST_TEST_CASE(&assign_test));
+ test->add(BOOST_TEST_CASE(&opaque_static_cast_test));
+#endif
+ test->add(BOOST_TEST_CASE(¬_equal_test));
+
+ return test;
+}
Added: sandbox/opaque/libs/opaque/test/new_class/using_plus_assign_pass.cpp
==============================================================================
--- (empty file)
+++ sandbox/opaque/libs/opaque/test/new_class/using_plus_assign_pass.cpp 2010-10-04 16:08:16 EDT (Mon, 04 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_assign
+ >
+ >
+{
+ typedef
+ boost::new_class<NT, UT
+ , boost::mpl::vector<
+ boost::opaque::using_plus_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 plus_assign_test() {
+ NT a1(1), b2(2), c2(2);
+ a1+=b2;
+ BOOST_CHECK(a1.underlying()=3);
+}
+
+test_suite* init_unit_test_suite(int, char*[])
+{
+ test_suite* test = BOOST_TEST_SUITE("new_class.using_plus_assign_pass");
+
+ test->add(BOOST_TEST_CASE(&size_test));
+#if 0
+ test->add(BOOST_TEST_CASE(&default_constructor_test));
+ test->add(BOOST_TEST_CASE(©_from_ut_test));
+ test->add(BOOST_TEST_CASE(©_from_ut2_test));
+ test->add(BOOST_TEST_CASE(©_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_assign_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