|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r65698 - in sandbox/opaque/libs/opaque: example test
From: vicente.botet_at_[hidden]
Date: 2010-09-30 16:28:42
Author: viboes
Date: 2010-09-30 16:28:40 EDT (Thu, 30 Sep 2010)
New Revision: 65698
URL: http://svn.boost.org/trac/boost/changeset/65698
Log:
Opaque:
* add example/ex1.cpp
* Adapt to "Parameterize the boolean type resulting from relational operators".
Added:
sandbox/opaque/libs/opaque/example/ex1.cpp (contents, props changed)
Text files modified:
sandbox/opaque/libs/opaque/test/Jamfile.v2 | 5 +++++
sandbox/opaque/libs/opaque/test/new_class_test.cpp | 4 ++--
sandbox/opaque/libs/opaque/test/new_type_test.cpp | 2 +-
3 files changed, 8 insertions(+), 3 deletions(-)
Added: sandbox/opaque/libs/opaque/example/ex1.cpp
==============================================================================
--- (empty file)
+++ sandbox/opaque/libs/opaque/example/ex1.cpp 2010-09-30 16:28:40 EDT (Thu, 30 Sep 2010)
@@ -0,0 +1,56 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (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;
+
+#if 0
+typedef int Int;
+
+bool gt(Int a, Int b)
+{
+ if(a) return a > b; // 1
+ else return 0; // 2
+}
+#else
+//~ BOOST_OPAQUE_PUBLIC_TYPEDEF(bool, Bool);
+struct private_unsigned_tag;
+typedef boost::new_type<unsigned, private_unsigned_tag, boost::mpl::vector<
+ opaque::using_totally_ordered1<opaque::boolean>
+> > Int;
+//~ BOOST_OPAQUE_PRIVATE_TYPEDEF(int, Int);
+
+opaque::boolean gt(Int a, Int b)
+{
+ if(a!=Int(0)) return a > b; // 1
+ //~ else return false; // 2
+ else return opaque::false_; // 2
+}
+#endif
+
+
+void t() {
+ BOOST_CHECK(gt(Int(1),Int(0)));
+}
+
+test_suite* init_unit_test_suite(int, char*[])
+{
+ test_suite* test = BOOST_TEST_SUITE("ex1");
+
+ test->add(BOOST_TEST_CASE(&t));
+
+ return test;
+}
+
+
Modified: sandbox/opaque/libs/opaque/test/Jamfile.v2
==============================================================================
--- sandbox/opaque/libs/opaque/test/Jamfile.v2 (original)
+++ sandbox/opaque/libs/opaque/test/Jamfile.v2 2010-09-30 16:28:40 EDT (Thu, 30 Sep 2010)
@@ -67,3 +67,8 @@
[ compile-fail assign_pub_siblings_fail.cpp ]
;
+
+ test-suite "examples"
+ :
+ [ run ../example/ex1.cpp ]
+ ;
Modified: sandbox/opaque/libs/opaque/test/new_class_test.cpp
==============================================================================
--- sandbox/opaque/libs/opaque/test/new_class_test.cpp (original)
+++ sandbox/opaque/libs/opaque/test/new_class_test.cpp 2010-09-30 16:28:40 EDT (Thu, 30 Sep 2010)
@@ -17,7 +17,7 @@
struct private_unsigned :
- boost::new_class<private_unsigned, unsigned, boost::mpl::vector<opaque::using_equality_comparable1> >
+ boost::new_class<private_unsigned, unsigned, boost::mpl::vector<opaque::using_equality_comparable1<> > >
//~ , opaque::equality_comparable1<private_unsigned
//~ >
//~ >
@@ -27,7 +27,7 @@
//~ , opaque::equality_comparable1<private_unsigned
//~ >
//~ >
- boost::new_class<private_unsigned, unsigned, boost::mpl::vector<opaque::using_equality_comparable1> >
+ boost::new_class<private_unsigned, unsigned, boost::mpl::vector<opaque::using_equality_comparable1<> > >
base_type;
private_unsigned(){}
Modified: sandbox/opaque/libs/opaque/test/new_type_test.cpp
==============================================================================
--- sandbox/opaque/libs/opaque/test/new_type_test.cpp (original)
+++ sandbox/opaque/libs/opaque/test/new_type_test.cpp 2010-09-30 16:28:40 EDT (Thu, 30 Sep 2010)
@@ -53,7 +53,7 @@
};
#else
struct private_unsigned_tag;
-typedef boost::new_type<unsigned, private_unsigned_tag, boost::mpl::vector<opaque::using_equality_comparable1> > private_unsigned;
+typedef boost::new_type<unsigned, private_unsigned_tag, boost::mpl::vector<opaque::using_equality_comparable1<> > > private_unsigned;
struct private_unsigned2_tag;
typedef boost::new_type<unsigned, private_unsigned2_tag> private_unsigned2;
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