Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r83262 - trunk/libs/thread/test/sync/mutual_exclusion/synchronized_value
From: vicente.botet_at_[hidden]
Date: 2013-03-03 05:22:37


Author: viboes
Date: 2013-03-03 05:22:35 EST (Sun, 03 Mar 2013)
New Revision: 83262
URL: http://svn.boost.org/trac/boost/changeset/83262

Log:
Thread: Added some synchronized_value tests
Added:
   trunk/libs/thread/test/sync/mutual_exclusion/synchronized_value/copy_T_assign_pass.cpp (contents, props changed)
   trunk/libs/thread/test/sync/mutual_exclusion/synchronized_value/copy_T_ctor_pass.cpp (contents, props changed)
   trunk/libs/thread/test/sync/mutual_exclusion/synchronized_value/copy_assign_pass.cpp (contents, props changed)
   trunk/libs/thread/test/sync/mutual_exclusion/synchronized_value/copy_ctor_pass.cpp (contents, props changed)
   trunk/libs/thread/test/sync/mutual_exclusion/synchronized_value/default_ctor_pass.cpp (contents, props changed)
   trunk/libs/thread/test/sync/mutual_exclusion/synchronized_value/indirect_pass.cpp (contents, props changed)
   trunk/libs/thread/test/sync/mutual_exclusion/synchronized_value/move_T_assign_pass.cpp (contents, props changed)
   trunk/libs/thread/test/sync/mutual_exclusion/synchronized_value/move_T_ctor_pass.cpp (contents, props changed)
   trunk/libs/thread/test/sync/mutual_exclusion/synchronized_value/move_assign_pass.cpp (contents, props changed)
   trunk/libs/thread/test/sync/mutual_exclusion/synchronized_value/move_ctor_pass.cpp (contents, props changed)
   trunk/libs/thread/test/sync/mutual_exclusion/synchronized_value/swap_T_pass.cpp (contents, props changed)
   trunk/libs/thread/test/sync/mutual_exclusion/synchronized_value/swap_pass.cpp (contents, props changed)
   trunk/libs/thread/test/sync/mutual_exclusion/synchronized_value/synchronize_pass.cpp (contents, props changed)

Added: trunk/libs/thread/test/sync/mutual_exclusion/synchronized_value/copy_T_assign_pass.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/thread/test/sync/mutual_exclusion/synchronized_value/copy_T_assign_pass.cpp 2013-03-03 05:22:35 EST (Sun, 03 Mar 2013)
@@ -0,0 +1,30 @@
+// Copyright (C) 2013 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)
+
+// <boost/thread/synchronized_value.hpp>
+
+// class synchronized_value<T,M>
+
+// synchronized_value& operator=(T const&);
+
+#define BOOST_THREAD_VERSION 4
+
+#include <boost/thread/synchronized_value.hpp>
+
+#include <boost/detail/lightweight_test.hpp>
+
+int main()
+{
+
+ {
+ int i = 1;
+ boost::synchronized_value<int> v;
+ v = i;
+ BOOST_TEST(v.value() == 1);
+ }
+
+ return boost::report_errors();
+}
+

Added: trunk/libs/thread/test/sync/mutual_exclusion/synchronized_value/copy_T_ctor_pass.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/thread/test/sync/mutual_exclusion/synchronized_value/copy_T_ctor_pass.cpp 2013-03-03 05:22:35 EST (Sun, 03 Mar 2013)
@@ -0,0 +1,29 @@
+// Copyright (C) 2013 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)
+
+// <boost/thread/synchronized_value.hpp>
+
+// class synchronized_value<T,M>
+
+// synchronized_value(T const&);
+
+#define BOOST_THREAD_VERSION 4
+
+#include <boost/thread/synchronized_value.hpp>
+
+#include <boost/detail/lightweight_test.hpp>
+
+int main()
+{
+
+ {
+ int i = 1;
+ boost::synchronized_value<int> v(i);
+ BOOST_TEST(v.value() == 1);
+ }
+
+ return boost::report_errors();
+}
+

