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.4 KB
|
Rev | Line | |
---|
[29] | 1 | /*============================================================================= |
---|
| 2 | Copyright (c) 1998-2003 Joel de Guzman |
---|
| 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 | #include <boost/spirit/core.hpp> |
---|
| 10 | #include <boost/spirit/error_handling/exceptions.hpp> |
---|
| 11 | #include <iostream> |
---|
| 12 | #include <boost/detail/lightweight_test.hpp> |
---|
| 13 | |
---|
| 14 | using namespace std; |
---|
| 15 | using namespace boost::spirit; |
---|
| 16 | |
---|
| 17 | struct handler |
---|
| 18 | { |
---|
| 19 | template <typename ScannerT, typename ErrorT> |
---|
| 20 | error_status<> |
---|
| 21 | operator()(ScannerT const& /*scan*/, ErrorT const& /*error*/) const |
---|
| 22 | { |
---|
| 23 | cout << "exception caught...Test concluded successfully" << endl; |
---|
| 24 | return error_status<>(error_status<>::fail); |
---|
| 25 | } |
---|
| 26 | }; |
---|
| 27 | |
---|
| 28 | int |
---|
| 29 | main() |
---|
| 30 | { |
---|
| 31 | cout << "/////////////////////////////////////////////////////////\n\n"; |
---|
| 32 | cout << "\t\tExceptions Test...\n\n"; |
---|
| 33 | cout << "/////////////////////////////////////////////////////////\n\n"; |
---|
| 34 | |
---|
| 35 | assertion<int> expect(0); |
---|
| 36 | guard<int> my_guard; |
---|
| 37 | |
---|
| 38 | bool r = |
---|
| 39 | parse("abcx", |
---|
| 40 | my_guard(ch_p('a') >> 'b' >> 'c' >> expect( ch_p('d') )) |
---|
| 41 | [ |
---|
| 42 | handler() |
---|
| 43 | ] |
---|
| 44 | ).full; |
---|
| 45 | |
---|
| 46 | BOOST_TEST(!r); |
---|
| 47 | return boost::report_errors(); |
---|
| 48 | } |
---|
| 49 | |
---|
Note: See
TracBrowser
for help on using the repository browser.