Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_34_1/libs/spirit/test/scoped_lock_tests.cpp @ 33

Last change on this file since 33 was 29, checked in by landauf, 16 years ago

updated boost from 1_33_1 to 1_34_1

File size: 1.6 KB
Line 
1/*=============================================================================
2    Copyright (C) 2003 Martin Wille
3    http://spirit.sourceforge.net/
4
5    Use, modification and distribution is subject to the Boost Software
6    License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
7    http://www.boost.org/LICENSE_1_0.txt)
8=============================================================================*/
9
10// Nota bene: the actual locking is _not_ tested here!
11
12#include <iostream>
13#include <boost/config.hpp>
14
15void banner()
16{
17    std::cout << "/////////////////////////////////////////////////////////\n";
18    std::cout << "\n";
19    std::cout << "          scoped_lock test\n";
20    std::cout << "\n";
21    std::cout << "/////////////////////////////////////////////////////////\n";
22    std::cout << "\n";
23}
24
25#if defined(DONT_HAVE_BOOST) || !defined(BOOST_HAS_THREADS) || defined(BOOST_DISABLE_THREADS)
26// if boost libraries are not available we have to skip the tests
27int
28main()
29{
30    banner();
31    std::cout << "Test skipped (Boost libaries not available)\n";
32    return 0;
33}
34#else
35
36#include <boost/thread/mutex.hpp>
37#include <boost/spirit/core.hpp>
38#include <boost/spirit/utility/scoped_lock.hpp>
39#include <boost/detail/lightweight_test.hpp>
40
41int
42main()
43{
44    banner();
45
46    using boost::spirit::rule;
47    using boost::spirit::scoped_lock_d;
48    using boost::spirit::parse_info;
49    using boost::spirit::parse;
50    using boost::mutex;
51
52    mutex m;
53    rule<> r = scoped_lock_d(m)['x'];
54    parse_info<> pi = parse("x", r);
55    BOOST_TEST(pi.hit);
56    BOOST_TEST(pi.full);
57
58    return boost::report_errors();
59}
60
61#endif // defined(DONT_HAVE_BOOST)
Note: See TracBrowser for help on using the repository browser.