Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r77686 - in trunk/libs/thread/test: . threads/thread/constr
From: vicente.botet_at_[hidden]
Date: 2012-04-01 11:48:56


Author: viboes
Date: 2012-04-01 11:48:56 EDT (Sun, 01 Apr 2012)
New Revision: 77686
URL: http://svn.boost.org/trac/boost/changeset/77686

Log:
Thread: Split test with and wothout args
Added:
   trunk/libs/thread/test/threads/thread/constr/FArgs_pass.cpp (contents, props changed)
Text files modified:
   trunk/libs/thread/test/Jamfile.v2 | 3 +--
   trunk/libs/thread/test/threads/thread/constr/F_pass.cpp | 20 +-------------------
   2 files changed, 2 insertions(+), 21 deletions(-)

Modified: trunk/libs/thread/test/Jamfile.v2
==============================================================================
--- trunk/libs/thread/test/Jamfile.v2 (original)
+++ trunk/libs/thread/test/Jamfile.v2 2012-04-01 11:48:56 EDT (Sun, 01 Apr 2012)
@@ -191,7 +191,6 @@
     #explicit mutual_exclusion ;
     test-suite mutual_exclusion
     :
- #uncomment the following once these works on windows
           [ thread-compile-fail-V2 ./sync/mutual_exclusion/locks/lock_guard/copy_assign_fail.cpp : : lock_guard__cons__copy_assign_f ]
           [ thread-compile-fail-V2 ./sync/mutual_exclusion/locks/lock_guard/copy_ctor_fail.cpp : : lock_guard__cons__copy_ctor_f ]
           [ thread-run2 ./sync/mutual_exclusion/locks/lock_guard/adopt_lock_pass.cpp : lock_guard__cons__adopt_lock_p ]
@@ -207,7 +206,6 @@
           [ thread-run2 ./sync/mutual_exclusion/locks/unique_lock/cons/move_assign_pass.cpp : unique_lock__cons__move_assign_p ]
           [ thread-run2 ./sync/mutual_exclusion/locks/unique_lock/cons/move_ctor_pass.cpp : unique_lock__cons__move_ctor_p ]
 
- #uncomment the following once these works on windows
           [ thread-run2 ./sync/mutual_exclusion/locks/unique_lock/cons/move_ctor_upgrade_lock_pass.cpp : unique_lock__cons__move_ctor_upgrade_lock_p ]
           [ thread-run2 ./sync/mutual_exclusion/locks/unique_lock/cons/move_ctor_upgrade_lock_try_pass.cpp : unique_lock__cons__move_ctor_upgrade_lock_try_p ]
           [ thread-run2 ./sync/mutual_exclusion/locks/unique_lock/cons/move_ctor_upgrade_lock_for_pass.cpp : unique_lock__cons__move_ctor_upgrade_lock_for_p ]
@@ -340,6 +338,7 @@
           [ thread-compile-fail-V2 ./threads/thread/constr/copy_fail.cpp : : thread__constr__copy_f ]
           [ thread-run2 ./threads/thread/constr/default_pass.cpp : thread__constr__default_p ]
           [ thread-run-lib2 ./threads/thread/constr/F_pass.cpp : thread__constr__F_p ]
+ [ thread-run-lib2 ./threads/thread/constr/FArgs_pass.cpp : thread__constr__FArgs_p ]
           [ thread-run2 ./threads/thread/constr/Frvalue_pass.cpp : thread__constr__Frvalue_p ]
           #[ thread-run2 ./threads/thread/constr/FrvalueArgs_pass.cpp : thread__constr__FrvalueArgs_p ]
           [ thread-run2 ./threads/thread/constr/move_pass.cpp : thread__constr__move_p ]

