No empty .Rs/.Re
[netbsd-mini2440.git] / gnu / dist / gcc4 / libstdc++-v3 / testsuite / ext / rope / 3.cc
blob79dfa41728dec8b5fc159cb0450ba3aa26f6f6bf
1 // Copyright (C) 2004, 2005 Free Software Foundation, Inc.
2 //
3 // This file is part of the GNU ISO C++ Library. This library is free
4 // software; you can redistribute it and/or modify it under the
5 // terms of the GNU General Public License as published by the
6 // Free Software Foundation; either version 2, or (at your option)
7 // any later version.
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License along
15 // with this library; see the file COPYING. If not, write to the Free
16 // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
17 // USA.
19 // rope (SGI extension)
21 #include <ext/rope>
22 #include <testsuite_hooks.h>
24 const char base[] =
25 "Happy families are all alike; every unhappy family is unhappy in \
26 its own way. \
28 Everything was in confusion in the Oblonskys' house. The wife \
29 had discovered that the husband was carrying on an intrigue with \
30 a French girl, who had been a governess in their family, and she \
31 had announced to her husband that she could not go on living in \
32 the same house with him. This position of affairs had now lasted \
33 three days, and not only the husband and wife themselves, but all \
34 the members of their family and household, were painfully \
35 conscious of it. Every person in the house felt that there was \
36 so sense in their living together, and that the stray people \
37 brought together by chance in any inn had more in common with one \
38 another than they, the members of the family and household of the \
39 Oblonskys. The wife did not leave her own room, the husband had \
40 not been at home for three days. The children ran wild all over \
41 the house; the English governess quarreled with the housekeeper, \
42 and wrote to a friend asking her to look out for a new situation \
43 for her; the man-cook had walked off the day before just at \
44 dinner time; the kitchen-maid, and the coachman had given \
45 warning."
48 int baselen = sizeof(base) - 1;
50 template<class StringType>
51 StringType
52 multiply(const StringType& s, int n)
54 StringType result;
55 while (n > 0)
57 result += s;
58 --n;
60 return result;
63 template <class StringType>
64 StringType
65 mung_substrings(const StringType& s, int len, int n, int skip)
67 StringType result;
68 int start = 0;
69 while (n > 0)
71 StringType tmp = s.substr (start, len);
72 result += tmp;
73 --n;
74 start += skip;
76 return result;
79 void
80 test01()
82 using namespace __gnu_cxx;
83 bool test __attribute__((unused)) = true;
85 crope r;
86 r = multiply(crope(base), 100000);
88 crope r1;
89 r1 = mung_substrings(r, 100000, 500, 73);
91 VERIFY( r1.size() == 50000000 );
92 VERIFY( r1.substr(88888, 6)[0] == 's' );
93 VERIFY( r1.substr(88888, 6)[2] == 'h' );
96 int main()
98 test01();
99 return 0;