Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r51340 - sandbox/synchro/libs/synchro/test
From: vicente.botet_at_[hidden]
Date: 2009-02-19 18:46:05


Author: viboes
Date: 2009-02-19 18:46:04 EST (Thu, 19 Feb 2009)
New Revision: 51340
URL: http://svn.boost.org/trac/boost/changeset/51340

Log:
V0.0.0 :adding tests

Added:
   sandbox/synchro/libs/synchro/test/lockable_concepts_test.cpp (contents, props changed)
   sandbox/synchro/libs/synchro/test/lockable_traits_test.cpp (contents, props changed)
   sandbox/synchro/libs/synchro/test/locker_concepts_test.cpp (contents, props changed)
   sandbox/synchro/libs/synchro/test/nested_reverse_locker_test.cpp (contents, props changed)
   sandbox/synchro/libs/synchro/test/reverse_lock_test.cpp (contents, props changed)
   sandbox/synchro/libs/synchro/test/static_thread_group_test.cpp (contents, props changed)
   sandbox/synchro/libs/synchro/test/sync_buffer_family_test.cpp (contents, props changed)
   sandbox/synchro/libs/synchro/test/sync_buffer_monitor_test.cpp (contents, props changed)
   sandbox/synchro/libs/synchro/test/test.hpp (contents, props changed)
   sandbox/synchro/libs/synchro/test/unit_test.hpp (contents, props changed)

Added: sandbox/synchro/libs/synchro/test/lockable_concepts_test.cpp
==============================================================================
--- (empty file)
+++ sandbox/synchro/libs/synchro/test/lockable_concepts_test.cpp 2009-02-19 18:46:04 EST (Thu, 19 Feb 2009)
@@ -0,0 +1,91 @@
+/* Copyright 2008-2009 Vicente J. Botet Escriba
+ * 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/luid for library home page.
+ */
+
+#include <boost/synchro/lockable_traits.hpp>
+#include <boost/synchro/lockable_concepts.hpp>
+#include <boost/synchro/lockable_adapter.hpp>
+#include <boost/synchro/poly/lock_adapter.hpp>
+
+#include <boost/synchro/null_mutex.hpp>
+#include <boost/synchro/null_condition.hpp>
+
+#include <boost/synchro/thread/mutex.hpp>
+#include <boost/synchro/thread/recursive_mutex.hpp>
+#include <boost/synchro/thread/shared_mutex.hpp>
+
+#include <boost/synchro/process/mutex.hpp>
+#include <boost/synchro/process/recursive_mutex.hpp>
+#include <boost/synchro/process/upgradable_mutex.hpp>
+#include <boost/synchro/process/named_mutex.hpp>
+#include <boost/synchro/process/named_recursive_mutex.hpp>
+#include <boost/synchro/process/named_upgradable_mutex.hpp>
+
+#include <boost/type_traits/is_same.hpp>
+#include <boost/static_assert.hpp>
+
+#define BOOST_TEST_MODULE sync_lockable_concepts_test
+
+using namespace boost;
+using namespace boost::synchro;
+
+BOOST_CONCEPT_ASSERT((LockableConcept<null_mutex>));
+BOOST_CONCEPT_ASSERT((TimedLockableConcept<null_mutex>));
+BOOST_CONCEPT_ASSERT((ShareLockableConcept<null_mutex>));
+BOOST_CONCEPT_ASSERT((UpgradeLockableConcept<null_mutex>));
+
+BOOST_CONCEPT_ASSERT((LockableConcept<exclusive_lockable_adapter<null_mutex> >));
+BOOST_CONCEPT_ASSERT((TimedLockableConcept<timed_lockable_adapter<null_mutex> >));
+BOOST_CONCEPT_ASSERT((ShareLockableConcept<shared_lockable_adapter<null_mutex> >));
+BOOST_CONCEPT_ASSERT((UpgradeLockableConcept<upgrade_lockable_adapter<null_mutex> >));
+
+BOOST_CONCEPT_ASSERT((LockableConcept<poly::exclusive_lock_adapter<null_mutex> >));
+BOOST_CONCEPT_ASSERT((TimedLockableConcept<poly::timed_lock_adapter<null_mutex> >));
+BOOST_CONCEPT_ASSERT((ShareLockableConcept<poly::sharable_lock_adapter<null_mutex> >));
+BOOST_CONCEPT_ASSERT((UpgradeLockableConcept<poly::upgradable_lock_adapter<null_mutex> >));
+
+BOOST_CONCEPT_ASSERT((LockableConcept<thread_mutex>));
+
+
+BOOST_CONCEPT_ASSERT((LockableConcept<thread_timed_mutex>));
+BOOST_CONCEPT_ASSERT((TimedLockableConcept<thread_timed_mutex>));
+
+BOOST_CONCEPT_ASSERT((LockableConcept<thread_recursive_mutex>));
+
+BOOST_CONCEPT_ASSERT((LockableConcept<thread_recursive_timed_mutex>));
+BOOST_CONCEPT_ASSERT((TimedLockableConcept<thread_recursive_timed_mutex>));
+
+BOOST_CONCEPT_ASSERT((LockableConcept<thread_shared_mutex>));
+BOOST_CONCEPT_ASSERT((TimedLockableConcept<thread_shared_mutex>));
+BOOST_CONCEPT_ASSERT((ShareLockableConcept<thread_shared_mutex>));
+BOOST_CONCEPT_ASSERT((UpgradeLockableConcept<thread_shared_mutex>));
+
+BOOST_CONCEPT_ASSERT((LockableConcept<interprocess_mutex>));
+BOOST_CONCEPT_ASSERT((TimedLockableConcept<synchro::interprocess_mutex>));
+
+BOOST_CONCEPT_ASSERT((LockableConcept<synchro::interprocess_recursive_mutex>));
+BOOST_CONCEPT_ASSERT((TimedLockableConcept<synchro::interprocess_recursive_mutex>));
+
+BOOST_CONCEPT_ASSERT((LockableConcept<synchro::named_mutex>));
+BOOST_CONCEPT_ASSERT((TimedLockableConcept<synchro::named_mutex>));
+
+BOOST_CONCEPT_ASSERT((LockableConcept<synchro::interprocess_upgradable_mutex>));
+BOOST_CONCEPT_ASSERT((TimedLockableConcept<synchro::interprocess_upgradable_mutex>));
+BOOST_CONCEPT_ASSERT((ShareLockableConcept<synchro::interprocess_upgradable_mutex>));
+BOOST_CONCEPT_ASSERT((UpgradeLockableConcept<synchro::interprocess_upgradable_mutex>));
+
+BOOST_CONCEPT_ASSERT((LockableConcept<synchro::interprocess_named_upgradable_mutex>));
+BOOST_CONCEPT_ASSERT((TimedLockableConcept<synchro::interprocess_named_upgradable_mutex>));
+BOOST_CONCEPT_ASSERT((ShareLockableConcept<synchro::interprocess_named_upgradable_mutex>));
+BOOST_CONCEPT_ASSERT((UpgradeLockableConcept<boost::synchro::interprocess_named_upgradable_mutex>));
+
+//____________________________________________________________________________//
+
+
+//____________________________________________________________________________//
+
+// EOF