Added: trunk/libs/thread/test/sync/mutual_exclusion/synchronized_value/copy_assign_pass.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/thread/test/sync/mutual_exclusion/synchronized_value/copy_assign_pass.cpp 2013-03-03 05:22:35 EST (Sun, 03 Mar 2013)
@@ -0,0 +1,31 @@
+// Copyright (C) 2013 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)
+
+// <boost/thread/synchronized_value.hpp>
+
+// class synchronized_value<T,M>
+
+// synchronized_value& operator=(synchronized_value const&);
+
+#define BOOST_THREAD_VERSION 4
+
+#include <boost/thread/synchronized_value.hpp>
+
+#include <boost/detail/lightweight_test.hpp>
+
+int main()
+{
+
+ {
+ int i = 1;
+ boost::synchronized_value<int> v1(i);
+ boost::synchronized_value<int> v2;
+ v2 = v1;
+ BOOST_TEST(v2.value() == 1);
+ }
+
+ return boost::report_errors();
+}
+

Added: trunk/libs/thread/test/sync/mutual_exclusion/synchronized_value/copy_ctor_pass.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/thread/test/sync/mutual_exclusion/synchronized_value/copy_ctor_pass.cpp 2013-03-03 05:22:35 EST (Sun, 03 Mar 2013)
@@ -0,0 +1,30 @@
+// Copyright (C) 2013 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)
+
+// <boost/thread/synchronized_value.hpp>
+
+// class synchronized_value<T,M>
+
+// synchronized_value(synchronized_value const&);
+
+#define BOOST_THREAD_VERSION 4
+
+#include <boost/thread/synchronized_value.hpp>
+
+#include <boost/detail/lightweight_test.hpp>
+
+int main()
+{
+
+ {
+ int i = 1;
+ boost::synchronized_value<int> v1(i);
+ boost::synchronized_value<int> v2(v1);
+ BOOST_TEST(v2.value() == 1);
+ }
+
+ return boost::report_errors();
+}
+

Added: trunk/libs/thread/test/sync/mutual_exclusion/synchronized_value/default_ctor_pass.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/thread/test/sync/mutual_exclusion/synchronized_value/default_ctor_pass.cpp 2013-03-03 05:22:35 EST (Sun, 03 Mar 2013)
@@ -0,0 +1,33 @@
+// Copyright (C) 2013 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)
+
+// <boost/thread/synchronized_value.hpp>
+
+// class synchronized_value<T,M>
+
+// synchronized_value();
+
+#define BOOST_THREAD_VERSION 4
+
+#include <boost/thread/synchronized_value.hpp>
+#include <boost/thread/testable_mutex.hpp>
+
+#include <boost/detail/lightweight_test.hpp>
+
+int main()
+{
+
+ {
+ boost::synchronized_value<int, boost::testable_mutex<boost::mutex> > f;
+ BOOST_TEST(! f.mutex().is_locked());
+ }
+ {
+ boost::synchronized_value<int, boost::testable_mutex<boost::timed_mutex> > f;
+ BOOST_TEST(! f.mutex().is_locked());
+ }
+
+ return boost::report_errors();
+}
+

Added: trunk/libs/thread/test/sync/mutual_exclusion/synchronized_value/indirect_pass.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/thread/test/sync/mutual_exclusion/synchronized_value/indirect_pass.cpp 2013-03-03 05:22:35 EST (Sun, 03 Mar 2013)
@@ -0,0 +1,38 @@
+// Copyright (C) 2013 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)
+
+// <boost/thread/synchronized_value.hpp>
+
+// class synchronized_value<T,M>
+
+// strict_lock_ptr<T,M> operator->();
+// const_strict_lock_ptr<T,M> operator->() const;
+
+#define BOOST_THREAD_VERSION 4
+
+#include <boost/thread/synchronized_value.hpp>
+
+#include <boost/detail/lightweight_test.hpp>
+
+struct S {
+ int f() const {return 1;}
+ int g() {return 1;}
+};
+
+int main()
+{
+ {
+ boost::synchronized_value<S> v;
+ BOOST_TEST(v->f()==1);
+ BOOST_TEST(v->g()==1);
+ }
+ {
+ const boost::synchronized_value<S> v;
+ BOOST_TEST(v->f()==1);
+ }
+
+ return boost::report_errors();
+}
+

