File: bad_expression_test.cpp

package info (click to toggle)
boost 1.32.0-6
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 93,952 kB
  • ctags: 128,458
  • sloc: cpp: 492,477; xml: 52,125; python: 13,519; ansic: 13,013; sh: 1,773; yacc: 853; makefile: 526; perl: 418; lex: 110; csh: 6
file content (49 lines) | stat: -rw-r--r-- 1,434 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/*
 *
 * Copyright (c) 1998-2002
 * Dr John Maddock
 *
 * Use, modification and distribution are subject to the 
 * Boost Software License, Version 1.0. (See accompanying file 
 * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
 *
 */

 /*
  *   LOCATION:    see http://www.boost.org for most recent version.
  *   FILE:        recursion_test.cpp
  *   VERSION:     see <boost/version.hpp>
  *   DESCRIPTION: Test for indefinite recursion and/or stack overrun.
  */

#include <string>
#include <boost/regex.hpp>
#include <boost/test/test_tools.hpp>

int test_main( int , char* [] )
{
   std::string bad_text(1024, ' ');
   std::string good_text(200, ' ');
   good_text.append("xyz");

   boost::smatch what;

   boost::regex e1("(.+)+xyz");

   BOOST_CHECK(boost::regex_search(good_text, what, e1));
   BOOST_CHECK_THROW(boost::regex_search(bad_text, what, e1), std::runtime_error);
   BOOST_CHECK(boost::regex_search(good_text, what, e1));

   BOOST_CHECK(boost::regex_match(good_text, what, e1));
   BOOST_CHECK_THROW(boost::regex_match(bad_text, what, e1), std::runtime_error);
   BOOST_CHECK(boost::regex_match(good_text, what, e1));

   boost::regex e2("abc|[[:space:]]+(xyz)?[[:space:]]+xyz");

   BOOST_CHECK(boost::regex_search(good_text, what, e2));
   BOOST_CHECK_THROW(boost::regex_search(bad_text, what, e2), std::runtime_error);
   BOOST_CHECK(boost::regex_search(good_text, what, e2));

   return 0;
}