Added: sandbox/synchro/libs/synchro/test/lockable_traits_test.cpp
==============================================================================
--- (empty file)
+++ sandbox/synchro/libs/synchro/test/lockable_traits_test.cpp 2009-02-19 18:46:04 EST (Thu, 19 Feb 2009)
@@ -0,0 +1,140 @@
+/* Copyright 2008-2009 Vicente J. Botet Escriba
+ * 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/luid for library home page.
+ */
+
+
+
+
+#include <boost/synchro/lockable_traits.hpp>
+
+#include <boost/synchro/null_mutex.hpp>
+#include <boost/synchro/null_condition.hpp>
+
+#include <boost/synchro/thread/mutex.hpp>
+#include <boost/synchro/thread/recursive_mutex.hpp>
+#include <boost/synchro/thread/shared_mutex.hpp>
+
+#include <boost/synchro/process/mutex.hpp>
+#include <boost/synchro/process/recursive_mutex.hpp>
+#include <boost/synchro/process/upgradable_mutex.hpp>
+#include <boost/synchro/process/named_mutex.hpp>
+#include <boost/synchro/process/named_recursive_mutex.hpp>
+#include <boost/synchro/process/named_upgradable_mutex.hpp>
+
+#include <boost/type_traits/is_same.hpp>
+#include <boost/static_assert.hpp>
+
+#define BOOST_TEST_MODULE sync_lock_traits_test
+
+using namespace boost;
+using namespace boost::synchro;
+
+
+BOOST_STATIC_ASSERT((is_same<best_condition<null_mutex>::type, null_condition>::value));
+BOOST_STATIC_ASSERT((is_same<scope_tag<null_mutex>::type, mono_threaded_tag>::value));
+BOOST_STATIC_ASSERT((is_same<category_tag<null_mutex>::type, upgradable_lock_tag>::value));
+BOOST_STATIC_ASSERT((is_same<reentrancy_tag<null_mutex>::type, recursive_tag>::value));
+BOOST_STATIC_ASSERT((is_same<timed_interface_tag<null_mutex>::type, has_timed_interface_tag>::value));
+BOOST_STATIC_ASSERT((is_exclusive_lock<null_mutex>::value));
+BOOST_STATIC_ASSERT((is_sharable_lock<null_mutex>::value));
+BOOST_STATIC_ASSERT((is_upgradable_lock<null_mutex>::value));
+BOOST_STATIC_ASSERT((is_mono_threaded<null_mutex>::value));
+BOOST_STATIC_ASSERT((!is_multi_threaded<null_mutex>::value));
+BOOST_STATIC_ASSERT((!is_multi_process<null_mutex>::value));
+BOOST_STATIC_ASSERT((is_recursive_lock<null_mutex>::value));
+BOOST_STATIC_ASSERT((has_timed_interface<null_mutex>::value));
+
+BOOST_STATIC_ASSERT((is_same<best_condition<synchro::thread_mutex>::type, boost::condition_variable>::value));
+BOOST_STATIC_ASSERT((is_same<scope_tag<synchro::thread_mutex>::type, multi_threaded_tag>::value));
+BOOST_STATIC_ASSERT((is_same<category_tag<synchro::thread_mutex>::type, exclusive_lock_tag>::value));
+BOOST_STATIC_ASSERT((is_same<reentrancy_tag<synchro::thread_mutex>::type, non_recursive_tag>::value));
+BOOST_STATIC_ASSERT((is_same<timed_interface_tag<synchro::thread_mutex>::type, hasnt_timed_interface_tag>::value));
+BOOST_STATIC_ASSERT((is_exclusive_lock<synchro::thread_mutex>::value));
+BOOST_STATIC_ASSERT((!is_sharable_lock<synchro::thread_mutex>::value));
+BOOST_STATIC_ASSERT((!is_upgradable_lock<synchro::thread_mutex>::value));
+BOOST_STATIC_ASSERT((is_mono_threaded<synchro::thread_mutex>::value));
+BOOST_STATIC_ASSERT((is_multi_threaded<synchro::thread_mutex>::value));
+BOOST_STATIC_ASSERT((!is_multi_process<synchro::thread_mutex>::value));
+BOOST_STATIC_ASSERT((!is_recursive_lock<synchro::thread_mutex>::value));
+BOOST_STATIC_ASSERT((!has_timed_interface<synchro::thread_mutex>::value));
+
+
+BOOST_STATIC_ASSERT((is_same<scope_tag<synchro::thread_timed_mutex>::type, multi_threaded_tag>::value));
+BOOST_STATIC_ASSERT((is_same<category_tag<synchro::thread_timed_mutex>::type, exclusive_lock_tag>::value));
+BOOST_STATIC_ASSERT((is_same<reentrancy_tag<synchro::thread_timed_mutex>::type, non_recursive_tag>::value));
+BOOST_STATIC_ASSERT((is_same<timed_interface_tag<synchro::thread_timed_mutex>::type, has_timed_interface_tag>::value));
+BOOST_STATIC_ASSERT((is_exclusive_lock<synchro::thread_timed_mutex>::value));
+BOOST_STATIC_ASSERT((!is_sharable_lock<synchro::thread_timed_mutex>::value));
+BOOST_STATIC_ASSERT((!is_upgradable_lock<synchro::thread_timed_mutex>::value));
+BOOST_STATIC_ASSERT((is_mono_threaded<synchro::thread_timed_mutex>::value));
+BOOST_STATIC_ASSERT((is_multi_threaded<synchro::thread_timed_mutex>::value));
+BOOST_STATIC_ASSERT((!is_multi_process<synchro::thread_timed_mutex>::value));
+BOOST_STATIC_ASSERT((!is_recursive_lock<synchro::thread_timed_mutex>::value));
+BOOST_STATIC_ASSERT((has_timed_interface<synchro::thread_timed_mutex>::value));
+
+BOOST_STATIC_ASSERT((is_same<scope_tag<synchro::thread_recursive_mutex>::type, multi_threaded_tag>::value));
+BOOST_STATIC_ASSERT((is_same<category_tag<synchro::thread_recursive_mutex>::type, exclusive_lock_tag>::value));
+BOOST_STATIC_ASSERT((is_same<reentrancy_tag<synchro::thread_recursive_mutex>::type, recursive_tag>::value));
+BOOST_STATIC_ASSERT((is_same<timed_interface_tag<synchro::thread_recursive_mutex>::type, hasnt_timed_interface_tag>::value));
+BOOST_STATIC_ASSERT((is_exclusive_lock<synchro::thread_recursive_mutex>::value));
+BOOST_STATIC_ASSERT((!is_sharable_lock<synchro::thread_recursive_mutex>::value));
+BOOST_STATIC_ASSERT((!is_upgradable_lock<synchro::thread_recursive_mutex>::value));
+BOOST_STATIC_ASSERT((is_mono_threaded<synchro::thread_recursive_mutex>::value));
+BOOST_STATIC_ASSERT((is_multi_threaded<synchro::thread_recursive_mutex>::value));
+BOOST_STATIC_ASSERT((!is_multi_process<synchro::thread_recursive_mutex>::value));
+BOOST_STATIC_ASSERT((is_recursive_lock<synchro::thread_recursive_mutex>::value));
+BOOST_STATIC_ASSERT((!has_timed_interface<synchro::thread_recursive_mutex>::value));
+
+BOOST_STATIC_ASSERT((is_same<scope_tag<synchro::thread_recursive_timed_mutex>::type, multi_threaded_tag>::value));
+BOOST_STATIC_ASSERT((is_same<category_tag<synchro::thread_recursive_timed_mutex>::type, exclusive_lock_tag>::value));
+
+BOOST_STATIC_ASSERT((is_same<scope_tag<synchro::thread_shared_mutex>::type, multi_threaded_tag>::value));
+BOOST_STATIC_ASSERT((is_same<category_tag<synchro::thread_shared_mutex>::type, upgradable_lock_tag>::value));
+BOOST_STATIC_ASSERT((is_exclusive_lock<synchro::thread_shared_mutex>::value));
+BOOST_STATIC_ASSERT((is_sharable_lock<synchro::thread_shared_mutex>::value));
+BOOST_STATIC_ASSERT((is_upgradable_lock<synchro::thread_shared_mutex>::value));
+BOOST_STATIC_ASSERT((is_mono_threaded<synchro::thread_shared_mutex>::value));
+BOOST_STATIC_ASSERT((is_multi_threaded<synchro::thread_shared_mutex>::value));
+BOOST_STATIC_ASSERT((!is_multi_process<synchro::thread_shared_mutex>::value));
+
+BOOST_STATIC_ASSERT((is_same<scope_tag<synchro::interprocess_mutex>::type, multi_process_tag>::value));
+BOOST_STATIC_ASSERT((is_same<category_tag<synchro::interprocess_mutex>::type, exclusive_lock_tag>::value));
+BOOST_STATIC_ASSERT((is_exclusive_lock<synchro::interprocess_mutex>::value));
+BOOST_STATIC_ASSERT((!is_sharable_lock<synchro::interprocess_mutex>::value));
+BOOST_STATIC_ASSERT((!is_upgradable_lock<synchro::interprocess_mutex>::value));
+BOOST_STATIC_ASSERT((is_mono_threaded<synchro::interprocess_mutex>::value));
+BOOST_STATIC_ASSERT((is_multi_threaded<synchro::interprocess_mutex>::value));
+BOOST_STATIC_ASSERT((is_multi_process<synchro::interprocess_mutex>::value));
+
+BOOST_STATIC_ASSERT((is_same<scope_tag<synchro::interprocess_recursive_mutex>::type, multi_process_tag>::value));
+BOOST_STATIC_ASSERT((is_same<category_tag<synchro::interprocess_recursive_mutex>::type, exclusive_lock_tag>::value));
+
+BOOST_STATIC_ASSERT((is_same<scope_tag<synchro::named_mutex>::type, multi_process_tag>::value));
+BOOST_STATIC_ASSERT((is_same<category_tag<synchro::named_mutex>::type, exclusive_lock_tag>::value));
+
+
+BOOST_STATIC_ASSERT((is_same<scope_tag<boost::synchro::interprocess_upgradable_mutex>::type, multi_process_tag>::value));
+BOOST_STATIC_ASSERT((is_same<category_tag<boost::synchro::interprocess_upgradable_mutex>::type, upgradable_lock_tag>::value));
+
+BOOST_STATIC_ASSERT((is_same<scope_tag<boost::synchro::interprocess_named_upgradable_mutex>::type, multi_process_tag>::value));
+BOOST_STATIC_ASSERT((is_same<category_tag<boost::synchro::interprocess_named_upgradable_mutex>::type, upgradable_lock_tag>::value));
+
+
+#if 0
+BOOST_STATIC_ASSERT((is_same<scope_tag<synchro::named_upgradable_mutex>::type, multi_process_tag>::value));
+BOOST_STATIC_ASSERT((is_same<category_tag<synchro::named_upgradable_mutex>::type, upgradable_lock_tag>::value));
+BOOST_STATIC_ASSERT((is_same<scope_tag<synchro::interprocess_upgradable_mutex>::type, multi_process_tag>::value));
+BOOST_STATIC_ASSERT((is_same<category_tag<synchro::interprocess_upgradable_mutex>::type, upgradable_lock_tag>::value));
+#endif
+
+
+//____________________________________________________________________________//
+
+
+//____________________________________________________________________________//
+
+// EOF