Added: trunk/libs/thread/test/sync/mutual_exclusion/synchronized_value/move_T_assign_pass.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/thread/test/sync/mutual_exclusion/synchronized_value/move_T_assign_pass.cpp 2013-03-03 05:22:35 EST (Sun, 03 Mar 2013)
@@ -0,0 +1,29 @@
+// Copyright (C) 2013 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)
+
+// <boost/thread/synchronized_value.hpp>
+
+// class synchronized_value<T,M>
+
+// synchronized_value& operator=(T &&);
+
+#define BOOST_THREAD_VERSION 4
+
+#include <boost/thread/synchronized_value.hpp>
+
+#include <boost/detail/lightweight_test.hpp>
+
+int main()
+{
+
+ {
+ boost::synchronized_value<int> v;
+ v = 1;
+ BOOST_TEST(v.value() == 1);
+ }
+
+ return boost::report_errors();
+}
+

Added: trunk/libs/thread/test/sync/mutual_exclusion/synchronized_value/move_T_ctor_pass.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/thread/test/sync/mutual_exclusion/synchronized_value/move_T_ctor_pass.cpp 2013-03-03 05:22:35 EST (Sun, 03 Mar 2013)
@@ -0,0 +1,28 @@
+// Copyright (C) 2013 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)
+
+// <boost/thread/synchronized_value.hpp>
+
+// class synchronized_value<T,M>
+
+// synchronized_value(T &&);
+
+#define BOOST_THREAD_VERSION 4
+
+#include <boost/thread/synchronized_value.hpp>
+
+#include <boost/detail/lightweight_test.hpp>
+
+int main()
+{
+
+ {
+ boost::synchronized_value<int> v(1);
+ BOOST_TEST(v.value() == 1);
+ }
+
+ return boost::report_errors();
+}
+

Added: trunk/libs/thread/test/sync/mutual_exclusion/synchronized_value/move_assign_pass.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/thread/test/sync/mutual_exclusion/synchronized_value/move_assign_pass.cpp 2013-03-03 05:22:35 EST (Sun, 03 Mar 2013)
@@ -0,0 +1,30 @@
+// Copyright (C) 2013 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)
+
+// <boost/thread/synchronized_value.hpp>
+
+// class synchronized_value<T,M>
+
+// synchronized_value& operator=(synchronized_value &&);
+
+#define BOOST_THREAD_VERSION 4
+
+#include <boost/thread/synchronized_value.hpp>
+
+#include <boost/detail/lightweight_test.hpp>
+
+int main()
+{
+
+ {
+ boost::synchronized_value<int> v1(1);
+ boost::synchronized_value<int> v2;
+ v2 = boost::move(v1);
+ BOOST_TEST(v2.value() == 1);
+ }
+
+ return boost::report_errors();
+}
+

Added: trunk/libs/thread/test/sync/mutual_exclusion/synchronized_value/move_ctor_pass.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/thread/test/sync/mutual_exclusion/synchronized_value/move_ctor_pass.cpp 2013-03-03 05:22:35 EST (Sun, 03 Mar 2013)
@@ -0,0 +1,29 @@
+// Copyright (C) 2013 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)
+
+// <boost/thread/synchronized_value.hpp>
+
+// class synchronized_value<T,M>
+
+// synchronized_value(synchronized_value &&);
+
+#define BOOST_THREAD_VERSION 4
+
+#include <boost/thread/synchronized_value.hpp>
+
+#include <boost/detail/lightweight_test.hpp>
+
+int main()
+{
+
+ {
+ boost::synchronized_value<int> v1(1);
+ boost::synchronized_value<int> v2(boost::move(v1));
+ BOOST_TEST(v2.value() == 1);
+ }
+
+ return boost::report_errors();
+}
+

