Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r64129 - sandbox/opaque/libs/opaque/test
From: vicente.botet_at_[hidden]
Date: 2010-07-18 11:37:20


Author: viboes
Date: 2010-07-18 11:37:19 EDT (Sun, 18 Jul 2010)
New Revision: 64129
URL: http://svn.boost.org/trac/boost/changeset/64129

Log:
development continue
Added:
   sandbox/opaque/libs/opaque/test/add_pub_siblings_fail.cpp (contents, props changed)
   sandbox/opaque/libs/opaque/test/add_siblings_fail.cpp (contents, props changed)
   sandbox/opaque/libs/opaque/test/assign_pub_siblings_fail.cpp (contents, props changed)
   sandbox/opaque/libs/opaque/test/assign_publ_siblings_fail.cpp (contents, props changed)
   sandbox/opaque/libs/opaque/test/assign_siblings_fail.cpp (contents, props changed)
   sandbox/opaque/libs/opaque/test/private_opaque_test.cpp (contents, props changed)
   sandbox/opaque/libs/opaque/test/public_opaque_test.cpp (contents, props changed)
   sandbox/opaque/libs/opaque/test/two_level_conversion_fails.cpp (contents, props changed)
Text files modified:
   sandbox/opaque/libs/opaque/test/Jamfile.v2 | 14 +
   sandbox/opaque/libs/opaque/test/test.cpp | 280 ++++------------------------------------
   2 files changed, 40 insertions(+), 254 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-07-18 11:37:19 EDT (Sun, 18 Jul 2010)
@@ -27,9 +27,19 @@
 # <toolset>msvc:<asynch-exceptions>on
     ;
 
- test-suite "public_opaque"
+ test-suite "compile_fail"
        :
- [ run test.cpp ]
+ [ compile-fail two_level_conversion_fails.cpp ]
+ [ compile-fail add_siblings_fail.cpp ]
+ [ compile-fail assign_siblings_fail.cpp ]
+ [ compile-fail add_pub_siblings_fail.cpp ]
+ [ compile-fail assign_pub_siblings_fail.cpp ]
          ;
 
+ test-suite "opaque"
+ :
+ [ run test.cpp ]
+ [ run public_opaque_test.cpp ]
+ [ run private_opaque_test.cpp ]
+ ;
 