Added: sandbox/synchro/libs/synchro/test/locker_concepts_test.cpp
==============================================================================
--- (empty file)
+++ sandbox/synchro/libs/synchro/test/locker_concepts_test.cpp 2009-02-19 18:46:04 EST (Thu, 19 Feb 2009)
@@ -0,0 +1,86 @@
+/* Copyright 2008-2009 Vicente J. Botet Escriba
+ * 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/luid for library home page.
+ */
+
+#include <boost/synchro/lockable_traits.hpp>
+#include <boost/synchro/lockable_concepts.hpp>
+#include <boost/synchro/locker_concepts.hpp>
+#include <boost/synchro/lockable_adapter.hpp>
+#include <boost/synchro/poly/lock_adapter.hpp>
+
+#include <boost/synchro/null_mutex.hpp>
+#include <boost/synchro/null_condition.hpp>
+
+#include <boost/synchro/thread/mutex.hpp>
+#include <boost/synchro/thread/recursive_mutex.hpp>
+#include <boost/synchro/thread/shared_mutex.hpp>
+#include <boost/synchro/thread/locks.hpp>
+
+#include <boost/synchro/process/mutex.hpp>
+#include <boost/synchro/process/recursive_mutex.hpp>
+#include <boost/synchro/process/upgradable_mutex.hpp>
+#include <boost/synchro/process/named_mutex.hpp>
+#include <boost/synchro/process/named_recursive_mutex.hpp>
+#include <boost/synchro/process/named_upgradable_mutex.hpp>
+#include <boost/synchro/process/locks.hpp>
+
+#include <boost/type_traits/is_same.hpp>
+#include <boost/static_assert.hpp>
+
+#define BOOST_TEST_MODULE sync_locker_concepts_test
+
+using namespace boost;
+using namespace boost::synchro;
+
+BOOST_CONCEPT_ASSERT((LockerConcept<unique_locker<thread_mutex> >));
+
+BOOST_CONCEPT_ASSERT((LockerConcept<unique_locker<thread_timed_mutex> >));
+BOOST_CONCEPT_ASSERT((TimedLockerConcept<unique_locker<thread_timed_mutex> >));
+BOOST_CONCEPT_ASSERT((UniqueLockerConcept<unique_locker<thread_timed_mutex> >));
+
+BOOST_CONCEPT_ASSERT((LockerConcept<shared_locker<thread_shared_mutex> >));
+BOOST_CONCEPT_ASSERT((TimedLockerConcept<shared_locker<thread_shared_mutex> >));
+BOOST_CONCEPT_ASSERT((UniqueLockerConcept<shared_locker<thread_shared_mutex> >));
+BOOST_CONCEPT_ASSERT((SharedLockerConcept<shared_locker<thread_shared_mutex> >));
+
+BOOST_CONCEPT_ASSERT((LockerConcept<upgrade_locker<thread_shared_mutex> >));
+// FAILS BOOST_CONCEPT_ASSERT((TimedLockerConcept<upgrade_locker<thread_shared_mutex> >));
+BOOST_CONCEPT_ASSERT((UniqueLockerConcept<upgrade_locker<thread_shared_mutex> >));
+BOOST_CONCEPT_ASSERT((SharedLockerConcept<upgrade_locker<thread_shared_mutex> >));
+BOOST_CONCEPT_ASSERT((UpgradeLockerConcept<upgrade_locker<thread_shared_mutex> >));
+
+BOOST_CONCEPT_ASSERT((LockerConcept<unique_locker<interprocess_mutex> >));
+BOOST_CONCEPT_ASSERT((TimedLockerConcept<unique_locker<interprocess_mutex> >));
+BOOST_CONCEPT_ASSERT((UniqueLockerConcept<unique_locker<interprocess_mutex> >));
+
+BOOST_CONCEPT_ASSERT((LockerConcept<shared_locker<interprocess_upgradable_mutex> >));
+BOOST_CONCEPT_ASSERT((TimedLockerConcept<shared_locker<interprocess_upgradable_mutex> >));
+BOOST_CONCEPT_ASSERT((UniqueLockerConcept<shared_locker<interprocess_upgradable_mutex> >));
+BOOST_CONCEPT_ASSERT((SharedLockerConcept<shared_locker<interprocess_upgradable_mutex> >));
+BOOST_CONCEPT_ASSERT((UpgradeLockerConcept<shared_locker<interprocess_upgradable_mutex> >));
+
+BOOST_CONCEPT_ASSERT((LockerConcept<upgrade_locker<interprocess_upgradable_mutex> >));
+BOOST_CONCEPT_ASSERT((TimedLockerConcept<upgrade_locker<interprocess_upgradable_mutex> >));
+BOOST_CONCEPT_ASSERT((UniqueLockerConcept<upgrade_locker<interprocess_upgradable_mutex> >));
+BOOST_CONCEPT_ASSERT((SharedLockerConcept<upgrade_locker<interprocess_upgradable_mutex> >));
+BOOST_CONCEPT_ASSERT((UpgradeLockerConcept<upgrade_locker<interprocess_upgradable_mutex> >));
+#if 0
+
+BOOST_CONCEPT_ASSERT((LockableConcept<exclusive_lockable_adapter<null_mutex> >));
+BOOST_CONCEPT_ASSERT((LockableConcept<poly::exclusive_lock_adapter<null_mutex> >));
+BOOST_CONCEPT_ASSERT((LockableConcept<thread_recursive_mutex>));
+BOOST_CONCEPT_ASSERT((LockableConcept<thread_recursive_timed_mutex>));
+BOOST_CONCEPT_ASSERT((LockableConcept<synchro::interprocess_recursive_mutex>));
+BOOST_CONCEPT_ASSERT((LockableConcept<synchro::named_mutex>));
+BOOST_CONCEPT_ASSERT((LockableConcept<synchro::interprocess_named_upgradable_mutex>));
+#endif
+//____________________________________________________________________________//
+
+
+//____________________________________________________________________________//
+
+// EOF

