]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/testsuite/ext/rope/3.cc
Update copyright years.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / ext / rope / 3.cc
CommitLineData
a5544970 1// Copyright (C) 2004-2019 Free Software Foundation, Inc.
e751adc3
PC
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
748086b7 6// Free Software Foundation; either version 3, or (at your option)
e751adc3
PC
7// any later version.
8
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.
13
14// You should have received a copy of the GNU General Public License along
748086b7
JJ
15// with this library; see the file COPYING3. If not see
16// <http://www.gnu.org/licenses/>.
e751adc3
PC
17
18// rope (SGI extension)
19
20#include <ext/rope>
21#include <testsuite_hooks.h>
22
23const char base[] =
24"Happy families are all alike; every unhappy family is unhappy in \
25its own way. \
26 \
27Everything was in confusion in the Oblonskys' house. The wife \
28had discovered that the husband was carrying on an intrigue with \
29a French girl, who had been a governess in their family, and she \
30had announced to her husband that she could not go on living in \
31the same house with him. This position of affairs had now lasted \
32three days, and not only the husband and wife themselves, but all \
33the members of their family and household, were painfully \
34conscious of it. Every person in the house felt that there was \
35so sense in their living together, and that the stray people \
36brought together by chance in any inn had more in common with one \
37another than they, the members of the family and household of the \
38Oblonskys. The wife did not leave her own room, the husband had \
39not been at home for three days. The children ran wild all over \
40the house; the English governess quarreled with the housekeeper, \
41and wrote to a friend asking her to look out for a new situation \
42for her; the man-cook had walked off the day before just at \
43dinner time; the kitchen-maid, and the coachman had given \
44warning."
45 ;
46
47int baselen = sizeof(base) - 1;
48
49template<class StringType>
50StringType
51multiply(const StringType& s, int n)
52{
53 StringType result;
54 while (n > 0)
55 {
56 result += s;
57 --n;
58 }
59 return result;
60}
61
62template <class StringType>
63StringType
64mung_substrings(const StringType& s, int len, int n, int skip)
65{
66 StringType result;
67 int start = 0;
68 while (n > 0)
69 {
70 StringType tmp = s.substr (start, len);
71 result += tmp;
72 --n;
73 start += skip;
74 }
75 return result;
76}
77
78void
79test01()
80{
81 using namespace __gnu_cxx;
e751adc3
PC
82
83 crope r;
84 r = multiply(crope(base), 100000);
85
86 crope r1;
87 r1 = mung_substrings(r, 100000, 500, 73);
88
89 VERIFY( r1.size() == 50000000 );
90 VERIFY( r1.substr(88888, 6)[0] == 's' );
91 VERIFY( r1.substr(88888, 6)[2] == 'h' );
92}
93
e751adc3
PC
94int main()
95{
96 test01();
97 return 0;
98}