Added: sandbox/opaque/libs/opaque/test/add_pub_siblings_fail.cpp
==============================================================================
--- (empty file)
+++ sandbox/opaque/libs/opaque/test/add_pub_siblings_fail.cpp 2010-07-18 11:37:19 EDT (Sun, 18 Jul 2010)
@@ -0,0 +1,45 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (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;
+
+// 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);
+
+template <typename T>
+void f(T v) {
+}
+
+void public_multiple_levels_fail() {
+
+ A a;
+ B b;
+ a=a+b;
+ //~ kinetic_energy k;
+ //~ potential_energy p,q;
+
+
+ //~ k = p + q; // ok!!! error
+
+}
+
+

Added: sandbox/opaque/libs/opaque/test/add_siblings_fail.cpp
==============================================================================
--- (empty file)
+++ sandbox/opaque/libs/opaque/test/add_siblings_fail.cpp 2010-07-18 11:37:19 EDT (Sun, 18 Jul 2010)
@@ -0,0 +1,45 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (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;
+
+// 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);
+
+template <typename T>
+void f(T v) {
+}
+
+void public_multiple_levels_fail() {
+
+ A a;
+ B b;
+ f(a+b);
+ //~ kinetic_energy k;
+ //~ potential_energy p,q;
+
+
+ //~ k = p + q; // ok!!! error
+
+}
+
+

Added: sandbox/opaque/libs/opaque/test/assign_pub_siblings_fail.cpp
==============================================================================
--- (empty file)
+++ sandbox/opaque/libs/opaque/test/assign_pub_siblings_fail.cpp 2010-07-18 11:37:19 EDT (Sun, 18 Jul 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>
+
+#include <boost/test/unit_test.hpp>
+
+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);
+
+
+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/assign_publ_siblings_fail.cpp
==============================================================================
--- (empty file)
+++ sandbox/opaque/libs/opaque/test/assign_publ_siblings_fail.cpp 2010-07-18 11:37:19 EDT (Sun, 18 Jul 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>
+
+#include <boost/test/unit_test.hpp>
+
+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/assign_siblings_fail.cpp
==============================================================================
--- (empty file)
+++ sandbox/opaque/libs/opaque/test/assign_siblings_fail.cpp 2010-07-18 11:37:19 EDT (Sun, 18 Jul 2010)
@@ -0,0 +1,38 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (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;
+
+// Listing 5
+
+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/private_opaque_test.cpp
==============================================================================
--- (empty file)
+++ sandbox/opaque/libs/opaque/test/private_opaque_test.cpp 2010-07-18 11:37:19 EDT (Sun, 18 Jul 2010)
@@ -0,0 +1,131 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (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;
+
+
+
+BOOST_OPAQUE_PRIVATE_TYPEDEF(unsigned,private_unsigned);
+BOOST_OPAQUE_PRIVATE_TYPEDEF(unsigned,private_unsigned2);
+
+void private_assign_test() {
+ private_unsigned a, a2;
+ private_unsigned2 b;
+
+ //~ a=b; // error
+ a=a2; // OK
+
+ unsigned i;
+
+ //~ i=opaque_static_cast<unsigned>(a);
+ //~ i=a; // error
+
+ //~ i=b; // error
+ //~ a=i; // error
+ //~ b=i; // error
+}
+
+void private_eq_test() {
+ private_unsigned a(1), b(2), c(2);
+ BOOST_CHECK(b==c);
+ BOOST_CHECK((a==b)==false);
+}
+#if 0
+void private_eq_test_fails() {
+ private_unsigned a;
+ private_unsigned2 a2;
+ BOOST_CHECK(a==a2);
+}
+#endif
+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);
+}
+
+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;
+}
+
+

Added: sandbox/opaque/libs/opaque/test/public_opaque_test.cpp
==============================================================================
--- (empty file)
+++ sandbox/opaque/libs/opaque/test/public_opaque_test.cpp 2010-07-18 11:37:19 EDT (Sun, 18 Jul 2010)
@@ -0,0 +1,129 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (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;
+
+
+BOOST_OPAQUE_PUBLIC_TYPEDEF(unsigned,public_unsigned);
+BOOST_OPAQUE_PUBLIC_TYPEDEF(unsigned,public_unsigned2);
+
+void public_assign_test() {
+ public_unsigned a, a2;
+ public_unsigned2 b;
+
+ //~ a=b; // error
+ a=a2; // OK
+
+ unsigned i;
+
+ i=a;
+ i=b;
+ //~ a=i; // error
+ //~ b=i; // error
+}
+
+void public_eq_test() {
+ public_unsigned a(1), b(2), c(2);
+ BOOST_CHECK(b==c);
+ BOOST_CHECK((a==b)==false);
+
+ unsigned u=1,v=2;
+ BOOST_CHECK(a==1u);
+ BOOST_CHECK(u==a);
+ BOOST_CHECK(a==u);
+ BOOST_CHECK((a==v)==false);
+ BOOST_CHECK((v==a)==false);
+}
+
+void public_lt_test() {
+ public_unsigned a(1), b(2), c(2);
+ BOOST_CHECK(a<b);
+ BOOST_CHECK((b<a)==false);
+ BOOST_CHECK((b<c)==false);
+}
+
+void public_gt_test() {
+ public_unsigned a(1), b(2), c(2);
+ BOOST_CHECK(b>a);
+ BOOST_CHECK((a>b)==false);
+ BOOST_CHECK((b>c)==false);
+}
+
+void public_le_test() {
+ public_unsigned a(1), b(2), c(2);
+ BOOST_CHECK(a<=b);
+ BOOST_CHECK((b<=a)==false);
+ BOOST_CHECK(b<=c);
+}
+void public_ge_test() {
+ public_unsigned a(1), b(2), c(2);
+ BOOST_CHECK(b>=a);
+ BOOST_CHECK((a>=b)==false);
+ BOOST_CHECK(b>=c);
+}
+
+void public_add_test() {
+ public_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);
+
+ public_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 public_substract_test() {
+ public_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("public");
+
+ test->add(BOOST_TEST_CASE(&public_assign_test));
+ test->add(BOOST_TEST_CASE(&public_eq_test));
+ test->add(BOOST_TEST_CASE(&public_lt_test));
+ test->add(BOOST_TEST_CASE(&public_gt_test));
+ test->add(BOOST_TEST_CASE(&public_le_test));
+ test->add(BOOST_TEST_CASE(&public_ge_test));
+ test->add(BOOST_TEST_CASE(&public_add_test));
+ test->add(BOOST_TEST_CASE(&public_substract_test));
+
+ return test;
+}
+
+

Modified: sandbox/opaque/libs/opaque/test/test.cpp
==============================================================================
--- sandbox/opaque/libs/opaque/test/test.cpp (original)
+++ sandbox/opaque/libs/opaque/test/test.cpp 2010-07-18 11:37:19 EDT (Sun, 18 Jul 2010)
@@ -16,16 +16,15 @@
 using namespace boost::unit_test;
 
 
-//~ struct game_score: public_opaque_type<game_score, unsigned>
-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);
-};
+//~ 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);
 
@@ -33,15 +32,15 @@
  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);
