]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/regex/test/pathology/bad_expression_test.cpp
3 * Copyright (c) 1998-2002
6 * Use, modification and distribution are subject to the
7 * Boost Software License, Version 1.0. (See accompanying file
8 * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
13 * LOCATION: see http://www.boost.org for most recent version.
14 * FILE: recursion_test.cpp
15 * VERSION: see <boost/version.hpp>
16 * DESCRIPTION: Test for indefinite recursion and/or stack overrun.
19 #include <boost/regex.hpp>
20 #include <boost/detail/lightweight_main.hpp>
21 #include "../test_macros.hpp"
25 #pragma warning(disable:1418 981 983 383)
28 int cpp_main( int , char* [] )
30 std::string
bad_text(1024, ' ');
31 std::string
good_text(200, ' ');
32 good_text
.append("xyz");
36 boost::regex
e1("(.+)+xyz");
38 BOOST_CHECK(boost::regex_search(good_text
, what
, e1
));
39 BOOST_CHECK_THROW(boost::regex_search(bad_text
, what
, e1
), std::runtime_error
);
40 BOOST_CHECK(boost::regex_search(good_text
, what
, e1
));
42 BOOST_CHECK(boost::regex_match(good_text
, what
, e1
));
43 BOOST_CHECK_THROW(boost::regex_match(bad_text
, what
, e1
), std::runtime_error
);
44 BOOST_CHECK(boost::regex_match(good_text
, what
, e1
));
46 boost::regex
e2("abc|[[:space:]]+(xyz)?[[:space:]]+xyz");
48 BOOST_CHECK(boost::regex_search(good_text
, what
, e2
));
49 BOOST_CHECK_THROW(boost::regex_search(bad_text
, what
, e2
), std::runtime_error
);
50 BOOST_CHECK(boost::regex_search(good_text
, what
, e2
));
52 bad_text
.assign((std::string::size_type
)500000, 'a');
54 BOOST_CHECK_THROW(boost::regex_search(bad_text
, what
, e2
), std::runtime_error
);
55 good_text
.assign((std::string::size_type
)5000, 'a');
56 BOOST_CHECK(0 == boost::regex_search(good_text
, what
, e2
));