Boost logo

Boost-Commit :

From: anthony_at_[hidden]
Date: 2008-05-21 09:38:04


Author: anthonyw
Date: 2008-05-21 09:38:04 EDT (Wed, 21 May 2008)
New Revision: 45607
URL: http://svn.boost.org/trac/boost/changeset/45607

Log:
New tests for a normal function with one argument, and a member function with 0 or 1 arguments
Text files modified:
   trunk/libs/thread/test/test_thread_launching.cpp | 60 +++++++++++++++++++++++++++++++++++++++
   1 files changed, 59 insertions(+), 1 deletions(-)

Modified: trunk/libs/thread/test/test_thread_launching.cpp
==============================================================================
--- trunk/libs/thread/test/test_thread_launching.cpp (original)
+++ trunk/libs/thread/test/test_thread_launching.cpp 2008-05-21 09:38:04 EDT (Wed, 21 May 2008)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 Anthony Williams
+// Copyright (C) 2007-8 Anthony Williams
 //
 // 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)
@@ -23,6 +23,20 @@
     BOOST_CHECK(normal_function_called);
 }
 
+int nfoa_res=0;
+
+void normal_function_one_arg(int i)
+{
+ nfoa_res=i;
+}
+
+void test_thread_function_one_argument()
+{
+ boost::thread function(normal_function_one_arg,42);
+ function.join();
+ BOOST_CHECK_EQUAL(42,nfoa_res);
+}
+
 struct callable_no_args
 {
     static bool called;
@@ -150,6 +164,47 @@
     BOOST_CHECK_EQUAL(callable_multiple_arg::called_two_arg2,dbl);
 }
 
+struct X
+{
+ bool function_called;
+ int arg_value;
+
+ X():
+ function_called(false),
+ arg_value(0)
+ {}
+
+
+ void f0()
+ {
+ function_called=true;
+ }
+
+ void f1(int i)
+ {
+ arg_value=i;
+ }
+
+};
+
+void test_thread_member_function_no_arguments()
+{
+ X x;
+
+ boost::thread function(&X::f0,&x);
+ function.join();
+ BOOST_CHECK(x.function_called);
+}
+
+
+void test_thread_member_function_one_argument()
+{
+ X x;
+ boost::thread function(&X::f1,&x,42);
+ function.join();
+ BOOST_CHECK_EQUAL(42,x.arg_value);
+}
+
 
 boost::unit_test_framework::test_suite* init_unit_test_suite(int, char*[])
 {
@@ -157,9 +212,12 @@
         BOOST_TEST_SUITE("Boost.Threads: thread launching test suite");
 
     test->add(BOOST_TEST_CASE(test_thread_function_no_arguments));
+ test->add(BOOST_TEST_CASE(test_thread_function_one_argument));
     test->add(BOOST_TEST_CASE(test_thread_callable_object_no_arguments));
     test->add(BOOST_TEST_CASE(test_thread_callable_object_ref_no_arguments));
     test->add(BOOST_TEST_CASE(test_thread_callable_object_one_argument));
     test->add(BOOST_TEST_CASE(test_thread_callable_object_multiple_arguments));
+ test->add(BOOST_TEST_CASE(test_thread_member_function_no_arguments));
+ test->add(BOOST_TEST_CASE(test_thread_member_function_one_argument));
     return test;
 }


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