]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/regex/test/pathology/recursion_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.
20 #include <boost/regex.hpp>
21 #include <boost/detail/lightweight_main.hpp>
22 #include "../test_macros.hpp"
25 #pragma warning(disable:1418 981 983 383)
28 int cpp_main( int , char* [] )
30 // this regex will recurse twice for each whitespace character matched:
31 boost::regex
e("([[:space:]]|.)+");
33 std::string
bad_text(1024*1024*4, ' ');
34 std::string
good_text(200, ' ');
39 // Over and over: We want to make sure that after a stack error has
40 // been triggered, that we can still conduct a good search and that
41 // subsequent stack failures still do the right thing:
43 BOOST_CHECK(boost::regex_search(good_text
, what
, e
));
44 BOOST_CHECK_THROW(boost::regex_search(bad_text
, what
, e
), std::runtime_error
);
45 BOOST_CHECK(boost::regex_search(good_text
, what
, e
));
46 BOOST_CHECK_THROW(boost::regex_search(bad_text
, what
, e
), std::runtime_error
);
47 BOOST_CHECK(boost::regex_search(good_text
, what
, e
));
48 BOOST_CHECK_THROW(boost::regex_search(bad_text
, what
, e
), std::runtime_error
);
49 BOOST_CHECK(boost::regex_search(good_text
, what
, e
));
50 BOOST_CHECK_THROW(boost::regex_search(bad_text
, what
, e
), std::runtime_error
);
51 BOOST_CHECK(boost::regex_search(good_text
, what
, e
));
53 BOOST_CHECK(boost::regex_match(good_text
, what
, e
));
54 BOOST_CHECK_THROW(boost::regex_match(bad_text
, what
, e
), std::runtime_error
);
55 BOOST_CHECK(boost::regex_match(good_text
, what
, e
));
56 BOOST_CHECK_THROW(boost::regex_match(bad_text
, what
, e
), std::runtime_error
);
57 BOOST_CHECK(boost::regex_match(good_text
, what
, e
));
58 BOOST_CHECK_THROW(boost::regex_match(bad_text
, what
, e
), std::runtime_error
);
59 BOOST_CHECK(boost::regex_match(good_text
, what
, e
));
60 BOOST_CHECK_THROW(boost::regex_match(bad_text
, what
, e
), std::runtime_error
);
61 BOOST_CHECK(boost::regex_match(good_text
, what
, e
));