Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r65744 - in sandbox/opaque/libs/opaque/test: . new_class
From: vicente.botet_at_[hidden]
Date: 2010-10-04 02:34:12


Author: viboes
Date: 2010-10-04 02:34:09 EDT (Mon, 04 Oct 2010)
New Revision: 65744
URL: http://svn.boost.org/trac/boost/changeset/65744

Log:
Opaque:
* Added new_class tests

Added:
   sandbox/opaque/libs/opaque/test/new_class/assign_down_fail.cpp (contents, props changed)
   sandbox/opaque/libs/opaque/test/new_class/assign_siblings_fail.cpp (contents, props changed)
   sandbox/opaque/libs/opaque/test/new_class/assign_up_fail.cpp (contents, props changed)
   sandbox/opaque/libs/opaque/test/new_class/copy_construct_from_non_convertible_fail.cpp (contents, props changed)
   sandbox/opaque/libs/opaque/test/new_class/regular_pass.cpp (contents, props changed)
Text files modified:
   sandbox/opaque/libs/opaque/test/Jamfile.v2 | 9 ++++++++-
   sandbox/opaque/libs/opaque/test/assign_siblings_fail.cpp | 9 +--------
   2 files changed, 9 insertions(+), 9 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 02:34:09 EDT (Mon, 04 Oct 2010)
@@ -39,6 +39,13 @@
         :
         [ run new_type_test.cpp ]
         [ run new_class_test.cpp ]
+ [ 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 ]
+ #[ compile-fail new_class/bad_metamixin_fail.cpp ]
+ [ compile-fail new_class/copy_construct_from_non_convertible_fail.cpp ]
+
         ;
 
    test-suite "opaque"
@@ -62,7 +69,7 @@
    test-suite "compile_fail"
         :
         [ compile-fail add_siblings_fail.cpp ]
- [ compile-fail assign_siblings_fail.cpp ]
+ #[ compile-fail assign_siblings_fail.cpp ]
         [ compile-fail add_pub_siblings_fail.cpp ]
         [ compile-fail assign_pub_siblings_fail.cpp ]
         ;

Modified: sandbox/opaque/libs/opaque/test/assign_siblings_fail.cpp
==============================================================================
--- sandbox/opaque/libs/opaque/test/assign_siblings_fail.cpp (original)
+++ sandbox/opaque/libs/opaque/test/assign_siblings_fail.cpp 2010-10-04 02:34:09 EDT (Mon, 04 Oct 2010)
@@ -24,14 +24,7 @@
 void public_multiple_levels_fail() {
     A a;
     B b;
- a=b; // error
-
- //~ kinetic_energy k;
- //~ potential_energy p;
-
- //~ k = p; // error
- //~ test.cpp:297: error: no match for 'operator=' in 'k = boost::operator+(const potential_energy&, const potential_energy&)(((const potential_energy&)((const potential_energy*)(& q))))'
- //~ test.cpp:272: note: candidates are: kinetic_energy& kinetic_energy::operator=(const kinetic_energy&)
+ a=b; // compile error
 
 }
 

Added: sandbox/opaque/libs/opaque/test/new_class/assign_down_fail.cpp
==============================================================================
--- (empty file)
+++ sandbox/opaque/libs/opaque/test/new_class/assign_down_fail.cpp 2010-10-04 02:34:09 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;
+
+// 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 a;
+ UT b(1);
+ a=b; // compile error
+}
+
+

Added: sandbox/opaque/libs/opaque/test/new_class/assign_siblings_fail.cpp
==============================================================================
--- (empty file)
+++ sandbox/opaque/libs/opaque/test/new_class/assign_siblings_fail.cpp 2010-10-04 02:34:09 EDT (Mon, 04 Oct 2010)
@@ -0,0 +1,59 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (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_)
+ {}
+};
+
+// NEW_CLASS(NT2,UT)
+struct NT2 : boost::new_class<NT2, UT>
+{
+ typedef
+ boost::new_class<NT2, UT>
+ base_type;
+
+ NT2(){}
+ explicit NT2(unsigned v) : base_type(v) {}
+ template <typename W>
+ explicit NT2(W w)
+ : base_type(w)
+ {}
+ NT2(NT2 const& r)
+ : base_type(r.val_)
+ {}
+};
+
+void fail() {
+ NT1 a;
+ NT2 b(1);
+ a=b; // compile error
+}
+
+

Added: sandbox/opaque/libs/opaque/test/new_class/assign_up_fail.cpp
==============================================================================
--- (empty file)
+++ sandbox/opaque/libs/opaque/test/new_class/assign_up_fail.cpp 2010-10-04 02:34:09 EDT (Mon, 04 Oct 2010)
@@ -0,0 +1,42 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (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() {
+ UT a;
+ NT1 b(1);
+ a=b; // compile error
+
+}
+
+

Added: sandbox/opaque/libs/opaque/test/new_class/copy_construct_from_non_convertible_fail.cpp
==============================================================================
--- (empty file)
+++ sandbox/opaque/libs/opaque/test/new_class/copy_construct_from_non_convertible_fail.cpp 2010-10-04 02:34:09 EDT (Mon, 04 Oct 2010)
@@ -0,0 +1,43 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (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() {
+ NUT a;
+ NT1 b(a); // compile error
+
+
+}
+
+

Added: sandbox/opaque/libs/opaque/test/new_class/regular_pass.cpp
==============================================================================
--- (empty file)
+++ sandbox/opaque/libs/opaque/test/new_class/regular_pass.cpp 2010-10-04 02:34:09 EDT (Mon, 04 Oct 2010)
@@ -0,0 +1,90 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (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>
+{
+ typedef
+ boost::new_class<NT, UT>
+ 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));
+}
+
+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());
+}
+
+test_suite* init_unit_test_suite(int, char*[])
+{
+ test_suite* test = BOOST_TEST_SUITE("new_class.regular_pass");
+
+ test->add(BOOST_TEST_CASE(&size_test));
+ 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));
+
+ 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