size_size_string.pass.cpp revision 4bd6cc9f30fb15f61d1e3f2df0bf11d633c04ebe
1//===----------------------------------------------------------------------===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// 9 10// <string> 11 12// basic_string<charT,traits,Allocator>& 13// replace(size_type pos1, size_type n1, const basic_string<charT,traits,Allocator>& str); 14 15#include <stdio.h> 16 17#include <string> 18#include <stdexcept> 19#include <algorithm> 20#include <cassert> 21 22typedef std::string S; 23 24void 25test(S s, S::size_type pos1, S::size_type n1, S str, S expected) 26{ 27 S::size_type old_size = s.size(); 28 S s0 = s; 29 try 30 { 31 s.replace(pos1, n1, str); 32 assert(s.__invariants()); 33 assert(pos1 <= old_size); 34 assert(s == expected); 35 S::size_type xlen = std::min(n1, old_size - pos1); 36 S::size_type rlen = str.size(); 37 assert(s.size() == old_size - xlen + rlen); 38 } 39 catch (std::out_of_range&) 40 { 41 assert(pos1 > old_size); 42 assert(s == s0); 43 } 44} 45 46void test0() 47{ 48 test(S(""), 0, 0, S(""), S("")); 49 test(S(""), 0, 0, S("12345"), S("12345")); 50 test(S(""), 0, 0, S("1234567890"), S("1234567890")); 51 test(S(""), 0, 0, S("12345678901234567890"), S("12345678901234567890")); 52 test(S(""), 0, 1, S(""), S("")); 53 test(S(""), 0, 1, S("12345"), S("12345")); 54 test(S(""), 0, 1, S("1234567890"), S("1234567890")); 55 test(S(""), 0, 1, S("12345678901234567890"), S("12345678901234567890")); 56 test(S(""), 1, 0, S(""), S("can't happen")); 57 test(S(""), 1, 0, S("12345"), S("can't happen")); 58 test(S(""), 1, 0, S("1234567890"), S("can't happen")); 59 test(S(""), 1, 0, S("12345678901234567890"), S("can't happen")); 60 test(S("abcde"), 0, 0, S(""), S("abcde")); 61 test(S("abcde"), 0, 0, S("12345"), S("12345abcde")); 62 test(S("abcde"), 0, 0, S("1234567890"), S("1234567890abcde")); 63 test(S("abcde"), 0, 0, S("12345678901234567890"), S("12345678901234567890abcde")); 64 test(S("abcde"), 0, 1, S(""), S("bcde")); 65 test(S("abcde"), 0, 1, S("12345"), S("12345bcde")); 66 test(S("abcde"), 0, 1, S("1234567890"), S("1234567890bcde")); 67 test(S("abcde"), 0, 1, S("12345678901234567890"), S("12345678901234567890bcde")); 68 test(S("abcde"), 0, 2, S(""), S("cde")); 69 test(S("abcde"), 0, 2, S("12345"), S("12345cde")); 70 test(S("abcde"), 0, 2, S("1234567890"), S("1234567890cde")); 71 test(S("abcde"), 0, 2, S("12345678901234567890"), S("12345678901234567890cde")); 72 test(S("abcde"), 0, 4, S(""), S("e")); 73 test(S("abcde"), 0, 4, S("12345"), S("12345e")); 74 test(S("abcde"), 0, 4, S("1234567890"), S("1234567890e")); 75 test(S("abcde"), 0, 4, S("12345678901234567890"), S("12345678901234567890e")); 76 test(S("abcde"), 0, 5, S(""), S("")); 77 test(S("abcde"), 0, 5, S("12345"), S("12345")); 78 test(S("abcde"), 0, 5, S("1234567890"), S("1234567890")); 79 test(S("abcde"), 0, 5, S("12345678901234567890"), S("12345678901234567890")); 80 test(S("abcde"), 0, 6, S(""), S("")); 81 test(S("abcde"), 0, 6, S("12345"), S("12345")); 82 test(S("abcde"), 0, 6, S("1234567890"), S("1234567890")); 83 test(S("abcde"), 0, 6, S("12345678901234567890"), S("12345678901234567890")); 84 test(S("abcde"), 1, 0, S(""), S("abcde")); 85 test(S("abcde"), 1, 0, S("12345"), S("a12345bcde")); 86 test(S("abcde"), 1, 0, S("1234567890"), S("a1234567890bcde")); 87 test(S("abcde"), 1, 0, S("12345678901234567890"), S("a12345678901234567890bcde")); 88 test(S("abcde"), 1, 1, S(""), S("acde")); 89 test(S("abcde"), 1, 1, S("12345"), S("a12345cde")); 90 test(S("abcde"), 1, 1, S("1234567890"), S("a1234567890cde")); 91 test(S("abcde"), 1, 1, S("12345678901234567890"), S("a12345678901234567890cde")); 92 test(S("abcde"), 1, 2, S(""), S("ade")); 93 test(S("abcde"), 1, 2, S("12345"), S("a12345de")); 94 test(S("abcde"), 1, 2, S("1234567890"), S("a1234567890de")); 95 test(S("abcde"), 1, 2, S("12345678901234567890"), S("a12345678901234567890de")); 96 test(S("abcde"), 1, 3, S(""), S("ae")); 97 test(S("abcde"), 1, 3, S("12345"), S("a12345e")); 98 test(S("abcde"), 1, 3, S("1234567890"), S("a1234567890e")); 99 test(S("abcde"), 1, 3, S("12345678901234567890"), S("a12345678901234567890e")); 100 test(S("abcde"), 1, 4, S(""), S("a")); 101 test(S("abcde"), 1, 4, S("12345"), S("a12345")); 102 test(S("abcde"), 1, 4, S("1234567890"), S("a1234567890")); 103 test(S("abcde"), 1, 4, S("12345678901234567890"), S("a12345678901234567890")); 104 test(S("abcde"), 1, 5, S(""), S("a")); 105 test(S("abcde"), 1, 5, S("12345"), S("a12345")); 106 test(S("abcde"), 1, 5, S("1234567890"), S("a1234567890")); 107 test(S("abcde"), 1, 5, S("12345678901234567890"), S("a12345678901234567890")); 108 test(S("abcde"), 2, 0, S(""), S("abcde")); 109 test(S("abcde"), 2, 0, S("12345"), S("ab12345cde")); 110 test(S("abcde"), 2, 0, S("1234567890"), S("ab1234567890cde")); 111 test(S("abcde"), 2, 0, S("12345678901234567890"), S("ab12345678901234567890cde")); 112 test(S("abcde"), 2, 1, S(""), S("abde")); 113 test(S("abcde"), 2, 1, S("12345"), S("ab12345de")); 114 test(S("abcde"), 2, 1, S("1234567890"), S("ab1234567890de")); 115 test(S("abcde"), 2, 1, S("12345678901234567890"), S("ab12345678901234567890de")); 116 test(S("abcde"), 2, 2, S(""), S("abe")); 117 test(S("abcde"), 2, 2, S("12345"), S("ab12345e")); 118 test(S("abcde"), 2, 2, S("1234567890"), S("ab1234567890e")); 119 test(S("abcde"), 2, 2, S("12345678901234567890"), S("ab12345678901234567890e")); 120 test(S("abcde"), 2, 3, S(""), S("ab")); 121 test(S("abcde"), 2, 3, S("12345"), S("ab12345")); 122 test(S("abcde"), 2, 3, S("1234567890"), S("ab1234567890")); 123 test(S("abcde"), 2, 3, S("12345678901234567890"), S("ab12345678901234567890")); 124 test(S("abcde"), 2, 4, S(""), S("ab")); 125 test(S("abcde"), 2, 4, S("12345"), S("ab12345")); 126 test(S("abcde"), 2, 4, S("1234567890"), S("ab1234567890")); 127 test(S("abcde"), 2, 4, S("12345678901234567890"), S("ab12345678901234567890")); 128 test(S("abcde"), 4, 0, S(""), S("abcde")); 129 test(S("abcde"), 4, 0, S("12345"), S("abcd12345e")); 130 test(S("abcde"), 4, 0, S("1234567890"), S("abcd1234567890e")); 131 test(S("abcde"), 4, 0, S("12345678901234567890"), S("abcd12345678901234567890e")); 132 test(S("abcde"), 4, 1, S(""), S("abcd")); 133 test(S("abcde"), 4, 1, S("12345"), S("abcd12345")); 134 test(S("abcde"), 4, 1, S("1234567890"), S("abcd1234567890")); 135 test(S("abcde"), 4, 1, S("12345678901234567890"), S("abcd12345678901234567890")); 136 test(S("abcde"), 4, 2, S(""), S("abcd")); 137 test(S("abcde"), 4, 2, S("12345"), S("abcd12345")); 138 test(S("abcde"), 4, 2, S("1234567890"), S("abcd1234567890")); 139 test(S("abcde"), 4, 2, S("12345678901234567890"), S("abcd12345678901234567890")); 140 test(S("abcde"), 5, 0, S(""), S("abcde")); 141 test(S("abcde"), 5, 0, S("12345"), S("abcde12345")); 142 test(S("abcde"), 5, 0, S("1234567890"), S("abcde1234567890")); 143 test(S("abcde"), 5, 0, S("12345678901234567890"), S("abcde12345678901234567890")); 144 test(S("abcde"), 5, 1, S(""), S("abcde")); 145 test(S("abcde"), 5, 1, S("12345"), S("abcde12345")); 146 test(S("abcde"), 5, 1, S("1234567890"), S("abcde1234567890")); 147 test(S("abcde"), 5, 1, S("12345678901234567890"), S("abcde12345678901234567890")); 148} 149 150void test1() 151{ 152 test(S("abcde"), 6, 0, S(""), S("can't happen")); 153 test(S("abcde"), 6, 0, S("12345"), S("can't happen")); 154 test(S("abcde"), 6, 0, S("1234567890"), S("can't happen")); 155 test(S("abcde"), 6, 0, S("12345678901234567890"), S("can't happen")); 156 test(S("abcdefghij"), 0, 0, S(""), S("abcdefghij")); 157 test(S("abcdefghij"), 0, 0, S("12345"), S("12345abcdefghij")); 158 test(S("abcdefghij"), 0, 0, S("1234567890"), S("1234567890abcdefghij")); 159 test(S("abcdefghij"), 0, 0, S("12345678901234567890"), S("12345678901234567890abcdefghij")); 160 test(S("abcdefghij"), 0, 1, S(""), S("bcdefghij")); 161 test(S("abcdefghij"), 0, 1, S("12345"), S("12345bcdefghij")); 162 test(S("abcdefghij"), 0, 1, S("1234567890"), S("1234567890bcdefghij")); 163 test(S("abcdefghij"), 0, 1, S("12345678901234567890"), S("12345678901234567890bcdefghij")); 164 test(S("abcdefghij"), 0, 5, S(""), S("fghij")); 165 test(S("abcdefghij"), 0, 5, S("12345"), S("12345fghij")); 166 test(S("abcdefghij"), 0, 5, S("1234567890"), S("1234567890fghij")); 167 test(S("abcdefghij"), 0, 5, S("12345678901234567890"), S("12345678901234567890fghij")); 168 test(S("abcdefghij"), 0, 9, S(""), S("j")); 169 test(S("abcdefghij"), 0, 9, S("12345"), S("12345j")); 170 test(S("abcdefghij"), 0, 9, S("1234567890"), S("1234567890j")); 171 test(S("abcdefghij"), 0, 9, S("12345678901234567890"), S("12345678901234567890j")); 172 test(S("abcdefghij"), 0, 10, S(""), S("")); 173 test(S("abcdefghij"), 0, 10, S("12345"), S("12345")); 174 test(S("abcdefghij"), 0, 10, S("1234567890"), S("1234567890")); 175 test(S("abcdefghij"), 0, 10, S("12345678901234567890"), S("12345678901234567890")); 176 test(S("abcdefghij"), 0, 11, S(""), S("")); 177 test(S("abcdefghij"), 0, 11, S("12345"), S("12345")); 178 test(S("abcdefghij"), 0, 11, S("1234567890"), S("1234567890")); 179 test(S("abcdefghij"), 0, 11, S("12345678901234567890"), S("12345678901234567890")); 180 test(S("abcdefghij"), 1, 0, S(""), S("abcdefghij")); 181 test(S("abcdefghij"), 1, 0, S("12345"), S("a12345bcdefghij")); 182 test(S("abcdefghij"), 1, 0, S("1234567890"), S("a1234567890bcdefghij")); 183 test(S("abcdefghij"), 1, 0, S("12345678901234567890"), S("a12345678901234567890bcdefghij")); 184 test(S("abcdefghij"), 1, 1, S(""), S("acdefghij")); 185 test(S("abcdefghij"), 1, 1, S("12345"), S("a12345cdefghij")); 186 test(S("abcdefghij"), 1, 1, S("1234567890"), S("a1234567890cdefghij")); 187 test(S("abcdefghij"), 1, 1, S("12345678901234567890"), S("a12345678901234567890cdefghij")); 188 test(S("abcdefghij"), 1, 4, S(""), S("afghij")); 189 test(S("abcdefghij"), 1, 4, S("12345"), S("a12345fghij")); 190 test(S("abcdefghij"), 1, 4, S("1234567890"), S("a1234567890fghij")); 191 test(S("abcdefghij"), 1, 4, S("12345678901234567890"), S("a12345678901234567890fghij")); 192 test(S("abcdefghij"), 1, 8, S(""), S("aj")); 193 test(S("abcdefghij"), 1, 8, S("12345"), S("a12345j")); 194 test(S("abcdefghij"), 1, 8, S("1234567890"), S("a1234567890j")); 195 test(S("abcdefghij"), 1, 8, S("12345678901234567890"), S("a12345678901234567890j")); 196 test(S("abcdefghij"), 1, 9, S(""), S("a")); 197 test(S("abcdefghij"), 1, 9, S("12345"), S("a12345")); 198 test(S("abcdefghij"), 1, 9, S("1234567890"), S("a1234567890")); 199 test(S("abcdefghij"), 1, 9, S("12345678901234567890"), S("a12345678901234567890")); 200 test(S("abcdefghij"), 1, 10, S(""), S("a")); 201 test(S("abcdefghij"), 1, 10, S("12345"), S("a12345")); 202 test(S("abcdefghij"), 1, 10, S("1234567890"), S("a1234567890")); 203 test(S("abcdefghij"), 1, 10, S("12345678901234567890"), S("a12345678901234567890")); 204 test(S("abcdefghij"), 5, 0, S(""), S("abcdefghij")); 205 test(S("abcdefghij"), 5, 0, S("12345"), S("abcde12345fghij")); 206 test(S("abcdefghij"), 5, 0, S("1234567890"), S("abcde1234567890fghij")); 207 test(S("abcdefghij"), 5, 0, S("12345678901234567890"), S("abcde12345678901234567890fghij")); 208 test(S("abcdefghij"), 5, 1, S(""), S("abcdeghij")); 209 test(S("abcdefghij"), 5, 1, S("12345"), S("abcde12345ghij")); 210 test(S("abcdefghij"), 5, 1, S("1234567890"), S("abcde1234567890ghij")); 211 test(S("abcdefghij"), 5, 1, S("12345678901234567890"), S("abcde12345678901234567890ghij")); 212 test(S("abcdefghij"), 5, 2, S(""), S("abcdehij")); 213 test(S("abcdefghij"), 5, 2, S("12345"), S("abcde12345hij")); 214 test(S("abcdefghij"), 5, 2, S("1234567890"), S("abcde1234567890hij")); 215 test(S("abcdefghij"), 5, 2, S("12345678901234567890"), S("abcde12345678901234567890hij")); 216 test(S("abcdefghij"), 5, 4, S(""), S("abcdej")); 217 test(S("abcdefghij"), 5, 4, S("12345"), S("abcde12345j")); 218 test(S("abcdefghij"), 5, 4, S("1234567890"), S("abcde1234567890j")); 219 test(S("abcdefghij"), 5, 4, S("12345678901234567890"), S("abcde12345678901234567890j")); 220 test(S("abcdefghij"), 5, 5, S(""), S("abcde")); 221 test(S("abcdefghij"), 5, 5, S("12345"), S("abcde12345")); 222 test(S("abcdefghij"), 5, 5, S("1234567890"), S("abcde1234567890")); 223 test(S("abcdefghij"), 5, 5, S("12345678901234567890"), S("abcde12345678901234567890")); 224 test(S("abcdefghij"), 5, 6, S(""), S("abcde")); 225 test(S("abcdefghij"), 5, 6, S("12345"), S("abcde12345")); 226 test(S("abcdefghij"), 5, 6, S("1234567890"), S("abcde1234567890")); 227 test(S("abcdefghij"), 5, 6, S("12345678901234567890"), S("abcde12345678901234567890")); 228 test(S("abcdefghij"), 9, 0, S(""), S("abcdefghij")); 229 test(S("abcdefghij"), 9, 0, S("12345"), S("abcdefghi12345j")); 230 test(S("abcdefghij"), 9, 0, S("1234567890"), S("abcdefghi1234567890j")); 231 test(S("abcdefghij"), 9, 0, S("12345678901234567890"), S("abcdefghi12345678901234567890j")); 232 test(S("abcdefghij"), 9, 1, S(""), S("abcdefghi")); 233 test(S("abcdefghij"), 9, 1, S("12345"), S("abcdefghi12345")); 234 test(S("abcdefghij"), 9, 1, S("1234567890"), S("abcdefghi1234567890")); 235 test(S("abcdefghij"), 9, 1, S("12345678901234567890"), S("abcdefghi12345678901234567890")); 236 test(S("abcdefghij"), 9, 2, S(""), S("abcdefghi")); 237 test(S("abcdefghij"), 9, 2, S("12345"), S("abcdefghi12345")); 238 test(S("abcdefghij"), 9, 2, S("1234567890"), S("abcdefghi1234567890")); 239 test(S("abcdefghij"), 9, 2, S("12345678901234567890"), S("abcdefghi12345678901234567890")); 240 test(S("abcdefghij"), 10, 0, S(""), S("abcdefghij")); 241 test(S("abcdefghij"), 10, 0, S("12345"), S("abcdefghij12345")); 242 test(S("abcdefghij"), 10, 0, S("1234567890"), S("abcdefghij1234567890")); 243 test(S("abcdefghij"), 10, 0, S("12345678901234567890"), S("abcdefghij12345678901234567890")); 244 test(S("abcdefghij"), 10, 1, S(""), S("abcdefghij")); 245 test(S("abcdefghij"), 10, 1, S("12345"), S("abcdefghij12345")); 246 test(S("abcdefghij"), 10, 1, S("1234567890"), S("abcdefghij1234567890")); 247 test(S("abcdefghij"), 10, 1, S("12345678901234567890"), S("abcdefghij12345678901234567890")); 248 test(S("abcdefghij"), 11, 0, S(""), S("can't happen")); 249 test(S("abcdefghij"), 11, 0, S("12345"), S("can't happen")); 250 test(S("abcdefghij"), 11, 0, S("1234567890"), S("can't happen")); 251 test(S("abcdefghij"), 11, 0, S("12345678901234567890"), S("can't happen")); 252} 253 254void test2() 255{ 256 test(S("abcdefghijklmnopqrst"), 0, 0, S(""), S("abcdefghijklmnopqrst")); 257 test(S("abcdefghijklmnopqrst"), 0, 0, S("12345"), S("12345abcdefghijklmnopqrst")); 258 test(S("abcdefghijklmnopqrst"), 0, 0, S("1234567890"), S("1234567890abcdefghijklmnopqrst")); 259 test(S("abcdefghijklmnopqrst"), 0, 0, S("12345678901234567890"), S("12345678901234567890abcdefghijklmnopqrst")); 260 test(S("abcdefghijklmnopqrst"), 0, 1, S(""), S("bcdefghijklmnopqrst")); 261 test(S("abcdefghijklmnopqrst"), 0, 1, S("12345"), S("12345bcdefghijklmnopqrst")); 262 test(S("abcdefghijklmnopqrst"), 0, 1, S("1234567890"), S("1234567890bcdefghijklmnopqrst")); 263 test(S("abcdefghijklmnopqrst"), 0, 1, S("12345678901234567890"), S("12345678901234567890bcdefghijklmnopqrst")); 264 test(S("abcdefghijklmnopqrst"), 0, 10, S(""), S("klmnopqrst")); 265 test(S("abcdefghijklmnopqrst"), 0, 10, S("12345"), S("12345klmnopqrst")); 266 test(S("abcdefghijklmnopqrst"), 0, 10, S("1234567890"), S("1234567890klmnopqrst")); 267 test(S("abcdefghijklmnopqrst"), 0, 10, S("12345678901234567890"), S("12345678901234567890klmnopqrst")); 268 test(S("abcdefghijklmnopqrst"), 0, 19, S(""), S("t")); 269 test(S("abcdefghijklmnopqrst"), 0, 19, S("12345"), S("12345t")); 270 test(S("abcdefghijklmnopqrst"), 0, 19, S("1234567890"), S("1234567890t")); 271 test(S("abcdefghijklmnopqrst"), 0, 19, S("12345678901234567890"), S("12345678901234567890t")); 272 test(S("abcdefghijklmnopqrst"), 0, 20, S(""), S("")); 273 test(S("abcdefghijklmnopqrst"), 0, 20, S("12345"), S("12345")); 274 test(S("abcdefghijklmnopqrst"), 0, 20, S("1234567890"), S("1234567890")); 275 test(S("abcdefghijklmnopqrst"), 0, 20, S("12345678901234567890"), S("12345678901234567890")); 276 test(S("abcdefghijklmnopqrst"), 0, 21, S(""), S("")); 277 test(S("abcdefghijklmnopqrst"), 0, 21, S("12345"), S("12345")); 278 test(S("abcdefghijklmnopqrst"), 0, 21, S("1234567890"), S("1234567890")); 279 test(S("abcdefghijklmnopqrst"), 0, 21, S("12345678901234567890"), S("12345678901234567890")); 280 test(S("abcdefghijklmnopqrst"), 1, 0, S(""), S("abcdefghijklmnopqrst")); 281 test(S("abcdefghijklmnopqrst"), 1, 0, S("12345"), S("a12345bcdefghijklmnopqrst")); 282 test(S("abcdefghijklmnopqrst"), 1, 0, S("1234567890"), S("a1234567890bcdefghijklmnopqrst")); 283 test(S("abcdefghijklmnopqrst"), 1, 0, S("12345678901234567890"), S("a12345678901234567890bcdefghijklmnopqrst")); 284 test(S("abcdefghijklmnopqrst"), 1, 1, S(""), S("acdefghijklmnopqrst")); 285 test(S("abcdefghijklmnopqrst"), 1, 1, S("12345"), S("a12345cdefghijklmnopqrst")); 286 test(S("abcdefghijklmnopqrst"), 1, 1, S("1234567890"), S("a1234567890cdefghijklmnopqrst")); 287 test(S("abcdefghijklmnopqrst"), 1, 1, S("12345678901234567890"), S("a12345678901234567890cdefghijklmnopqrst")); 288 test(S("abcdefghijklmnopqrst"), 1, 9, S(""), S("aklmnopqrst")); 289 test(S("abcdefghijklmnopqrst"), 1, 9, S("12345"), S("a12345klmnopqrst")); 290 test(S("abcdefghijklmnopqrst"), 1, 9, S("1234567890"), S("a1234567890klmnopqrst")); 291 test(S("abcdefghijklmnopqrst"), 1, 9, S("12345678901234567890"), S("a12345678901234567890klmnopqrst")); 292 test(S("abcdefghijklmnopqrst"), 1, 18, S(""), S("at")); 293 test(S("abcdefghijklmnopqrst"), 1, 18, S("12345"), S("a12345t")); 294 test(S("abcdefghijklmnopqrst"), 1, 18, S("1234567890"), S("a1234567890t")); 295 test(S("abcdefghijklmnopqrst"), 1, 18, S("12345678901234567890"), S("a12345678901234567890t")); 296 test(S("abcdefghijklmnopqrst"), 1, 19, S(""), S("a")); 297 test(S("abcdefghijklmnopqrst"), 1, 19, S("12345"), S("a12345")); 298 test(S("abcdefghijklmnopqrst"), 1, 19, S("1234567890"), S("a1234567890")); 299 test(S("abcdefghijklmnopqrst"), 1, 19, S("12345678901234567890"), S("a12345678901234567890")); 300 test(S("abcdefghijklmnopqrst"), 1, 20, S(""), S("a")); 301 test(S("abcdefghijklmnopqrst"), 1, 20, S("12345"), S("a12345")); 302 test(S("abcdefghijklmnopqrst"), 1, 20, S("1234567890"), S("a1234567890")); 303 test(S("abcdefghijklmnopqrst"), 1, 20, S("12345678901234567890"), S("a12345678901234567890")); 304 test(S("abcdefghijklmnopqrst"), 10, 0, S(""), S("abcdefghijklmnopqrst")); 305 test(S("abcdefghijklmnopqrst"), 10, 0, S("12345"), S("abcdefghij12345klmnopqrst")); 306 test(S("abcdefghijklmnopqrst"), 10, 0, S("1234567890"), S("abcdefghij1234567890klmnopqrst")); 307 test(S("abcdefghijklmnopqrst"), 10, 0, S("12345678901234567890"), S("abcdefghij12345678901234567890klmnopqrst")); 308 test(S("abcdefghijklmnopqrst"), 10, 1, S(""), S("abcdefghijlmnopqrst")); 309 test(S("abcdefghijklmnopqrst"), 10, 1, S("12345"), S("abcdefghij12345lmnopqrst")); 310 test(S("abcdefghijklmnopqrst"), 10, 1, S("1234567890"), S("abcdefghij1234567890lmnopqrst")); 311 test(S("abcdefghijklmnopqrst"), 10, 1, S("12345678901234567890"), S("abcdefghij12345678901234567890lmnopqrst")); 312 test(S("abcdefghijklmnopqrst"), 10, 5, S(""), S("abcdefghijpqrst")); 313 test(S("abcdefghijklmnopqrst"), 10, 5, S("12345"), S("abcdefghij12345pqrst")); 314 test(S("abcdefghijklmnopqrst"), 10, 5, S("1234567890"), S("abcdefghij1234567890pqrst")); 315 test(S("abcdefghijklmnopqrst"), 10, 5, S("12345678901234567890"), S("abcdefghij12345678901234567890pqrst")); 316 test(S("abcdefghijklmnopqrst"), 10, 9, S(""), S("abcdefghijt")); 317 test(S("abcdefghijklmnopqrst"), 10, 9, S("12345"), S("abcdefghij12345t")); 318 test(S("abcdefghijklmnopqrst"), 10, 9, S("1234567890"), S("abcdefghij1234567890t")); 319 test(S("abcdefghijklmnopqrst"), 10, 9, S("12345678901234567890"), S("abcdefghij12345678901234567890t")); 320 test(S("abcdefghijklmnopqrst"), 10, 10, S(""), S("abcdefghij")); 321 test(S("abcdefghijklmnopqrst"), 10, 10, S("12345"), S("abcdefghij12345")); 322 test(S("abcdefghijklmnopqrst"), 10, 10, S("1234567890"), S("abcdefghij1234567890")); 323 test(S("abcdefghijklmnopqrst"), 10, 10, S("12345678901234567890"), S("abcdefghij12345678901234567890")); 324 test(S("abcdefghijklmnopqrst"), 10, 11, S(""), S("abcdefghij")); 325 test(S("abcdefghijklmnopqrst"), 10, 11, S("12345"), S("abcdefghij12345")); 326 test(S("abcdefghijklmnopqrst"), 10, 11, S("1234567890"), S("abcdefghij1234567890")); 327 test(S("abcdefghijklmnopqrst"), 10, 11, S("12345678901234567890"), S("abcdefghij12345678901234567890")); 328 test(S("abcdefghijklmnopqrst"), 19, 0, S(""), S("abcdefghijklmnopqrst")); 329 test(S("abcdefghijklmnopqrst"), 19, 0, S("12345"), S("abcdefghijklmnopqrs12345t")); 330 test(S("abcdefghijklmnopqrst"), 19, 0, S("1234567890"), S("abcdefghijklmnopqrs1234567890t")); 331 test(S("abcdefghijklmnopqrst"), 19, 0, S("12345678901234567890"), S("abcdefghijklmnopqrs12345678901234567890t")); 332 test(S("abcdefghijklmnopqrst"), 19, 1, S(""), S("abcdefghijklmnopqrs")); 333 test(S("abcdefghijklmnopqrst"), 19, 1, S("12345"), S("abcdefghijklmnopqrs12345")); 334 test(S("abcdefghijklmnopqrst"), 19, 1, S("1234567890"), S("abcdefghijklmnopqrs1234567890")); 335 test(S("abcdefghijklmnopqrst"), 19, 1, S("12345678901234567890"), S("abcdefghijklmnopqrs12345678901234567890")); 336 test(S("abcdefghijklmnopqrst"), 19, 2, S(""), S("abcdefghijklmnopqrs")); 337 test(S("abcdefghijklmnopqrst"), 19, 2, S("12345"), S("abcdefghijklmnopqrs12345")); 338 test(S("abcdefghijklmnopqrst"), 19, 2, S("1234567890"), S("abcdefghijklmnopqrs1234567890")); 339 test(S("abcdefghijklmnopqrst"), 19, 2, S("12345678901234567890"), S("abcdefghijklmnopqrs12345678901234567890")); 340 test(S("abcdefghijklmnopqrst"), 20, 0, S(""), S("abcdefghijklmnopqrst")); 341 test(S("abcdefghijklmnopqrst"), 20, 0, S("12345"), S("abcdefghijklmnopqrst12345")); 342 test(S("abcdefghijklmnopqrst"), 20, 0, S("1234567890"), S("abcdefghijklmnopqrst1234567890")); 343 test(S("abcdefghijklmnopqrst"), 20, 0, S("12345678901234567890"), S("abcdefghijklmnopqrst12345678901234567890")); 344 test(S("abcdefghijklmnopqrst"), 20, 1, S(""), S("abcdefghijklmnopqrst")); 345 test(S("abcdefghijklmnopqrst"), 20, 1, S("12345"), S("abcdefghijklmnopqrst12345")); 346 test(S("abcdefghijklmnopqrst"), 20, 1, S("1234567890"), S("abcdefghijklmnopqrst1234567890")); 347 test(S("abcdefghijklmnopqrst"), 20, 1, S("12345678901234567890"), S("abcdefghijklmnopqrst12345678901234567890")); 348 test(S("abcdefghijklmnopqrst"), 21, 0, S(""), S("can't happen")); 349 test(S("abcdefghijklmnopqrst"), 21, 0, S("12345"), S("can't happen")); 350 test(S("abcdefghijklmnopqrst"), 21, 0, S("1234567890"), S("can't happen")); 351 test(S("abcdefghijklmnopqrst"), 21, 0, S("12345678901234567890"), S("can't happen")); 352} 353 354int main() 355{ 356 test0(); 357 test1(); 358 test2(); 359} 360