Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_34_1/libs/regex/test/regress/main.cpp @ 29

Last change on this file since 29 was 29, checked in by landauf, 17 years ago

updated boost from 1_33_1 to 1_34_1

File size: 3.7 KB
Line 
1/*
2 *
3 * Copyright (c) 2004
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         main.cpp
15  *   VERSION      see <boost/version.hpp>
16  *   DESCRIPTION: entry point for test program.
17  */
18
19#include "test.hpp"
20#include "test_locale.hpp"
21#include <stdarg.h>
22
23#ifdef TEST_THREADS
24#include <list>
25#include <boost/thread.hpp>
26#include <boost/thread/tss.hpp>
27#include <boost/shared_ptr.hpp>
28#include <boost/array.hpp>
29
30int* get_array_data();
31
32#endif
33
34int error_count = 0;
35
36void run_tests()
37{
38   basic_tests();
39   test_simple_repeats();
40   test_alt();
41   test_sets();
42   test_sets2();
43   test_anchors();
44   test_backrefs();
45   test_character_escapes();
46   test_assertion_escapes();
47   test_tricky_cases();
48   test_grep();
49   test_replace();
50   test_non_greedy_repeats();
51   test_non_marking_paren();
52   test_partial_match();
53   test_forward_lookahead_asserts();
54   test_fast_repeats();
55   test_fast_repeats2();
56   test_independent_subs();
57   test_nosubs();
58   test_conditionals();
59   test_options();
60   test_options2();
61#ifndef TEST_THREADS
62   test_en_locale();
63#endif
64   test_emacs();
65   test_operators();
66   test_overloads();
67   test_unicode();
68}
69
70int cpp_main(int /*argc*/, char * /*argv*/[])
71{
72#ifdef TEST_THREADS
73   get_array_data();  // initialises data.
74
75   std::list<boost::shared_ptr<boost::thread> > threads;
76   for(int i = 0; i < 5; ++i)
77   {
78      threads.push_back(boost::shared_ptr<boost::thread>(new boost::thread(&run_tests)));
79   }
80   std::list<boost::shared_ptr<boost::thread> >::const_iterator a(threads.begin()), b(threads.end());
81   while(a != b)
82   {
83      (*a)->join();
84      ++a;
85   }
86#else
87   run_tests();
88#endif
89   return error_count;
90}
91
92#ifdef TEST_THREADS
93
94int* get_array_data()
95{
96   static boost::thread_specific_ptr<boost::array<int, 200> > tp;
97
98   if(tp.get() == 0)
99      tp.reset(new boost::array<int, 200>);
100
101   return tp.get()->data();
102}
103
104#endif
105
106const int* make_array(int first, ...)
107{
108   //
109   // this function takes a variable number of arguments
110   // and packs them into an array that we can pass through
111   // our testing macros (ideally we would use an array literal
112   // but these can't apparently be used as macro arguments).
113   //
114#ifdef TEST_THREADS
115   int* data = get_array_data();
116#else
117   static int data[200];
118#endif
119   va_list ap;
120   va_start(ap, first);
121   //
122   // keep packing args, until we get two successive -2 values:
123   //
124   int terminator_count;
125   int next_position = 1;
126   data[0] = first;
127   if(first == -2)
128      terminator_count = 1;
129   else
130      terminator_count = 0;
131   while(terminator_count < 2)
132   {
133      data[next_position] = va_arg(ap, int);
134      if(data[next_position] == -2)
135         ++terminator_count;
136      else
137         terminator_count = 0;
138      ++next_position;
139   }
140   va_end(ap);
141   return data;
142}
143
144#ifdef BOOST_NO_EXCEPTIONS
145
146namespace boost{
147
148void throw_exception(std::exception const & e)
149{
150   std::abort();
151}
152
153}
154
155#endif
156
157void test(const char& c, const test_regex_replace_tag& tag)
158{
159   do_test(c, tag);
160}
161void test(const char& c, const test_regex_search_tag& tag)
162{
163   do_test(c, tag);
164}
165void test(const char& c, const test_invalid_regex_tag& tag)
166{
167   do_test(c, tag);
168}
169
170#ifndef BOOST_NO_WREGEX
171void test(const wchar_t& c, const test_regex_replace_tag& tag)
172{
173   do_test(c, tag);
174}
175void test(const wchar_t& c, const test_regex_search_tag& tag)
176{
177   do_test(c, tag);
178}
179void test(const wchar_t& c, const test_invalid_regex_tag& tag)
180{
181   do_test(c, tag);
182}
183#endif
184
185#include <boost/test/included/prg_exec_monitor.hpp>
Note: See TracBrowser for help on using the repository browser.