Added: sandbox/synchro/libs/synchro/test/nested_reverse_locker_test.cpp
==============================================================================
--- (empty file)
+++ sandbox/synchro/libs/synchro/test/nested_reverse_locker_test.cpp 2009-02-19 18:46:04 EST (Thu, 19 Feb 2009)
@@ -0,0 +1,143 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (C) Copyright Vicente J. Botet Escriba 2008-2009. 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/synchro for documentation.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+#include <boost/synchro/lockers/nested_reverse_locker.hpp>
+#include <boost/synchro/thread/mutex.hpp>
+#include <boost/synchro/thread/locks.hpp>
+#include <iostream>
+#include <boost/test/unit_test.hpp>
+
+using namespace boost;
+using namespace boost::unit_test;
+using namespace boost::synchro;
+
+ #define BOOST_SYNCHRONIZED_VAR(VARS_DECLARATION) if (volatile bool stop_ = false) {} else \
+ for (VARS_DECLARATION; !stop_; stop_ = true)
+
+ #define BOOST_SYNCHRONIZED(MUTEX) BOOST_SYNCHRONIZED_VAR(guard __lock(MUTEX))
+
+ #define synchronized(MUTEX) BOOST_SYNCHRONIZED(MUTEX)
+
+ #define atomic BOOST_SYNCHRONIZED(atomic_globla_mutex)
+
+
+static boost::mutex atomic_globla_mutex;
+struct guard {
+ boost::mutex& m_;
+ bool locked_;
+ guard(boost::mutex& m): m_(m) {
+ locked_ = m_.try_lock();
+ std::cout << "guard:" << &m_ << std::endl;
+ };
+ ~guard() {
+ std::cout << "~guard:" << &m_ << std::endl;
+ m_.unlock();
+ };
+ operator bool(/*synchronized _=mtx*/) const
+ {
+ return locked_;
+ }
+};
+
+struct non_copyable_class
+ : boost::noncopyable
+{
+ int value;
+ boost::mutex mtx;
+ typedef const guard &synchronized;
+ typedef guard synchronizer;
+
+ non_copyable_class():
+ value(0)
+ {}
+
+ void inc()
+ {
+ synchronized (mtx) ++value;
+ atomic ++value;
+ }
+ void dec()
+ {
+ synchronized(mtx) --value;
+ }
+ int get()
+ {
+ synchronized(mtx) return value;
+ return 0; // not reachable
+ }
+};
+
+//boost::mutex non_copyable_class::mtx;
+void test_xxx() {
+
+ {
+ typedef const guard &try_locker;
+ boost::mutex mtx;
+ bool res=false;
+ if (try_locker locker = mtx) {
+ res=true;
+ std::cout << "try_locker:OK=" << int(locker) << std::endl;
+ }
+ BOOST_CHECK(res);
+ }
+ {
+ typedef const try_unique_locker<thread_mutex> &try_locker;
+ thread_mutex mtx;
+ bool res=false;
+ try_unique_locker<thread_mutex> locker(mtx);
+ if (locker) {
+ res=true;
+ std::cout << "try_unique_locker:OK=" << std::endl;
+ }
+ BOOST_CHECK(res);
+ }
+ non_copyable_class cnt;
+ BOOST_CHECK(cnt.get()==0);
+ cnt.inc();
+ BOOST_CHECK(cnt.get()==2);
+ std::cout << "non_copyable_class " << cnt.get() << std::endl;
+ cnt.dec();
+ BOOST_CHECK(cnt.get()==1);
+ std::cout << "non_copyable_class " << cnt.get() << std::endl;
+
+}
+void test_locked() {
+ thread_mutex mtx;
+ unique_lock_type<thread_mutex>::type lock(mtx);
+ BOOST_CHECK(lock);
+ {
+ boost::synchro::nested_reverse_locker<unique_lock_type<thread_mutex>::type > rlock(lock);
+ BOOST_CHECK(!lock);
+ }
+ BOOST_CHECK(lock);
+}
+
+void test_unlocked() {
+ thread_mutex mtx;
+ unique_lock_type<thread_mutex>::type lock(mtx);
+ BOOST_CHECK(lock);
+ lock.unlock();
+ BOOST_CHECK(!lock);
+ {
+ synchro::nested_reverse_locker<unique_lock_type<thread_mutex>::type > rlock(lock);
+ BOOST_CHECK(!lock);
+ }
+ BOOST_CHECK(!lock);
+}
+
+test_suite* init_unit_test_suite(int, char*[])
+{
+ test_suite* test = BOOST_TEST_SUITE("nested_reverse_locker_tests");
+ test->add(BOOST_TEST_CASE(&test_xxx));
+ test->add(BOOST_TEST_CASE(&test_locked));
+ test->add(BOOST_TEST_CASE(&test_unlocked));
+ return test;
+}
+