Added: trunk/libs/thread/test/sync/mutual_exclusion/synchronized_value/swap_T_pass.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/thread/test/sync/mutual_exclusion/synchronized_value/swap_T_pass.cpp 2013-03-03 05:22:35 EST (Sun, 03 Mar 2013)
@@ -0,0 +1,38 @@
+// Copyright (C) 2013 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)
+
+// <boost/thread/synchronized_value.hpp>
+
+// class synchronized_value<T,M>
+
+// void swap(synchronized_value&,synchronized_value&);
+
+#define BOOST_THREAD_VERSION 4
+
+#include <boost/thread/synchronized_value.hpp>
+
+#include <boost/detail/lightweight_test.hpp>
+
+int main()
+{
+
+ {
+ boost::synchronized_value<int> v1(1);
+ int v2(2);
+ boost::swap(v1,v2);
+ BOOST_TEST(v1.value() == 2);
+ BOOST_TEST(v2 == 1);
+ }
+ {
+ boost::synchronized_value<int> v1(1);
+ int v2(2);
+ boost::swap(v2,v1);
+ BOOST_TEST(v1.value() == 2);
+ BOOST_TEST(v2 == 1);
+ }
+
+ return boost::report_errors();
+}
+

Added: trunk/libs/thread/test/sync/mutual_exclusion/synchronized_value/swap_pass.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/thread/test/sync/mutual_exclusion/synchronized_value/swap_pass.cpp 2013-03-03 05:22:35 EST (Sun, 03 Mar 2013)
@@ -0,0 +1,31 @@
+// Copyright (C) 2013 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)
+
+// <boost/thread/synchronized_value.hpp>
+
+// class synchronized_value<T,M>
+
+// void swap(synchronized_value&,synchronized_value&);
+
+#define BOOST_THREAD_VERSION 4
+
+#include <boost/thread/synchronized_value.hpp>
+
+#include <boost/detail/lightweight_test.hpp>
+
+int main()
+{
+
+ {
+ boost::synchronized_value<int> v1(1);
+ boost::synchronized_value<int> v2(2);
+ swap(v1,v2);
+ BOOST_TEST(v1.value() == 2);
+ BOOST_TEST(v2.value() == 1);
+ }
+
+ return boost::report_errors();
+}
+

Added: trunk/libs/thread/test/sync/mutual_exclusion/synchronized_value/synchronize_pass.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/thread/test/sync/mutual_exclusion/synchronized_value/synchronize_pass.cpp 2013-03-03 05:22:35 EST (Sun, 03 Mar 2013)
@@ -0,0 +1,41 @@
+// Copyright (C) 2013 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)
+
+// <boost/thread/synchronized_value.hpp>
+
+// class synchronized_value<T,M>
+
+// strict_lock_ptr<T,M> synchronize();
+// const_strict_lock_ptr<T,M> synchronize() const;
+
+
+#define BOOST_THREAD_VERSION 4
+
+#include <boost/thread/synchronized_value.hpp>
+
+#include <boost/detail/lightweight_test.hpp>
+
+struct S {
+ int f() const {return 1;}
+ int g() {return 1;}
+};
+
+int main()
+{
+ {
+ boost::synchronized_value<S> v;
+ boost::strict_lock_ptr<S> ptr = v.synchronize();
+ BOOST_TEST(ptr->f()==1);
+ BOOST_TEST(ptr->g()==1);
+ }
+ {
+ const boost::synchronized_value<S> v;
+ boost::const_strict_lock_ptr<S> ptr = v.synchronize();
+ BOOST_TEST(ptr->f()==1);
+ }
+
+ 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