-
+//~ 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);
@@ -57,7 +56,7 @@
     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));
@@ -68,9 +67,9 @@
     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);
 }
 
@@ -80,196 +79,8 @@
     //~ BOOST_CHECK(serial_number(3)==game_score(3));
 //~ }
 
-
-BOOST_OPAQUE_PUBLIC_TYPEDEF(unsigned,public_unsigned);
-BOOST_OPAQUE_PUBLIC_TYPEDEF(unsigned,public_unsigned2);
-
-void public_assign_test() {
- public_unsigned a, a2;
- public_unsigned2 b;
-
- //~ a=b; // error
- a=a2; // OK
-
- unsigned i;
-
- i=a;
- i=b;
- //~ a=i; // error
- //~ b=i; // error
-}
-
-void public_eq_test() {
- public_unsigned a(1), b(2), c(2);
- BOOST_CHECK(b==c);
- BOOST_CHECK((a==b)==false);
-
- unsigned u=1,v=2;
- BOOST_CHECK(a==1u);
- BOOST_CHECK(u==a);
- BOOST_CHECK(a==u);
- BOOST_CHECK((a==v)==false);
- BOOST_CHECK((v==a)==false);
-}
-
-void public_lt_test() {
- public_unsigned a(1), b(2), c(2);
- BOOST_CHECK(a<b);
- BOOST_CHECK((b<a)==false);
- BOOST_CHECK((b<c)==false);
-}
-
-void public_gt_test() {
- public_unsigned a(1), b(2), c(2);
- BOOST_CHECK(b>a);
- BOOST_CHECK((a>b)==false);
- BOOST_CHECK((b>c)==false);
-}
-
-void public_le_test() {
- public_unsigned a(1), b(2), c(2);
- BOOST_CHECK(a<=b);
- BOOST_CHECK((b<=a)==false);
- BOOST_CHECK(b<=c);
-}
-void public_ge_test() {
- public_unsigned a(1), b(2), c(2);
- BOOST_CHECK(b>=a);
- BOOST_CHECK((a>=b)==false);
- BOOST_CHECK(b>=c);
-}
-
-void public_add_test() {
- public_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);
-
- public_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 public_substract_test() {
- public_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);
-
-}
-
-BOOST_OPAQUE_PRIVATE_TYPEDEF(unsigned,private_unsigned);
-BOOST_OPAQUE_PRIVATE_TYPEDEF(unsigned,private_unsigned2);
-
-void private_assign_test() {
- private_unsigned a, a2;
- private_unsigned2 b;
-
- //~ a=b; // error
- a=a2; // OK
-
- unsigned i;
-
- i=opaque_static_cast(a);
- //~ i=a; // error
-
- //~ i=b; // error
- //~ a=i; // error
- //~ b=i; // error
-}
-
-void private_eq_test() {
- private_unsigned a(1), b(2), c(2);
- BOOST_CHECK(b==c);
- BOOST_CHECK((a==b)==false);
-}
-#if 0
-void private_eq_test_fails() {
- private_unsigned a;
- private_unsigned2 a2;
- BOOST_CHECK(a==a2);
-}
-#endif
-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);
-}
-
-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() {
- public_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);
-
- public_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() {
- public_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);
-
-}
-
 // Listing 7