Added: sandbox/synchro/libs/synchro/test/reverse_lock_test.cpp
==============================================================================
--- (empty file)
+++ sandbox/synchro/libs/synchro/test/reverse_lock_test.cpp 2009-02-19 18:46:04 EST (Thu, 19 Feb 2009)
@@ -0,0 +1,52 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (C) Copyright Vicente J. Botet Escriba 2008-2009. 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/synchro for documentation.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+#include <boost/synchro/lockers/reverse_lock.hpp>
+#include <boost/synchro/thread/mutex.hpp>
+#include <boost/synchro/thread/locks.hpp>
+#include <iostream>
+#include <boost/test/unit_test.hpp>
+
+using namespace boost;
+using namespace boost::unit_test;
+using namespace boost::synchro;
+
+void test_locked() {
+ boost::mutex mtx;
+ boost::unique_lock<boost::mutex> lock(mtx);
+ BOOST_CHECK(lock);
+ {
+ boost::synchro::reverse_lock<unique_lock<boost::mutex> > rlock(lock);
+ BOOST_CHECK(!lock);
+ }
+ BOOST_CHECK(lock);
+}
+
+void test_unlocked() {
+ boost::mutex mtx;
+ boost::unique_lock<boost::mutex> lock(mtx);
+ BOOST_CHECK(lock);
+ lock.unlock();
+ BOOST_CHECK(!lock);
+ {
+ boost::synchro::reverse_lock<unique_lock<boost::mutex> > rlock(lock);
+ BOOST_CHECK(!lock);
+ }
+ BOOST_CHECK(!lock);
+}
+
+test_suite* init_unit_test_suite(int, char*[])
+{
+ test_suite* test = BOOST_TEST_SUITE("reverse_lock_tests");
+ test->add(BOOST_TEST_CASE(&test_locked));
+ test->add(BOOST_TEST_CASE(&test_unlocked));
+ return test;
+}
+

