Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r65612 - sandbox/opaque/libs/opaque/test
From: vicente.botet_at_[hidden]
Date: 2010-09-26 16:26:58


Author: viboes
Date: 2010-09-26 16:26:48 EDT (Sun, 26 Sep 2010)
New Revision: 65612
URL: http://svn.boost.org/trac/boost/changeset/65612

Log:
Opaque: Add missing new_class.hpp

Added:
   sandbox/opaque/libs/opaque/test/new_class_test.cpp (contents, props changed)
Text files modified:
   sandbox/opaque/libs/opaque/test/add_pub_siblings_fail.cpp | 14 +-------------
   sandbox/opaque/libs/opaque/test/add_siblings_fail.cpp | 11 -----------
   sandbox/opaque/libs/opaque/test/assign_pub_siblings_fail.cpp | 12 ------------
   sandbox/opaque/libs/opaque/test/assign_publ_siblings_fail.cpp | 12 ------------
   sandbox/opaque/libs/opaque/test/private_opaque_explicit_conversion_fail.cpp | 2 +-
   5 files changed, 2 insertions(+), 49 deletions(-)

Modified: sandbox/opaque/libs/opaque/test/add_pub_siblings_fail.cpp
==============================================================================
--- sandbox/opaque/libs/opaque/test/add_pub_siblings_fail.cpp (original)
+++ sandbox/opaque/libs/opaque/test/add_pub_siblings_fail.cpp 2010-09-26 16:26:48 EDT (Sun, 26 Sep 2010)
@@ -15,13 +15,6 @@
 using namespace boost;
 using namespace boost::unit_test;
 
-// Listing 7
-//~ BOOST_OPAQUE_PRIVATE_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);
-
 BOOST_OPAQUE_PRIVATE_TYPEDEF(int,A);
 BOOST_OPAQUE_PRIVATE_TYPEDEF(int,B);
 
@@ -34,12 +27,7 @@
     A a;
     B b;
     a=a+b;
- //~ kinetic_energy k;
- //~ potential_energy p,q;
-
-
- //~ k = p + q; // ok!!! error
-
+
 }
 
 

Modified: sandbox/opaque/libs/opaque/test/add_siblings_fail.cpp
==============================================================================
--- sandbox/opaque/libs/opaque/test/add_siblings_fail.cpp (original)
+++ sandbox/opaque/libs/opaque/test/add_siblings_fail.cpp 2010-09-26 16:26:48 EDT (Sun, 26 Sep 2010)
@@ -15,12 +15,6 @@
 using namespace boost;
 using namespace boost::unit_test;
 
-// Listing 7
-//~ BOOST_OPAQUE_PRIVATE_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);
 
 BOOST_OPAQUE_PRIVATE_TYPEDEF(int,A);
 BOOST_OPAQUE_PRIVATE_TYPEDEF(int,B);
@@ -34,11 +28,6 @@
     A a;
     B b;
     f(a+b);
- //~ kinetic_energy k;
- //~ potential_energy p,q;
-
-
- //~ k = p + q; // ok!!! error
 
 }
 

Modified: sandbox/opaque/libs/opaque/test/assign_pub_siblings_fail.cpp
==============================================================================
--- sandbox/opaque/libs/opaque/test/assign_pub_siblings_fail.cpp (original)
+++ sandbox/opaque/libs/opaque/test/assign_pub_siblings_fail.cpp 2010-09-26 16:26:48 EDT (Sun, 26 Sep 2010)
@@ -15,13 +15,6 @@
 using namespace boost;
 using namespace boost::unit_test;
 
-// Listing 7
-//~ BOOST_OPAQUE_PRIVATE_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);
-
 BOOST_OPAQUE_PUBLIC_TYPEDEF(int,A);
 BOOST_OPAQUE_PUBLIC_TYPEDEF(int,B);
 
@@ -31,13 +24,8 @@
     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&)
-
 }
 
 

Modified: sandbox/opaque/libs/opaque/test/assign_publ_siblings_fail.cpp
==============================================================================
--- sandbox/opaque/libs/opaque/test/assign_publ_siblings_fail.cpp (original)
+++ sandbox/opaque/libs/opaque/test/assign_publ_siblings_fail.cpp 2010-09-26 16:26:48 EDT (Sun, 26 Sep 2010)
@@ -15,26 +15,14 @@
 using namespace boost;
 using namespace boost::unit_test;
 
-// Listing 7
-//~ BOOST_OPAQUE_PRIVATE_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);
-
 BOOST_OPAQUE_PRIVATE_TYPEDEF(int,A);
 BOOST_OPAQUE_PRIVATE_TYPEDEF(int,B);
 
-
 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&)
 