-BOOST_OPAQUE_PRIVATE_TYPEDEF(double,mass1_leng2_per_time2);
+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);
@@ -277,58 +88,23 @@
 
 double sqrt(double d) { return d;}
 void public_multiple_levels_test() {
- //~ double d;
- mass1_leng2_per_time2 x;
     energy e;
- kinetic_energy k;
     potential_energy p, q;
-
+
     p = p + q; // ok
- e = p + q; // ok
- //~ x = p + q; // error two levels
- //~ test.cpp:287: error: no match for 'operator=' in 'x = boost::operator+(const potential_energy&, const potential_energy&)(((const potential_energy&)((const potential_energy*)(& q))))'
- //~ test.cpp:270: note: candidates are: mass1_leng2_per_time2& mass1_leng2_per_time2::operator=(const mass1_leng2_per_time2&)
-
- //~ e = k + p; // ok!!! error
- //~ test.cpp:287: error: ambiguous overload for 'operator+' in 'k + p'
- //~ ..\..\../boost/operators.hpp:255: note: candidates are: energy boost::operator+(const energy&, const energy&)
- //~ ..\..\../boost/operators.hpp:255: note: energy boost::operator+(const kinetic_energy&, const energy&)
- //~ ..\..\../boost/operators.hpp:255: note: energy boost::operator+(const energy&, const potential_energy&)
-
- //~ k = p + q; // 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&)
-
- //~ d = sqrt(e); // error
- //~ test.cpp:302: error: cannot convert 'energy' to 'double' for argument '1' to 'double sqrt(double)'
+ 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));
-
- test->add(BOOST_TEST_CASE(&public_assign_test));
- test->add(BOOST_TEST_CASE(&public_eq_test));
- test->add(BOOST_TEST_CASE(&public_lt_test));
- test->add(BOOST_TEST_CASE(&public_gt_test));
- test->add(BOOST_TEST_CASE(&public_le_test));
- test->add(BOOST_TEST_CASE(&public_ge_test));
- test->add(BOOST_TEST_CASE(&public_add_test));
- test->add(BOOST_TEST_CASE(&public_substract_test));
-
-
- 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;
 }
 

Added: sandbox/opaque/libs/opaque/test/two_level_conversion_fails.cpp
==============================================================================
--- (empty file)
+++ sandbox/opaque/libs/opaque/test/two_level_conversion_fails.cpp 2010-07-18 11:37:19 EDT (Sun, 18 Jul 2010)
@@ -0,0 +1,69 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (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/mpl/assert.hpp>
+#include <boost/type_traits/is_same.hpp>
+#include <boost/mpl/contains.hpp>
+
+#include <boost/test/unit_test.hpp>
+
+using namespace boost;
+using namespace boost::unit_test;
+
+// 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);
+
+BOOST_OPAQUE_STATIC_ASSERT((
+ is_same<
+ mass1_leng2_per_time2::substituables,
+ mpl::vector<double>
+ >::value),
+ SSSSSSSSSSS,
+ (mass1_leng2_per_time2::substituables)
+);
+
+BOOST_OPAQUE_STATIC_ASSERT((
+ mpl::contains<
+ energy::substituables,
+ mass1_leng2_per_time2
+ >::value),
+ SSSSSSSSSSS,
+ (energy::substituables)
+);
+
+BOOST_OPAQUE_STATIC_ASSERT((
+ mpl::contains<
+ potential_energy::substituables,
+ mass1_leng2_per_time2
+ >::value),
+ SSSSSSSSSSS,
+ (potential_energy::substituables)
+);
+
+void public_multiple_levels_fail() {
+ mass1_leng2_per_time2 x;
+ energy e;
+ potential_energy p, q;
+
+ x = e;
+ e = p;
+ x = p; // error two levels
+ //~ x = p + q; // error two levels
+ //~ test.cpp:287: error: no match for 'operator=' in 'x = boost::operator+(const potential_energy&, const potential_energy&)(((const potential_energy&)((const potential_energy*)(& q))))'
+ //~ test.cpp:270: note: candidates are: mass1_leng2_per_time2& mass1_leng2_per_time2::operator=(const mass1_leng2_per_time2&)
+
+}
+
+


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