Added: sandbox/synchro/libs/synchro/test/static_thread_group_test.cpp
==============================================================================
--- (empty file)
+++ sandbox/synchro/libs/synchro/test/static_thread_group_test.cpp 2009-02-19 18:46:04 EST (Thu, 19 Feb 2009)
@@ -0,0 +1,62 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (C) Copyright Vicente J. Botet Escriba 2008-2009. 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/synchro for documentation.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+#include <boost/synchro/conc/static_thread_group.hpp>
+#include <iostream>
+#include <boost/test/unit_test.hpp>
+
+using namespace boost;
+using namespace boost::unit_test;
+//using namespace boost::synchro;
+
+void th1() {
+ std::cout<<"th1_begin"<<std::endl;
+ boost::this_thread::sleep(boost::posix_time::seconds(2));
+ std::cout<<"th1_end"<<std::endl;
+}
+void th2() {
+ std::cout<<"th2_begin"<<std::endl;
+ boost::this_thread::sleep(boost::posix_time::seconds(3));
+ std::cout<<"th2_end"<<std::endl;
+}
+
+void test_join() {
+ boost::static_thread_group<2> stg(th1, th2);
+ stg.join();
+}
+void test_join_f() {
+ join_all(th1, th2);
+}
+
+void test_join_first() {
+ boost::static_thread_group<2> stg(th1, th2);
+ BOOST_CHECK(0==stg.join_first());
+ boost::this_thread::sleep(boost::posix_time::seconds(2));
+}
+void test_join_first_then_interrupt() {
+ boost::static_thread_group<2> stg(th1, th2);
+ unsigned end_id =stg.join_first();
+ stg.interrupt();
+ BOOST_CHECK(0==end_id);
+}
+void test_join_first_then_interrupt_f() {
+ BOOST_CHECK(0==join_first_then_interrupt(th1, th2));
+}
+test_suite* init_unit_test_suite(int, char*[])
+{
+ test_suite* test = BOOST_TEST_SUITE("static_thread_group_tests");
+ test->add(BOOST_TEST_CASE(&test_join));
+ test->add(BOOST_TEST_CASE(&test_join_f));
+ test->add(BOOST_TEST_CASE(&test_join_first));
+ test->add(BOOST_TEST_CASE(&test_join_first_then_interrupt));
+ test->add(BOOST_TEST_CASE(&test_join_first_then_interrupt_f));
+ return test;
+}
+

Added: sandbox/synchro/libs/synchro/test/sync_buffer_family_test.cpp
==============================================================================
--- (empty file)
+++ sandbox/synchro/libs/synchro/test/sync_buffer_family_test.cpp 2009-02-19 18:46:04 EST (Thu, 19 Feb 2009)
@@ -0,0 +1,143 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (C) Copyright Vicente J. Botet Escriba 2008-2009. 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/synchro for documentation.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+#include <boost/synchro/queues/synchro_buffer_family.hpp>
+#include <boost/synchro/thread_synchronization_family.hpp>
+#include <boost/synchro/process_synchronization_family.hpp>
+#include <boost/thread.hpp>
+#include <boost/bind.hpp>
+#include <iostream>
+#include <boost/test/unit_test.hpp>
+
+using namespace boost;
+using namespace boost::unit_test;
+using namespace boost::synchro;
+
+typedef sync_buffer<int, 10, boost::synchro::thread_synchronization_family> MyBuffer;
+MyBuffer gbuf;
+boost::mutex gmtx;
+
+void producer(int base)
+{
+ for(int i = 0; i<10; i++) {
+// thread::sleep(i);
+// {
+// boost::unique_lock<boost::mutex> l(gmtx);
+// std::cout << "buf.push("<<base+i<<");"<<std::endl;
+// }
+ gbuf.push(base+i);
+ }
+}
+
+void consumer() {
+ for(int i = 0; i<90; i++) {
+// thread::sleep(i);
+ int j;
+ j= gbuf.pull();
+// {
+// boost::unique_lock<boost::mutex> l(gmtx);
+// std::cout << "buf.pull() -> "<<j<<" "<<i<< std::endl;
+// }
+ boost::this_thread::sleep(boost::posix_time::seconds(1));
+
+// if (j!= i) return;
+ }
+}
+
+void test_1() {
+ boost::thread thread0(consumer); // start concurrent execution of consumer
+ boost::thread thread1(boost::bind(producer, 1000)); // start concurrent execution of producer
+ boost::thread thread2(boost::bind(producer, 2000)); // start concurrent execution of producer
+ boost::thread thread3(boost::bind(producer, 3000)); // start concurrent execution of consumer
+ boost::thread thread4(boost::bind(producer, 4000)); // start concurrent execution of consumer
+ boost::thread thread5(boost::bind(producer, 5000)); // start concurrent execution of consumer
+ boost::thread thread6(boost::bind(producer, 6000)); // start concurrent execution of consumer
+ boost::thread thread7(boost::bind(producer, 7000)); // start concurrent execution of consumer
+ boost::thread thread8(boost::bind(producer, 8000)); // start concurrent execution of consumer
+ boost::thread thread9(boost::bind(producer, 9000)); // start concurrent execution of consumer
+// thread::sleep(1);
+
+ thread0.join();
+ thread1.join();
+ thread2.join();
+ thread3.join();
+ thread4.join();
+ thread5.join();
+ thread6.join();
+ thread7.join();
+ thread8.join();
+ thread9.join();
+}
+
+void test_push() {
+ sync_buffer<int, 10, boost::synchro::thread_synchronization_family> buf;
+
+ BOOST_CHECK((buf.get_in()==0));
+ BOOST_CHECK((buf.get_out()==0));
+ BOOST_CHECK((buf.empty()));
+ BOOST_CHECK((!buf.full()));
+ buf.push(1);
+ std::cout << "buf.push("<<1<<");"<<std::endl;
+ std::cout << "in_ ="<< buf.get_in()<<std::endl;
+ std::cout << "out_ ="<< buf.get_out()<<std::endl;
+ std::cout << "(out_%size)+1 ="<< (buf.get_out()%2)+1<<std::endl;
+
+ BOOST_CHECK((buf.get_in()==1));
+ BOOST_CHECK((buf.get_out()==0));
+ BOOST_CHECK((!buf.empty()));
+ BOOST_CHECK((!buf.full()));
+
+ buf.push(2);
+ std::cout << "buf.push("<<2<<");"<<std::endl;
+ std::cout << "in_ ="<< buf.get_in()<<std::endl;
+ std::cout << "out_ ="<< buf.get_out()<<std::endl;
+ std::cout << "(out_%size)+1 ="<< (buf.get_out()%2)+1<<std::endl;
+
+ BOOST_CHECK((buf.get_in()==2));
+ BOOST_CHECK((buf.get_out()==0));
+ BOOST_CHECK((!buf.empty()));
+ BOOST_CHECK((buf.full()));
+
+
+ int l;
+ l= buf.pull();
+ std::cout << "buf.pull() -> "<<l<<""<<std::endl;
+ BOOST_CHECK(l==1);
+ BOOST_CHECK((!buf.empty()));
+ BOOST_CHECK((!buf.full()));
+
+ l= buf.pull();
+ std::cout << "buf.pull() -> "<<l<<""<<std::endl;
+ BOOST_CHECK(l==2);
+ BOOST_CHECK((buf.empty()));
+ BOOST_CHECK((!buf.full()));
+}
+
+//int main() {
+// test_1();
+//}
+//#define BOOST_TEST_MAIN syn
+//BOOST_TEST_SUITE( syn )
+//
+//BOOST_AUTO_TEST_CASE( t1 )
+//{
+// test_1();
+//}
+//
+//BOOST_AUTO_TEST_SUITE_END()
+
+test_suite* init_unit_test_suite(int, char*[])
+{
+ test_suite* test = BOOST_TEST_SUITE("sync__queues__sync_buffer_family");
+// test->add(BOOST_TEST_CASE(&test_push));
+ test->add(BOOST_TEST_CASE(&test_1));
+ return test;
+}
+

