|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r55312 - sandbox/fmhess/libs/generic_ptr/test
From: fmhess_at_[hidden]
Date: 2009-07-31 11:55:40
Author: fmhess
Date: 2009-07-31 11:55:39 EDT (Fri, 31 Jul 2009)
New Revision: 55312
URL: http://svn.boost.org/trac/boost/changeset/55312
Log:
Added new test. Made existing tests actually report errors instead of always
passing.
Added:
sandbox/fmhess/libs/generic_ptr/test/cloning_monitor_test.cpp (contents, props changed)
Text files modified:
sandbox/fmhess/libs/generic_ptr/test/Jamfile.v2 | 1 +
sandbox/fmhess/libs/generic_ptr/test/basic_generic_pointer_test.cpp | 12 +++++++++---
sandbox/fmhess/libs/generic_ptr/test/cloning_test.cpp | 2 +-
sandbox/fmhess/libs/generic_ptr/test/throwing_test.cpp | 2 +-
4 files changed, 12 insertions(+), 5 deletions(-)
Modified: sandbox/fmhess/libs/generic_ptr/test/Jamfile.v2
==============================================================================
--- sandbox/fmhess/libs/generic_ptr/test/Jamfile.v2 (original)
+++ sandbox/fmhess/libs/generic_ptr/test/Jamfile.v2 2009-07-31 11:55:39 EDT (Fri, 31 Jul 2009)
@@ -23,6 +23,7 @@
test-suite "generic_ptr"
: [ thread-run basic_generic_pointer_test.cpp ]
[ run cloning_test.cpp ]
+ [ run cloning_monitor_test.cpp ]
[ run throwing_test.cpp ]
;
}
Modified: sandbox/fmhess/libs/generic_ptr/test/basic_generic_pointer_test.cpp
==============================================================================
--- sandbox/fmhess/libs/generic_ptr/test/basic_generic_pointer_test.cpp (original)
+++ sandbox/fmhess/libs/generic_ptr/test/basic_generic_pointer_test.cpp 2009-07-31 11:55:39 EDT (Fri, 31 Jul 2009)
@@ -70,6 +70,7 @@
<typename boost::generic_ptr::pointer_traits<GenericPointer>::value_type>(yp);
yp = boost::generic_ptr::dynamic_pointer_cast<Y>(p);
+ BOOST_TEST(boost::generic_ptr::get_plain_old_pointer(yp) != 0);
xp = boost::generic_ptr::dynamic_pointer_cast
<typename boost::generic_ptr::pointer_traits<GenericPointer>::value_type>(yp);
BOOST_TEST(boost::generic_ptr::get_plain_old_pointer(xp) != 0);
@@ -123,6 +124,11 @@
const void
>::other pointer_to_const_void_type;
pointer_to_const_void_type const_void_p(cp);
+ BOOST_TEST(cp == const_void_p ||
+ is_cloning_pointer);
+ void_p = p;
+ BOOST_TEST(cp == const_void_p ||
+ is_cloning_pointer);
}
int main()
@@ -200,8 +206,8 @@
dereference_test(p);
rebind_test(p);
cast_test(p);
- conversion_to_base_test(p);
- conversion_to_void_test(p);
+ conversion_to_base_test(p, true);
+ conversion_to_void_test(p, true);
}
- return 0;
+ return boost::report_errors();
}
Added: sandbox/fmhess/libs/generic_ptr/test/cloning_monitor_test.cpp
==============================================================================
--- (empty file)
+++ sandbox/fmhess/libs/generic_ptr/test/cloning_monitor_test.cpp 2009-07-31 11:55:39 EDT (Fri, 31 Jul 2009)
@@ -0,0 +1,60 @@
+//
+// cloning_monitor_test.cpp
+//
+// Copyright (c) 2009 Frank Mori Hess
+//
+// 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)
+//
+
+#include <boost/config.hpp>
+#include <boost/detail/lightweight_test.hpp>
+#include <boost/generic_ptr/cloning.hpp>
+#include <boost/generic_ptr/monitor.hpp>
+
+class event_counting_mutex
+{
+public:
+ event_counting_mutex():
+ lock_count(0),
+ unlock_count(0),
+ try_lock_count(0)
+ {}
+ void lock()
+ {
+ ++lock_count;
+ }
+ void unlock()
+ {
+ ++unlock_count;
+ }
+ bool try_lock()
+ {
+ ++lock_count;
+ ++try_lock_count;
+ return true;
+ }
+ unsigned lock_count;
+ unsigned unlock_count;
+ unsigned try_lock_count;
+};
+
+void clone_test()
+{
+ typedef boost::generic_ptr::cloning<boost::generic_ptr::monitor<int*, event_counting_mutex> > cloning_monitor_type;
+ cloning_monitor_type p0(new int());
+ BOOST_TEST(p0.get().get_mutex_ref().lock_count == 0);
+ BOOST_TEST(p0.get().get_mutex_ref().unlock_count == 0);
+ cloning_monitor_type p1(p0);
+ BOOST_TEST(p0.get().get_mutex_ref().lock_count == 1);
+ BOOST_TEST(p0.get().get_mutex_ref().unlock_count == 1);
+ BOOST_TEST(p1.get().get_mutex_ref().lock_count == 0);
+ BOOST_TEST(p1.get().get_mutex_ref().unlock_count == 0);
+}
+
+int main()
+{
+ clone_test();
+ return boost::report_errors();
+}
Modified: sandbox/fmhess/libs/generic_ptr/test/cloning_test.cpp
==============================================================================
--- sandbox/fmhess/libs/generic_ptr/test/cloning_test.cpp (original)
+++ sandbox/fmhess/libs/generic_ptr/test/cloning_test.cpp 2009-07-31 11:55:39 EDT (Fri, 31 Jul 2009)
@@ -160,5 +160,5 @@
cast_test();
deleter_test();
custom_cloner_test();
- return 0;
+ return boost::report_errors();
}
Modified: sandbox/fmhess/libs/generic_ptr/test/throwing_test.cpp
==============================================================================
--- sandbox/fmhess/libs/generic_ptr/test/throwing_test.cpp (original)
+++ sandbox/fmhess/libs/generic_ptr/test/throwing_test.cpp 2009-07-31 11:55:39 EDT (Fri, 31 Jul 2009)
@@ -52,5 +52,5 @@
{
implicit_conversion_test();
throw_test();
- return 0;
+ return boost::report_errors();
}
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