Added: trunk/libs/thread/test/threads/thread/constr/FArgs_pass.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/thread/test/threads/thread/constr/FArgs_pass.cpp 2012-04-01 11:48:56 EDT (Sun, 01 Apr 2012)
@@ -0,0 +1,123 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// Copyright (C) 2011 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/thread.hpp>
+
+// class thread
+
+// template <class F, class ...Args> thread(F f, Args... args);
+
+#include <new>
+#include <cstdlib>
+#include <cassert>
+#include <boost/thread/thread.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+unsigned throw_one = 0xFFFF;
+
+void* operator new(std::size_t s) throw (std::bad_alloc)
+{
+ std::cout << __FILE__ << ":" << __LINE__ << std::endl;
+ if (throw_one == 0) throw std::bad_alloc();
+ --throw_one;
+ return std::malloc(s);
+}
+
+void operator delete(void* p) throw ()
+{
+ std::cout << __FILE__ << ":" << __LINE__ << std::endl;
+ std::free(p);
+}
+
+bool f_run = false;
+
+void f(int i, double j)
+{
+ BOOST_TEST(i == 5);
+ BOOST_TEST(j == 5.5);
+ f_run = true;
+}
+
+class G
+{
+ int alive_;
+public:
+ static int n_alive;
+ static bool op_run;
+
+ G() :
+ alive_(1)
+ {
+ ++n_alive;
+ }
+ G(const G& g) :
+ alive_(g.alive_)
+ {
+ ++n_alive;
+ }
+ ~G()
+ {
+ alive_ = 0;
+ --n_alive;
+ }
+
+ void operator()(int i, double j)
+ {
+ BOOST_TEST(alive_ == 1);
+ BOOST_TEST(n_alive >= 1);
+ BOOST_TEST(i == 5);
+ BOOST_TEST(j == 5.5);
+ op_run = true;
+ }
+};
+
+int G::n_alive = 0;
+bool G::op_run = false;
+
+
+int main()
+{
+ {
+ boost::thread t(f, 5, 5.5);
+ t.join();
+ BOOST_TEST(f_run == true);
+ }
+#ifndef BOOST_MSVC
+ f_run = false;
+ {
+ try
+ {
+ throw_one = 0;
+ boost::thread t(f, 5, 5.5);
+ BOOST_TEST(false);
+ }
+ catch (...)
+ {
+ throw_one = 0xFFFF;
+ BOOST_TEST(!f_run);
+ }
+ }
+#endif
+ {
+ BOOST_TEST(G::n_alive == 0);
+ std::cout << __FILE__ << ":" << __LINE__ <<" " << G::n_alive << std::endl;
+ BOOST_TEST(!G::op_run);
+ boost::thread t(G(), 5, 5.5);
+ t.join();
+ std::cout << __FILE__ << ":" << __LINE__ <<" " << G::n_alive << std::endl;
+ BOOST_TEST(G::n_alive == 0);
+ BOOST_TEST(G::op_run);
+ }
+
+ return boost::report_errors();
+}

Modified: trunk/libs/thread/test/threads/thread/constr/F_pass.cpp
==============================================================================
--- trunk/libs/thread/test/threads/thread/constr/F_pass.cpp (original)
+++ trunk/libs/thread/test/threads/thread/constr/F_pass.cpp 2012-04-01 11:48:56 EDT (Sun, 01 Apr 2012)
@@ -76,14 +76,6 @@
     op_run = true;
   }
 
- void operator()(int i, double j)
- {
- BOOST_TEST(alive_ == 1);
- BOOST_TEST(n_alive >= 1);
- BOOST_TEST(i == 5);
- BOOST_TEST(j == 5.5);
- op_run = true;
- }
 };
 
 int G::n_alive = 0;
@@ -121,8 +113,8 @@
     BOOST_TEST(G::n_alive == 0);
     BOOST_TEST(G::op_run);
   }
- G::op_run = false;
 #ifndef BOOST_MSVC
+ G::op_run = false;
   {
     try
     {
@@ -141,16 +133,6 @@
     }
   }
 #endif
- {
- BOOST_TEST(G::n_alive == 0);
- std::cout << __FILE__ << ":" << __LINE__ <<" " << G::n_alive << std::endl;
- BOOST_TEST(!G::op_run);
- boost::thread t(G(), 5, 5.5);
- t.join();
- std::cout << __FILE__ << ":" << __LINE__ <<" " << G::n_alive << std::endl;
- BOOST_TEST(G::n_alive == 0);
- BOOST_TEST(G::op_run);
- }
 
   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