|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r77658 - in trunk/libs/thread/test: . sync/mutual_exclusion/locks/unique_lock/obs
From: vicente.botet_at_[hidden]
Date: 2012-03-31 02:52:57
Author: viboes
Date: 2012-03-31 02:52:55 EDT (Sat, 31 Mar 2012)
New Revision: 77658
URL: http://svn.boost.org/trac/boost/changeset/77658
Log:
Thread: Added explicit int conversion from lock should fail
Added:
trunk/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/obs/op_int_fail.cpp (contents, props changed)
Text files modified:
trunk/libs/thread/test/Jamfile.v2 | 1 +
trunk/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/obs/op_bool_pass.cpp | 22 ++++++++++++++++------
2 files changed, 17 insertions(+), 6 deletions(-)
Modified: trunk/libs/thread/test/Jamfile.v2
==============================================================================
--- trunk/libs/thread/test/Jamfile.v2 (original)
+++ trunk/libs/thread/test/Jamfile.v2 2012-03-31 02:52:55 EDT (Sat, 31 Mar 2012)
@@ -214,6 +214,7 @@
[ thread-run2 ./sync/mutual_exclusion/locks/unique_lock/mod/release_pass.cpp : unique_lock__release_p ]
[ thread-run2 ./sync/mutual_exclusion/locks/unique_lock/obs/mutex_pass.cpp : unique_lock__mutex_p ]
[ thread-run2 ./sync/mutual_exclusion/locks/unique_lock/obs/op_bool_pass.cpp : unique_lock__op_bool_p ]
+ [ thread-compile-fail-V2 ./sync/mutual_exclusion/locks/unique_lock/obs/op_int_fail.cpp : : unique_lock__op_int_f ]
[ thread-run2 ./sync/mutual_exclusion/locks/unique_lock/obs/owns_lock_pass.cpp : unique_lock__owns_lock_p ]
[ thread-run2 ./sync/mutual_exclusion/locks/unique_lock/types_pass.cpp : unique_lock__types_p ]
Modified: trunk/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/obs/op_bool_pass.cpp
==============================================================================
--- trunk/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/obs/op_bool_pass.cpp (original)
+++ trunk/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/obs/op_bool_pass.cpp 2012-03-31 02:52:55 EDT (Sat, 31 Mar 2012)
@@ -26,13 +26,23 @@
int main()
{
- boost::unique_lock < boost::mutex > lk0;
- BOOST_TEST(bool(lk0) == false);
- boost::unique_lock < boost::mutex > lk1(m);
- BOOST_TEST(bool(lk1) == true);
- lk1.unlock();
- BOOST_TEST(bool(lk1) == false);
+ {
+ boost::unique_lock<boost::mutex> lk0;
+ BOOST_TEST(bool(lk0) == false);
+ boost::unique_lock<boost::mutex> lk1(m);
+ BOOST_TEST(bool(lk1) == true);
+ lk1.unlock();
+ BOOST_TEST(bool(lk1) == false);
+ }
+ {
+ boost::unique_lock<boost::mutex> lk0;
+ if (lk0) BOOST_TEST(false);
+ boost::unique_lock<boost::mutex> lk1(m);
+ if (!lk1) BOOST_TEST(false);
+ lk1.unlock();
+ if (lk1) BOOST_TEST(false);
+ }
return boost::report_errors();
}
Added: trunk/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/obs/op_int_fail.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/obs/op_int_fail.cpp 2012-03-31 02:52:55 EDT (Sat, 31 Mar 2012)
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// 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/locks.hpp>
+
+// template <class Mutex> class unique_lock;
+
+// explicit operator bool() const;
+
+#include <boost/thread/locks.hpp>
+#include <boost/thread/mutex.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+boost::mutex m;
+
+int main()
+{
+ {
+ boost::unique_lock<boost::mutex> lk0;
+ int i = int(lk0);
+ BOOST_TEST(i == 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