Added: sandbox/synchro/libs/synchro/test/sync_buffer_monitor_test.cpp
==============================================================================
--- (empty file)
+++ sandbox/synchro/libs/synchro/test/sync_buffer_monitor_test.cpp 2009-02-19 18:46:04 EST (Thu, 19 Feb 2009)
@@ -0,0 +1,133 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (C) Copyright Vicente J. Botet Escriba 2008-2009. 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/synchro for documentation.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+#include <boost/synchro/queues/synchro_buffer_monitor.hpp>
+#include <boost/thread.hpp>
+#include <boost/synchro/thread/mutex.hpp>
+#include <boost/synchro/thread/locks.hpp>
+#include <boost/bind.hpp>
+#include <iostream>
+#include <boost/test/unit_test.hpp>
+
+using namespace boost;
+using namespace boost::unit_test;
+using namespace boost::synchro;
+
+typedef sync_buffer<int, 10> MyBuffer;
+MyBuffer gbuf;
+boost::mutex gmtx;
+
+void producer(int base, int times)
+{
+ for(int i = 0; i<times; i++) {
+// thread::sleep(i);
+// {
+// boost::unique_lock<boost::mutex> l(gmtx);
+// std::cout << "buf.push("<<base+i<<");"<<std::endl;
+// }
+ gbuf.push(base+i);
+ }
+}
+
+void consumer(int times) {
+ for(int i = 0; i<times; i++) {
+// thread::sleep(i);
+ int j;
+ j= gbuf.pull();
+// {
+// boost::unique_lock<boost::mutex> l(gmtx);
+// std::cout << "buf.pull() -> "<<j<<" "<<i<< std::endl;
+// }
+ boost::this_thread::sleep(boost::posix_time::seconds(1));
+
+// if (j!= i) return;
+ }
+}
+
+void test_1() {
+// std::cout << "test_1"<<std::endl;
+ const int nb_prods=10;
+ const int times=10;
+ boost::thread thread0(boost::bind(consumer, nb_prods*times)); // start concurrent execution of consumer
+ boost::thread ath[nb_prods];
+ for (int i=0; i<nb_prods;++i) {
+ ath[i] =boost::thread(boost::bind(producer, 1000*i, times)); // start concurrent execution of producer
+ }
+ for (int i=0; i<nb_prods;++i) {
+ ath[i].join();
+ }
+ thread0.join();
+// std::cout << "test_1F"<<std::endl;
+}
+
+void test_push() {
+ sync_buffer<int, 2> buf;
+ BOOST_CHECK((buf.get_in()==0));
+ BOOST_CHECK((buf.get_out()==0));
+ BOOST_CHECK((buf.empty()));
+ BOOST_CHECK((!buf.full()));
+ buf.push(1);
+ std::cout << "buf.push("<<1<<");"<<std::endl;
+ std::cout << "in_ ="<< buf.get_in()<<std::endl;
+ std::cout << "out_ ="<< buf.get_out()<<std::endl;
+ std::cout << "(out_%size)+1 ="<< (buf.get_out()%2)+1<<std::endl;
+
+ BOOST_CHECK((buf.get_in()==1));
+ BOOST_CHECK((buf.get_out()==0));
+ BOOST_CHECK((!buf.empty()));
+ BOOST_CHECK((!buf.full()));
+
+ buf.push(2);
+ std::cout << "buf.push("<<2<<");"<<std::endl;
+ std::cout << "in_ ="<< buf.get_in()<<std::endl;
+ std::cout << "out_ ="<< buf.get_out()<<std::endl;
+ std::cout << "(out_%size)+1 ="<< (buf.get_out()%2)+1<<std::endl;
+
+ BOOST_CHECK((buf.get_in()==2));
+ BOOST_CHECK((buf.get_out()==0));
+ BOOST_CHECK((!buf.empty()));
+ BOOST_CHECK((buf.full()));
+
+
+ int l;
+ l= buf.pull();
+ std::cout << "buf.pull() -> "<<l<<""<<std::endl;
+ BOOST_CHECK(l==1);
+ BOOST_CHECK((!buf.empty()));
+ BOOST_CHECK((!buf.full()));
+
+ l= buf.pull();
+ std::cout << "buf.pull() -> "<<l<<""<<std::endl;
+ BOOST_CHECK(l==2);
+ BOOST_CHECK((buf.empty()));
+ BOOST_CHECK((!buf.full()));
+}
+
+//int main() {
+// test_1();
+//}
+//#define BOOST_TEST_MAIN syn
+//BOOST_TEST_SUITE( syn )
+//
+//BOOST_AUTO_TEST_CASE( t1 )
+//{
+// test_1();
+//}
+//
+//BOOST_AUTO_TEST_SUITE_END()
+
+test_suite* init_unit_test_suite(int, char*[])
+{
+ test_suite* test = BOOST_TEST_SUITE("sync__queues__sync_buffer_family");
+// test->add(BOOST_TEST_CASE(&test_push));
+ test->add(BOOST_TEST_CASE(&test_1));
+ return test;
+}
+