Added: sandbox/opaque/libs/opaque/test/new_class_test.cpp
==============================================================================
--- (empty file)
+++ sandbox/opaque/libs/opaque/test/new_class_test.cpp 2010-09-26 16:26:48 EDT (Sun, 26 Sep 2010)
@@ -0,0 +1,176 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (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 private_unsigned :
+ boost::new_class<private_unsigned, unsigned, boost::mpl::vector<opaque::using_equality_comparable1> >
+//~ , opaque::equality_comparable1<private_unsigned
+ //~ >
+ //~ >
+{
+ typedef
+ //~ boost::new_class<private_unsigned, unsigned
+ //~ , opaque::equality_comparable1<private_unsigned
+ //~ >
+ //~ >
+ boost::new_class<private_unsigned, unsigned, boost::mpl::vector<opaque::using_equality_comparable1> >
+ base_type;
+
+ private_unsigned(){}
+ explicit private_unsigned(unsigned v) : base_type(v) {}
+ template <typename W>
+ explicit private_unsigned(W w)
+ : base_type(w)
+ {}
+ private_unsigned(private_unsigned const& r)
+ : base_type(r.val_)
+ {}
+};
+
+struct private_unsigned2: boost::new_class<private_unsigned2, unsigned>
+{
+ typedef boost::new_class<private_unsigned2, unsigned> base_type;
+
+ private_unsigned2(){}
+ explicit private_unsigned2(unsigned v) : base_type(v) {}
+ template <typename W>
+ explicit private_unsigned2(W w)
+ : base_type(w)
+ {}
+ private_unsigned2(private_unsigned2 const& r)
+ : base_type(r.val_)
+ {}
+};
+
+void private_assign_test() {
+ private_unsigned a, a2;
+ private_unsigned2 b;
+
+ //~ a=b; // error
+ a=a2; // OK
+
+ unsigned short i;
+
+ i=opaque_static_cast<unsigned short>(a);
+ //~ i=a; // error
+
+ //~ a=i; // error
+}
+
+void private_eq_test() {
+ private_unsigned a(1), b(2), c(2);
+ BOOST_CHECK(b==c);
+ BOOST_CHECK((a==b)==false);
+}
+void private_neq_test() {
+ private_unsigned a(1), b(2), c(2);
+ BOOST_CHECK(a!=b);
+ BOOST_CHECK((b!=c)==false);
+}
+//~ void private_lt_test() {
+ //~ private_unsigned a(1), b(2), c(2);
+ //~ BOOST_CHECK(a<b);
+ //~ BOOST_CHECK((b<a)==false);
+ //~ BOOST_CHECK((b<c)==false);
+//~ }
+#if 0
+
+void private_gt_test() {
+ private_unsigned a(1), b(2), c(2);
+ BOOST_CHECK(b>a);
+ BOOST_CHECK((a>b)==false);
+ BOOST_CHECK((b>c)==false);
+}
+
+void private_le_test() {
+ private_unsigned a(1), b(2), c(2);
+ BOOST_CHECK(a<=b);
+ BOOST_CHECK((b<=a)==false);
+ BOOST_CHECK(b<=c);
+}
+void private_ge_test() {
+ private_unsigned a(1), b(2), c(2);
+ BOOST_CHECK(b>=a);
+ BOOST_CHECK((a>=b)==false);
+ BOOST_CHECK(b>=c);
+}
+
+void private_add_test() {
+ private_unsigned a(1), b(2), c(3),d(4);
+ BOOST_CHECK(a+b==c);
+ BOOST_CHECK(c==a+b);
+ BOOST_CHECK((a+b==d)==false);
+ BOOST_CHECK((d==a+b)==false);
+
+ private_unsigned2 x;
+ //~ a=a+x; // error
+
+ //~ unsigned u=3,v=0;
+ //~ BOOST_CHECK(a+b==3u);
+ //~ BOOST_CHECK(u==a+b);
+ //~ BOOST_CHECK(a+b==u);
+ //~ BOOST_CHECK((a+b==v)==false);
+ //~ BOOST_CHECK((v==a+b)==false);
+
+}
+
+void private_substract_test() {
+ private_unsigned a(1), b(2), c(3),d(4);
+ BOOST_CHECK(c-b==a);
+ BOOST_CHECK(a==c-b);
+ BOOST_CHECK((c-b==d)==false);
+ BOOST_CHECK((d==c-b)==false);
+
+ //~ unsigned u=1,v=0;
+ //~ BOOST_CHECK(c-b==1u);
+ //~ BOOST_CHECK(u==c-b);
+ //~ BOOST_CHECK(c-b==u);
+ //~ BOOST_CHECK((c-b==v)==false);
+ //~ BOOST_CHECK((v==c-b)==false);
+
+}
+
+test_suite* init_unit_test_suite(int, char*[])
+{
+ test_suite* test = BOOST_TEST_SUITE("private");
+
+
+ test->add(BOOST_TEST_CASE(&private_assign_test));
+ test->add(BOOST_TEST_CASE(&private_eq_test));
+ test->add(BOOST_TEST_CASE(&private_lt_test));
+ test->add(BOOST_TEST_CASE(&private_gt_test));
+ test->add(BOOST_TEST_CASE(&private_le_test));
+ test->add(BOOST_TEST_CASE(&private_ge_test));
+ test->add(BOOST_TEST_CASE(&private_add_test));
+ test->add(BOOST_TEST_CASE(&private_substract_test));
+
+ return test;
+}
+
+#endif
+
+test_suite* init_unit_test_suite(int, char*[])
+{
+ test_suite* test = BOOST_TEST_SUITE("new");
+
+
+ test->add(BOOST_TEST_CASE(&private_assign_test));
+ test->add(BOOST_TEST_CASE(&private_eq_test));
+ test->add(BOOST_TEST_CASE(&private_neq_test));
+
+ return test;
+}

Modified: sandbox/opaque/libs/opaque/test/private_opaque_explicit_conversion_fail.cpp
==============================================================================
--- sandbox/opaque/libs/opaque/test/private_opaque_explicit_conversion_fail.cpp (original)
+++ sandbox/opaque/libs/opaque/test/private_opaque_explicit_conversion_fail.cpp 2010-09-26 16:26:48 EDT (Sun, 26 Sep 2010)
@@ -18,7 +18,7 @@
 
 BOOST_OPAQUE_PRIVATE_TYPEDEF(int,A);
 
-template <typename T> void f(T v) {}
+template <typename T> void f(T ) {}
 
 void public_multiple_levels_fail() {
     


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