]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/regex/test/pathology/bad_expression_test.cpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / libs / regex / test / pathology / bad_expression_test.cpp
CommitLineData
7c673cae
FG
1/*
2 *
3 * Copyright (c) 1998-2002
4 * John Maddock
5 *
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)
9 *
10 */
11
12 /*
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.
17 */
18
7c673cae
FG
19#include <boost/regex.hpp>
20#include <boost/detail/lightweight_main.hpp>
21#include "../test_macros.hpp"
b32b8144 22#include <string>
7c673cae
FG
23
24#ifdef BOOST_INTEL
25#pragma warning(disable:1418 981 983 383)
26#endif
27
28int cpp_main( int , char* [] )
29{
30 std::string bad_text(1024, ' ');
31 std::string good_text(200, ' ');
32 good_text.append("xyz");
33
34 boost::smatch what;
35
36 boost::regex e1("(.+)+xyz");
37
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));
41
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));
45
46 boost::regex e2("abc|[[:space:]]+(xyz)?[[:space:]]+xyz");
47
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));
51
52 bad_text.assign((std::string::size_type)500000, 'a');
53 e2.assign("aaa*@");
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));
57
58 return 0;
59}
60