Added: sandbox/synchro/libs/synchro/test/test.hpp
==============================================================================
--- (empty file)
+++ sandbox/synchro/libs/synchro/test/test.hpp 2009-02-19 18:46:04 EST (Thu, 19 Feb 2009)
@@ -0,0 +1,192 @@
+/* Copyright 2008-2009 Vicente J. Botet Escriba
+ * 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/luid for library home page.
+ */
+
+#ifndef BOOST_LUID_TEST_TEST_HPP_
+#define BOOST_LUID_TEST_TEST_HPP_
+
+#include <boost/test/unit_test.hpp>
+#include <boost/luid/generator.hpp>
+#include <set>
+
+using namespace boost;
+using namespace boost::mpl;
+namespace bip =boost::interprocess;
+namespace bdsl =boost::dsl;
+
+namespace bluid = boost::luid;
+
+template <typename G>
+void test_inmediate(G& g) {
+ typename G::numeric_type id1= g.make();
+ g.release(id1);
+ typename G::numeric_type id2= g.make();
+ BOOST_CHECK(id1==id2);
+ g.clear();
+}
+
+template <typename G>
+void test_fifo(G& g) {
+ typename G::numeric_type id1= g.make();
+ typename G::numeric_type id2= g.make();
+ typename G::numeric_type id3= g.make();
+ g.release(id2);
+ g.release(id3);
+ g.release(id1);
+ typename G::numeric_type id4= g.make();
+ BOOST_CHECK(id4==id2);
+ typename G::numeric_type id5= g.make();
+ BOOST_CHECK(id5==id3);
+ typename G::numeric_type id6= g.make();
+ BOOST_CHECK(id6==id1);
+ g.clear();
+}
+
+template <typename G>
+void test_resize(G& g, unsigned int d, unsigned int u) {
+ typename G::numeric_type i;
+ for (i =g.lower_bound(); i<d; ++i) {
+ BOOST_CHECK(g.make()!=g.error());
+ }
+ std::cout << "test_resize # " << d << std::endl;
+ g.set_upper_bound(u);
+ std::cout << "test_resize # " << g.upper_bound() << std::endl;
+ for (;i<g.upper_bound(); ++i) {
+ BOOST_CHECK(g.make()!=g.error());
+ }
+ std::cout << "test_resize # " << u << std::endl;
+// BOOST_CHECK(g.make()==g.error());
+ g.clear();
+}
+
+template <typename G, typename D>
+void test_delay(G& g, D d) {
+// std::cout << "T." <<++i<< " test_delay " << std::endl;
+ typename G::numeric_type id1= g.make();
+ g.release(id1);
+// std::cout << "test_delay # " << g.count() << std::endl;
+ typename G::numeric_type id2= g.make();
+ BOOST_CHECK(id1!=id2);
+// thread::sleep(boost::posix_time::second_clock::local_time()+posix_time::time_duration(0,0,d,0));
+ sleep(d);
+ typename G::numeric_type id3= g.make();
+ BOOST_CHECK(id1==id3);
+// std::cout << "test_delay # " << g.count() << std::endl;
+ g.clear();
+// g.release(id2);
+// g.release(id3);
+}
+
+template <typename G>
+void test_unique(G& g) {
+// std::cout << "T." <<++i<< " test_unique " << std::endl;
+
+// typedef std::set<> used_type;
+ typedef std::set<typename G::numeric_type> used_type;
+ used_type used;
+ typename G::numeric_type id;
+ for (typename G::numeric_type i =g.lower_bound(); i<g.upper_bound(); ++i) {
+ id=g.make();
+ if(id==g.error()) {
+ std::cout << "FAIL " << __LINE__ << std::endl;
+ BOOST_FAIL("unique");
+ }
+// std::cout << "SUCCEED " << id << std::endl;
+ BOOST_CHECK(used.count(id)==0);
+ used.insert(id);
+ }
+// std::cout << "inserted test_unique " << std::endl;
+// for (typename used_type::iterator it2=used.begin(), e=used.upper_bound()
+// ; it2!=e
+// ; ++it2) {
+// g.release(*it2);
+// }
+// std::cout << "END test_unique " << std::endl;
+ g.clear();
+}
+
+template <typename G>
+void test_overflow(G& g) {
+// std::cout << "T." <<++i<< " test_overflow " << std::endl;
+ typename G::numeric_type i;
+ typename G::numeric_type id;
+// std::cout << "make test_overflow " << int(g.upper_bound()) << std::endl;
+ for (i =g.lower_bound(); i<g.upper_bound(); ++i) {
+ id =g.make();
+ if(id==g.error()) {
+ std::cout << "FAIL " << __LINE__ << std::endl;
+ BOOST_FAIL("overflow");
+ }
+// std::cout << "SUCCED " << __LINE__ << std::endl;
+
+ }
+// std::cout << "check test_overflow " << std::endl;
+ for (i =0; i<10; ++i) {
+ BOOST_CHECK(g.make()==g.error());
+ }
+// std::cout << "end test_overflow " << std::endl;
+ g.clear();
+}
+
+template <typename G>
+void test_discard(G& g) {
+// std::cout << "T." <<++i<< " test_overflow " << std::endl;
+ typename G::numeric_type i;
+ typename G::numeric_type id;
+// std::cout << "make test_overflow " << int(g.upper_bound()) << std::endl;
+ for (i =g.lower_bound(); i<g.upper_bound(); ++i) {
+ id =g.make();
+ if(id==g.error()) {
+ std::cout << "FAIL " << __LINE__ << std::endl;
+ BOOST_FAIL("overflow");
+ }
+// std::cout << "SUCCED " << __LINE__ << std::endl;
+
+ }
+ g.release(id);
+
+ typename G::numeric_type id2= g.make();
+ BOOST_CHECK(id2==g.error());
+
+ g.clear();
+}
+
+
+template <typename G>
+void test_overflow_throw(G& g) {
+// std::cout << "T." <<++i<< " test_overflow_throw " << std::endl;
+ typename G::numeric_type i;
+ for (i =g.lower_bound(); i<g.upper_bound(); ++i) {
+ g.make();
+ }
+ for (i =0; i<10; ++i) {
+ try {
+ (void)g.make();
+ BOOST_CHECK(false);
+ } catch(...) {
+ }
+ }
+}
+
+template <typename G>
+void test_check(G& g) {
+// std::cout << "T." <<++i<< " test_check " << std::endl;
+ typename G::numeric_type id1= g.make();
+ g.release(id1);
+// std::cout << "test_check2 " << std::endl;
+
+ try {
+ g.release(id1);
+ BOOST_CHECK(false);
+ } catch(...) {
+ }
+// std::cout << "test_check # " << g.count() << std::endl;
+
+ g.clear();
+}
+
+#endif

Added: sandbox/synchro/libs/synchro/test/unit_test.hpp
==============================================================================
--- (empty file)
+++ sandbox/synchro/libs/synchro/test/unit_test.hpp 2009-02-19 18:46:04 EST (Thu, 19 Feb 2009)
@@ -0,0 +1,23 @@
+//
+// unit_test.hpp
+// ~~~~~~~~~~~~~
+//
+// Copyright (c) 2003-2008 Christopher M. Kohlhoff (chris at kohlhoff dot com)
+//
+// 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)
+//
+
+#ifndef UNIT_TEST_HPP
+#define UNIT_TEST_HPP
+
+
+#include <boost/test/unit_test.hpp>
+#include <boost/test/included/unit_test_framework.hpp>
+using boost::unit_test::test_suite;
+
+inline void null_test()
+{
+}
+
+#endif // UNIT_TEST_HPP


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