|
Boost-Commit : |
From: anthony_at_[hidden]
Date: 2008-05-26 04:40:13
Author: anthonyw
Date: 2008-05-26 04:40:13 EDT (Mon, 26 May 2008)
New Revision: 45765
URL: http://svn.boost.org/trac/boost/changeset/45765
Log:
Initial test for generic lock functions
Added:
trunk/libs/thread/test/test_generic_locks.cpp (contents, props changed)
Added: trunk/libs/thread/test/test_generic_locks.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/thread/test/test_generic_locks.cpp 2008-05-26 04:40:13 EDT (Mon, 26 May 2008)
@@ -0,0 +1,36 @@
+// (C) Copyright 2008 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)
+
+#include <boost/test/unit_test.hpp>
+#include <boost/test/test_case_template.hpp>
+#include <boost/thread/mutex.hpp>
+#include <boost/thread/thread.hpp>
+#include <boost/thread/locks.hpp>
+
+void test_lock_two_uncontended()
+{
+ boost::mutex m1,m2;
+
+ boost::mutex::scoped_lock l1(m1,boost::defer_lock),
+ l2(m2,boost::defer_lock);
+
+ BOOST_CHECK(!l1.owns_lock());
+ BOOST_CHECK(!l2.owns_lock());
+
+ boost::lock(l1,l2);
+
+ BOOST_CHECK(l1.owns_lock());
+ BOOST_CHECK(l2.owns_lock());
+}
+
+boost::unit_test_framework::test_suite* init_unit_test_suite(int, char*[])
+{
+ boost::unit_test_framework::test_suite* test =
+ BOOST_TEST_SUITE("Boost.Threads: generic locks test suite");
+
+ test->add(BOOST_TEST_CASE(&test_lock_two_uncontended));
+
+ 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