1 //===----------------------------------------------------------------------===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is dual licensed under the MIT and the University of Illinois Open 6 // Source Licenses. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 10 // <string> 11 12 // basic_string<charT,traits,Allocator>& 13 // replace(const_iterator i1, const_iterator i2, const charT* s, size_type n); 14 15 #include <string> 16 #include <algorithm> 17 #include <cassert> 18 19 #include "test_macros.h" 20 #include "min_allocator.h" 21 22 template <class S> 23 void 24 test(S s, typename S::size_type pos1, typename S::size_type n1, const typename S::value_type* str, 25 typename S::size_type n2, S expected) 26 { 27 typename S::size_type old_size = s.size(); 28 typename S::const_iterator first = s.begin() + pos1; 29 typename S::const_iterator last = s.begin() + pos1 + n1; 30 typename S::size_type xlen = last - first; 31 s.replace(first, last, str, n2); 32 LIBCPP_ASSERT(s.__invariants()); 33 assert(s == expected); 34 typename S::size_type rlen = n2; 35 assert(s.size() == old_size - xlen + rlen); 36 } 37 38 template <class S> 39 void test0() 40 { 41 test(S(""), 0, 0, "", 0, S("")); 42 test(S(""), 0, 0, "12345", 0, S("")); 43 test(S(""), 0, 0, "12345", 1, S("1")); 44 test(S(""), 0, 0, "12345", 2, S("12")); 45 test(S(""), 0, 0, "12345", 4, S("1234")); 46 test(S(""), 0, 0, "12345", 5, S("12345")); 47 test(S(""), 0, 0, "1234567890", 0, S("")); 48 test(S(""), 0, 0, "1234567890", 1, S("1")); 49 test(S(""), 0, 0, "1234567890", 5, S("12345")); 50 test(S(""), 0, 0, "1234567890", 9, S("123456789")); 51 test(S(""), 0, 0, "1234567890", 10, S("1234567890")); 52 test(S(""), 0, 0, "12345678901234567890", 0, S("")); 53 test(S(""), 0, 0, "12345678901234567890", 1, S("1")); 54 test(S(""), 0, 0, "12345678901234567890", 10, S("1234567890")); 55 test(S(""), 0, 0, "12345678901234567890", 19, S("1234567890123456789")); 56 test(S(""), 0, 0, "12345678901234567890", 20, S("12345678901234567890")); 57 test(S("abcde"), 0, 0, "", 0, S("abcde")); 58 test(S("abcde"), 0, 0, "12345", 0, S("abcde")); 59 test(S("abcde"), 0, 0, "12345", 1, S("1abcde")); 60 test(S("abcde"), 0, 0, "12345", 2, S("12abcde")); 61 test(S("abcde"), 0, 0, "12345", 4, S("1234abcde")); 62 test(S("abcde"), 0, 0, "12345", 5, S("12345abcde")); 63 test(S("abcde"), 0, 0, "1234567890", 0, S("abcde")); 64 test(S("abcde"), 0, 0, "1234567890", 1, S("1abcde")); 65 test(S("abcde"), 0, 0, "1234567890", 5, S("12345abcde")); 66 test(S("abcde"), 0, 0, "1234567890", 9, S("123456789abcde")); 67 test(S("abcde"), 0, 0, "1234567890", 10, S("1234567890abcde")); 68 test(S("abcde"), 0, 0, "12345678901234567890", 0, S("abcde")); 69 test(S("abcde"), 0, 0, "12345678901234567890", 1, S("1abcde")); 70 test(S("abcde"), 0, 0, "12345678901234567890", 10, S("1234567890abcde")); 71 test(S("abcde"), 0, 0, "12345678901234567890", 19, S("1234567890123456789abcde")); 72 test(S("abcde"), 0, 0, "12345678901234567890", 20, S("12345678901234567890abcde")); 73 test(S("abcde"), 0, 1, "", 0, S("bcde")); 74 test(S("abcde"), 0, 1, "12345", 0, S("bcde")); 75 test(S("abcde"), 0, 1, "12345", 1, S("1bcde")); 76 test(S("abcde"), 0, 1, "12345", 2, S("12bcde")); 77 test(S("abcde"), 0, 1, "12345", 4, S("1234bcde")); 78 test(S("abcde"), 0, 1, "12345", 5, S("12345bcde")); 79 test(S("abcde"), 0, 1, "1234567890", 0, S("bcde")); 80 test(S("abcde"), 0, 1, "1234567890", 1, S("1bcde")); 81 test(S("abcde"), 0, 1, "1234567890", 5, S("12345bcde")); 82 test(S("abcde"), 0, 1, "1234567890", 9, S("123456789bcde")); 83 test(S("abcde"), 0, 1, "1234567890", 10, S("1234567890bcde")); 84 test(S("abcde"), 0, 1, "12345678901234567890", 0, S("bcde")); 85 test(S("abcde"), 0, 1, "12345678901234567890", 1, S("1bcde")); 86 test(S("abcde"), 0, 1, "12345678901234567890", 10, S("1234567890bcde")); 87 test(S("abcde"), 0, 1, "12345678901234567890", 19, S("1234567890123456789bcde")); 88 test(S("abcde"), 0, 1, "12345678901234567890", 20, S("12345678901234567890bcde")); 89 test(S("abcde"), 0, 2, "", 0, S("cde")); 90 test(S("abcde"), 0, 2, "12345", 0, S("cde")); 91 test(S("abcde"), 0, 2, "12345", 1, S("1cde")); 92 test(S("abcde"), 0, 2, "12345", 2, S("12cde")); 93 test(S("abcde"), 0, 2, "12345", 4, S("1234cde")); 94 test(S("abcde"), 0, 2, "12345", 5, S("12345cde")); 95 test(S("abcde"), 0, 2, "1234567890", 0, S("cde")); 96 test(S("abcde"), 0, 2, "1234567890", 1, S("1cde")); 97 test(S("abcde"), 0, 2, "1234567890", 5, S("12345cde")); 98 test(S("abcde"), 0, 2, "1234567890", 9, S("123456789cde")); 99 test(S("abcde"), 0, 2, "1234567890", 10, S("1234567890cde")); 100 test(S("abcde"), 0, 2, "12345678901234567890", 0, S("cde")); 101 test(S("abcde"), 0, 2, "12345678901234567890", 1, S("1cde")); 102 test(S("abcde"), 0, 2, "12345678901234567890", 10, S("1234567890cde")); 103 test(S("abcde"), 0, 2, "12345678901234567890", 19, S("1234567890123456789cde")); 104 test(S("abcde"), 0, 2, "12345678901234567890", 20, S("12345678901234567890cde")); 105 test(S("abcde"), 0, 4, "", 0, S("e")); 106 test(S("abcde"), 0, 4, "12345", 0, S("e")); 107 test(S("abcde"), 0, 4, "12345", 1, S("1e")); 108 test(S("abcde"), 0, 4, "12345", 2, S("12e")); 109 test(S("abcde"), 0, 4, "12345", 4, S("1234e")); 110 test(S("abcde"), 0, 4, "12345", 5, S("12345e")); 111 test(S("abcde"), 0, 4, "1234567890", 0, S("e")); 112 test(S("abcde"), 0, 4, "1234567890", 1, S("1e")); 113 test(S("abcde"), 0, 4, "1234567890", 5, S("12345e")); 114 test(S("abcde"), 0, 4, "1234567890", 9, S("123456789e")); 115 test(S("abcde"), 0, 4, "1234567890", 10, S("1234567890e")); 116 test(S("abcde"), 0, 4, "12345678901234567890", 0, S("e")); 117 test(S("abcde"), 0, 4, "12345678901234567890", 1, S("1e")); 118 test(S("abcde"), 0, 4, "12345678901234567890", 10, S("1234567890e")); 119 test(S("abcde"), 0, 4, "12345678901234567890", 19, S("1234567890123456789e")); 120 test(S("abcde"), 0, 4, "12345678901234567890", 20, S("12345678901234567890e")); 121 test(S("abcde"), 0, 5, "", 0, S("")); 122 test(S("abcde"), 0, 5, "12345", 0, S("")); 123 test(S("abcde"), 0, 5, "12345", 1, S("1")); 124 test(S("abcde"), 0, 5, "12345", 2, S("12")); 125 test(S("abcde"), 0, 5, "12345", 4, S("1234")); 126 test(S("abcde"), 0, 5, "12345", 5, S("12345")); 127 test(S("abcde"), 0, 5, "1234567890", 0, S("")); 128 test(S("abcde"), 0, 5, "1234567890", 1, S("1")); 129 test(S("abcde"), 0, 5, "1234567890", 5, S("12345")); 130 test(S("abcde"), 0, 5, "1234567890", 9, S("123456789")); 131 test(S("abcde"), 0, 5, "1234567890", 10, S("1234567890")); 132 test(S("abcde"), 0, 5, "12345678901234567890", 0, S("")); 133 test(S("abcde"), 0, 5, "12345678901234567890", 1, S("1")); 134 test(S("abcde"), 0, 5, "12345678901234567890", 10, S("1234567890")); 135 test(S("abcde"), 0, 5, "12345678901234567890", 19, S("1234567890123456789")); 136 test(S("abcde"), 0, 5, "12345678901234567890", 20, S("12345678901234567890")); 137 test(S("abcde"), 1, 0, "", 0, S("abcde")); 138 test(S("abcde"), 1, 0, "12345", 0, S("abcde")); 139 test(S("abcde"), 1, 0, "12345", 1, S("a1bcde")); 140 test(S("abcde"), 1, 0, "12345", 2, S("a12bcde")); 141 } 142 143 template <class S> 144 void test1() 145 { 146 test(S("abcde"), 1, 0, "12345", 4, S("a1234bcde")); 147 test(S("abcde"), 1, 0, "12345", 5, S("a12345bcde")); 148 test(S("abcde"), 1, 0, "1234567890", 0, S("abcde")); 149 test(S("abcde"), 1, 0, "1234567890", 1, S("a1bcde")); 150 test(S("abcde"), 1, 0, "1234567890", 5, S("a12345bcde")); 151 test(S("abcde"), 1, 0, "1234567890", 9, S("a123456789bcde")); 152 test(S("abcde"), 1, 0, "1234567890", 10, S("a1234567890bcde")); 153 test(S("abcde"), 1, 0, "12345678901234567890", 0, S("abcde")); 154 test(S("abcde"), 1, 0, "12345678901234567890", 1, S("a1bcde")); 155 test(S("abcde"), 1, 0, "12345678901234567890", 10, S("a1234567890bcde")); 156 test(S("abcde"), 1, 0, "12345678901234567890", 19, S("a1234567890123456789bcde")); 157 test(S("abcde"), 1, 0, "12345678901234567890", 20, S("a12345678901234567890bcde")); 158 test(S("abcde"), 1, 1, "", 0, S("acde")); 159 test(S("abcde"), 1, 1, "12345", 0, S("acde")); 160 test(S("abcde"), 1, 1, "12345", 1, S("a1cde")); 161 test(S("abcde"), 1, 1, "12345", 2, S("a12cde")); 162 test(S("abcde"), 1, 1, "12345", 4, S("a1234cde")); 163 test(S("abcde"), 1, 1, "12345", 5, S("a12345cde")); 164 test(S("abcde"), 1, 1, "1234567890", 0, S("acde")); 165 test(S("abcde"), 1, 1, "1234567890", 1, S("a1cde")); 166 test(S("abcde"), 1, 1, "1234567890", 5, S("a12345cde")); 167 test(S("abcde"), 1, 1, "1234567890", 9, S("a123456789cde")); 168 test(S("abcde"), 1, 1, "1234567890", 10, S("a1234567890cde")); 169 test(S("abcde"), 1, 1, "12345678901234567890", 0, S("acde")); 170 test(S("abcde"), 1, 1, "12345678901234567890", 1, S("a1cde")); 171 test(S("abcde"), 1, 1, "12345678901234567890", 10, S("a1234567890cde")); 172 test(S("abcde"), 1, 1, "12345678901234567890", 19, S("a1234567890123456789cde")); 173 test(S("abcde"), 1, 1, "12345678901234567890", 20, S("a12345678901234567890cde")); 174 test(S("abcde"), 1, 2, "", 0, S("ade")); 175 test(S("abcde"), 1, 2, "12345", 0, S("ade")); 176 test(S("abcde"), 1, 2, "12345", 1, S("a1de")); 177 test(S("abcde"), 1, 2, "12345", 2, S("a12de")); 178 test(S("abcde"), 1, 2, "12345", 4, S("a1234de")); 179 test(S("abcde"), 1, 2, "12345", 5, S("a12345de")); 180 test(S("abcde"), 1, 2, "1234567890", 0, S("ade")); 181 test(S("abcde"), 1, 2, "1234567890", 1, S("a1de")); 182 test(S("abcde"), 1, 2, "1234567890", 5, S("a12345de")); 183 test(S("abcde"), 1, 2, "1234567890", 9, S("a123456789de")); 184 test(S("abcde"), 1, 2, "1234567890", 10, S("a1234567890de")); 185 test(S("abcde"), 1, 2, "12345678901234567890", 0, S("ade")); 186 test(S("abcde"), 1, 2, "12345678901234567890", 1, S("a1de")); 187 test(S("abcde"), 1, 2, "12345678901234567890", 10, S("a1234567890de")); 188 test(S("abcde"), 1, 2, "12345678901234567890", 19, S("a1234567890123456789de")); 189 test(S("abcde"), 1, 2, "12345678901234567890", 20, S("a12345678901234567890de")); 190 test(S("abcde"), 1, 3, "", 0, S("ae")); 191 test(S("abcde"), 1, 3, "12345", 0, S("ae")); 192 test(S("abcde"), 1, 3, "12345", 1, S("a1e")); 193 test(S("abcde"), 1, 3, "12345", 2, S("a12e")); 194 test(S("abcde"), 1, 3, "12345", 4, S("a1234e")); 195 test(S("abcde"), 1, 3, "12345", 5, S("a12345e")); 196 test(S("abcde"), 1, 3, "1234567890", 0, S("ae")); 197 test(S("abcde"), 1, 3, "1234567890", 1, S("a1e")); 198 test(S("abcde"), 1, 3, "1234567890", 5, S("a12345e")); 199 test(S("abcde"), 1, 3, "1234567890", 9, S("a123456789e")); 200 test(S("abcde"), 1, 3, "1234567890", 10, S("a1234567890e")); 201 test(S("abcde"), 1, 3, "12345678901234567890", 0, S("ae")); 202 test(S("abcde"), 1, 3, "12345678901234567890", 1, S("a1e")); 203 test(S("abcde"), 1, 3, "12345678901234567890", 10, S("a1234567890e")); 204 test(S("abcde"), 1, 3, "12345678901234567890", 19, S("a1234567890123456789e")); 205 test(S("abcde"), 1, 3, "12345678901234567890", 20, S("a12345678901234567890e")); 206 test(S("abcde"), 1, 4, "", 0, S("a")); 207 test(S("abcde"), 1, 4, "12345", 0, S("a")); 208 test(S("abcde"), 1, 4, "12345", 1, S("a1")); 209 test(S("abcde"), 1, 4, "12345", 2, S("a12")); 210 test(S("abcde"), 1, 4, "12345", 4, S("a1234")); 211 test(S("abcde"), 1, 4, "12345", 5, S("a12345")); 212 test(S("abcde"), 1, 4, "1234567890", 0, S("a")); 213 test(S("abcde"), 1, 4, "1234567890", 1, S("a1")); 214 test(S("abcde"), 1, 4, "1234567890", 5, S("a12345")); 215 test(S("abcde"), 1, 4, "1234567890", 9, S("a123456789")); 216 test(S("abcde"), 1, 4, "1234567890", 10, S("a1234567890")); 217 test(S("abcde"), 1, 4, "12345678901234567890", 0, S("a")); 218 test(S("abcde"), 1, 4, "12345678901234567890", 1, S("a1")); 219 test(S("abcde"), 1, 4, "12345678901234567890", 10, S("a1234567890")); 220 test(S("abcde"), 1, 4, "12345678901234567890", 19, S("a1234567890123456789")); 221 test(S("abcde"), 1, 4, "12345678901234567890", 20, S("a12345678901234567890")); 222 test(S("abcde"), 2, 0, "", 0, S("abcde")); 223 test(S("abcde"), 2, 0, "12345", 0, S("abcde")); 224 test(S("abcde"), 2, 0, "12345", 1, S("ab1cde")); 225 test(S("abcde"), 2, 0, "12345", 2, S("ab12cde")); 226 test(S("abcde"), 2, 0, "12345", 4, S("ab1234cde")); 227 test(S("abcde"), 2, 0, "12345", 5, S("ab12345cde")); 228 test(S("abcde"), 2, 0, "1234567890", 0, S("abcde")); 229 test(S("abcde"), 2, 0, "1234567890", 1, S("ab1cde")); 230 test(S("abcde"), 2, 0, "1234567890", 5, S("ab12345cde")); 231 test(S("abcde"), 2, 0, "1234567890", 9, S("ab123456789cde")); 232 test(S("abcde"), 2, 0, "1234567890", 10, S("ab1234567890cde")); 233 test(S("abcde"), 2, 0, "12345678901234567890", 0, S("abcde")); 234 test(S("abcde"), 2, 0, "12345678901234567890", 1, S("ab1cde")); 235 test(S("abcde"), 2, 0, "12345678901234567890", 10, S("ab1234567890cde")); 236 test(S("abcde"), 2, 0, "12345678901234567890", 19, S("ab1234567890123456789cde")); 237 test(S("abcde"), 2, 0, "12345678901234567890", 20, S("ab12345678901234567890cde")); 238 test(S("abcde"), 2, 1, "", 0, S("abde")); 239 test(S("abcde"), 2, 1, "12345", 0, S("abde")); 240 test(S("abcde"), 2, 1, "12345", 1, S("ab1de")); 241 test(S("abcde"), 2, 1, "12345", 2, S("ab12de")); 242 test(S("abcde"), 2, 1, "12345", 4, S("ab1234de")); 243 test(S("abcde"), 2, 1, "12345", 5, S("ab12345de")); 244 test(S("abcde"), 2, 1, "1234567890", 0, S("abde")); 245 test(S("abcde"), 2, 1, "1234567890", 1, S("ab1de")); 246 } 247 248 template <class S> 249 void test2() 250 { 251 test(S("abcde"), 2, 1, "1234567890", 5, S("ab12345de")); 252 test(S("abcde"), 2, 1, "1234567890", 9, S("ab123456789de")); 253 test(S("abcde"), 2, 1, "1234567890", 10, S("ab1234567890de")); 254 test(S("abcde"), 2, 1, "12345678901234567890", 0, S("abde")); 255 test(S("abcde"), 2, 1, "12345678901234567890", 1, S("ab1de")); 256 test(S("abcde"), 2, 1, "12345678901234567890", 10, S("ab1234567890de")); 257 test(S("abcde"), 2, 1, "12345678901234567890", 19, S("ab1234567890123456789de")); 258 test(S("abcde"), 2, 1, "12345678901234567890", 20, S("ab12345678901234567890de")); 259 test(S("abcde"), 2, 2, "", 0, S("abe")); 260 test(S("abcde"), 2, 2, "12345", 0, S("abe")); 261 test(S("abcde"), 2, 2, "12345", 1, S("ab1e")); 262 test(S("abcde"), 2, 2, "12345", 2, S("ab12e")); 263 test(S("abcde"), 2, 2, "12345", 4, S("ab1234e")); 264 test(S("abcde"), 2, 2, "12345", 5, S("ab12345e")); 265 test(S("abcde"), 2, 2, "1234567890", 0, S("abe")); 266 test(S("abcde"), 2, 2, "1234567890", 1, S("ab1e")); 267 test(S("abcde"), 2, 2, "1234567890", 5, S("ab12345e")); 268 test(S("abcde"), 2, 2, "1234567890", 9, S("ab123456789e")); 269 test(S("abcde"), 2, 2, "1234567890", 10, S("ab1234567890e")); 270 test(S("abcde"), 2, 2, "12345678901234567890", 0, S("abe")); 271 test(S("abcde"), 2, 2, "12345678901234567890", 1, S("ab1e")); 272 test(S("abcde"), 2, 2, "12345678901234567890", 10, S("ab1234567890e")); 273 test(S("abcde"), 2, 2, "12345678901234567890", 19, S("ab1234567890123456789e")); 274 test(S("abcde"), 2, 2, "12345678901234567890", 20, S("ab12345678901234567890e")); 275 test(S("abcde"), 2, 3, "", 0, S("ab")); 276 test(S("abcde"), 2, 3, "12345", 0, S("ab")); 277 test(S("abcde"), 2, 3, "12345", 1, S("ab1")); 278 test(S("abcde"), 2, 3, "12345", 2, S("ab12")); 279 test(S("abcde"), 2, 3, "12345", 4, S("ab1234")); 280 test(S("abcde"), 2, 3, "12345", 5, S("ab12345")); 281 test(S("abcde"), 2, 3, "1234567890", 0, S("ab")); 282 test(S("abcde"), 2, 3, "1234567890", 1, S("ab1")); 283 test(S("abcde"), 2, 3, "1234567890", 5, S("ab12345")); 284 test(S("abcde"), 2, 3, "1234567890", 9, S("ab123456789")); 285 test(S("abcde"), 2, 3, "1234567890", 10, S("ab1234567890")); 286 test(S("abcde"), 2, 3, "12345678901234567890", 0, S("ab")); 287 test(S("abcde"), 2, 3, "12345678901234567890", 1, S("ab1")); 288 test(S("abcde"), 2, 3, "12345678901234567890", 10, S("ab1234567890")); 289 test(S("abcde"), 2, 3, "12345678901234567890", 19, S("ab1234567890123456789")); 290 test(S("abcde"), 2, 3, "12345678901234567890", 20, S("ab12345678901234567890")); 291 test(S("abcde"), 4, 0, "", 0, S("abcde")); 292 test(S("abcde"), 4, 0, "12345", 0, S("abcde")); 293 test(S("abcde"), 4, 0, "12345", 1, S("abcd1e")); 294 test(S("abcde"), 4, 0, "12345", 2, S("abcd12e")); 295 test(S("abcde"), 4, 0, "12345", 4, S("abcd1234e")); 296 test(S("abcde"), 4, 0, "12345", 5, S("abcd12345e")); 297 test(S("abcde"), 4, 0, "1234567890", 0, S("abcde")); 298 test(S("abcde"), 4, 0, "1234567890", 1, S("abcd1e")); 299 test(S("abcde"), 4, 0, "1234567890", 5, S("abcd12345e")); 300 test(S("abcde"), 4, 0, "1234567890", 9, S("abcd123456789e")); 301 test(S("abcde"), 4, 0, "1234567890", 10, S("abcd1234567890e")); 302 test(S("abcde"), 4, 0, "12345678901234567890", 0, S("abcde")); 303 test(S("abcde"), 4, 0, "12345678901234567890", 1, S("abcd1e")); 304 test(S("abcde"), 4, 0, "12345678901234567890", 10, S("abcd1234567890e")); 305 test(S("abcde"), 4, 0, "12345678901234567890", 19, S("abcd1234567890123456789e")); 306 test(S("abcde"), 4, 0, "12345678901234567890", 20, S("abcd12345678901234567890e")); 307 test(S("abcde"), 4, 1, "", 0, S("abcd")); 308 test(S("abcde"), 4, 1, "12345", 0, S("abcd")); 309 test(S("abcde"), 4, 1, "12345", 1, S("abcd1")); 310 test(S("abcde"), 4, 1, "12345", 2, S("abcd12")); 311 test(S("abcde"), 4, 1, "12345", 4, S("abcd1234")); 312 test(S("abcde"), 4, 1, "12345", 5, S("abcd12345")); 313 test(S("abcde"), 4, 1, "1234567890", 0, S("abcd")); 314 test(S("abcde"), 4, 1, "1234567890", 1, S("abcd1")); 315 test(S("abcde"), 4, 1, "1234567890", 5, S("abcd12345")); 316 test(S("abcde"), 4, 1, "1234567890", 9, S("abcd123456789")); 317 test(S("abcde"), 4, 1, "1234567890", 10, S("abcd1234567890")); 318 test(S("abcde"), 4, 1, "12345678901234567890", 0, S("abcd")); 319 test(S("abcde"), 4, 1, "12345678901234567890", 1, S("abcd1")); 320 test(S("abcde"), 4, 1, "12345678901234567890", 10, S("abcd1234567890")); 321 test(S("abcde"), 4, 1, "12345678901234567890", 19, S("abcd1234567890123456789")); 322 test(S("abcde"), 4, 1, "12345678901234567890", 20, S("abcd12345678901234567890")); 323 test(S("abcde"), 5, 0, "", 0, S("abcde")); 324 test(S("abcde"), 5, 0, "12345", 0, S("abcde")); 325 test(S("abcde"), 5, 0, "12345", 1, S("abcde1")); 326 test(S("abcde"), 5, 0, "12345", 2, S("abcde12")); 327 test(S("abcde"), 5, 0, "12345", 4, S("abcde1234")); 328 test(S("abcde"), 5, 0, "12345", 5, S("abcde12345")); 329 test(S("abcde"), 5, 0, "1234567890", 0, S("abcde")); 330 test(S("abcde"), 5, 0, "1234567890", 1, S("abcde1")); 331 test(S("abcde"), 5, 0, "1234567890", 5, S("abcde12345")); 332 test(S("abcde"), 5, 0, "1234567890", 9, S("abcde123456789")); 333 test(S("abcde"), 5, 0, "1234567890", 10, S("abcde1234567890")); 334 test(S("abcde"), 5, 0, "12345678901234567890", 0, S("abcde")); 335 test(S("abcde"), 5, 0, "12345678901234567890", 1, S("abcde1")); 336 test(S("abcde"), 5, 0, "12345678901234567890", 10, S("abcde1234567890")); 337 test(S("abcde"), 5, 0, "12345678901234567890", 19, S("abcde1234567890123456789")); 338 test(S("abcde"), 5, 0, "12345678901234567890", 20, S("abcde12345678901234567890")); 339 test(S("abcdefghij"), 0, 0, "", 0, S("abcdefghij")); 340 test(S("abcdefghij"), 0, 0, "12345", 0, S("abcdefghij")); 341 test(S("abcdefghij"), 0, 0, "12345", 1, S("1abcdefghij")); 342 test(S("abcdefghij"), 0, 0, "12345", 2, S("12abcdefghij")); 343 test(S("abcdefghij"), 0, 0, "12345", 4, S("1234abcdefghij")); 344 test(S("abcdefghij"), 0, 0, "12345", 5, S("12345abcdefghij")); 345 test(S("abcdefghij"), 0, 0, "1234567890", 0, S("abcdefghij")); 346 test(S("abcdefghij"), 0, 0, "1234567890", 1, S("1abcdefghij")); 347 test(S("abcdefghij"), 0, 0, "1234567890", 5, S("12345abcdefghij")); 348 test(S("abcdefghij"), 0, 0, "1234567890", 9, S("123456789abcdefghij")); 349 test(S("abcdefghij"), 0, 0, "1234567890", 10, S("1234567890abcdefghij")); 350 test(S("abcdefghij"), 0, 0, "12345678901234567890", 0, S("abcdefghij")); 351 } 352 353 template <class S> 354 void test3() 355 { 356 test(S("abcdefghij"), 0, 0, "12345678901234567890", 1, S("1abcdefghij")); 357 test(S("abcdefghij"), 0, 0, "12345678901234567890", 10, S("1234567890abcdefghij")); 358 test(S("abcdefghij"), 0, 0, "12345678901234567890", 19, S("1234567890123456789abcdefghij")); 359 test(S("abcdefghij"), 0, 0, "12345678901234567890", 20, S("12345678901234567890abcdefghij")); 360 test(S("abcdefghij"), 0, 1, "", 0, S("bcdefghij")); 361 test(S("abcdefghij"), 0, 1, "12345", 0, S("bcdefghij")); 362 test(S("abcdefghij"), 0, 1, "12345", 1, S("1bcdefghij")); 363 test(S("abcdefghij"), 0, 1, "12345", 2, S("12bcdefghij")); 364 test(S("abcdefghij"), 0, 1, "12345", 4, S("1234bcdefghij")); 365 test(S("abcdefghij"), 0, 1, "12345", 5, S("12345bcdefghij")); 366 test(S("abcdefghij"), 0, 1, "1234567890", 0, S("bcdefghij")); 367 test(S("abcdefghij"), 0, 1, "1234567890", 1, S("1bcdefghij")); 368 test(S("abcdefghij"), 0, 1, "1234567890", 5, S("12345bcdefghij")); 369 test(S("abcdefghij"), 0, 1, "1234567890", 9, S("123456789bcdefghij")); 370 test(S("abcdefghij"), 0, 1, "1234567890", 10, S("1234567890bcdefghij")); 371 test(S("abcdefghij"), 0, 1, "12345678901234567890", 0, S("bcdefghij")); 372 test(S("abcdefghij"), 0, 1, "12345678901234567890", 1, S("1bcdefghij")); 373 test(S("abcdefghij"), 0, 1, "12345678901234567890", 10, S("1234567890bcdefghij")); 374 test(S("abcdefghij"), 0, 1, "12345678901234567890", 19, S("1234567890123456789bcdefghij")); 375 test(S("abcdefghij"), 0, 1, "12345678901234567890", 20, S("12345678901234567890bcdefghij")); 376 test(S("abcdefghij"), 0, 5, "", 0, S("fghij")); 377 test(S("abcdefghij"), 0, 5, "12345", 0, S("fghij")); 378 test(S("abcdefghij"), 0, 5, "12345", 1, S("1fghij")); 379 test(S("abcdefghij"), 0, 5, "12345", 2, S("12fghij")); 380 test(S("abcdefghij"), 0, 5, "12345", 4, S("1234fghij")); 381 test(S("abcdefghij"), 0, 5, "12345", 5, S("12345fghij")); 382 test(S("abcdefghij"), 0, 5, "1234567890", 0, S("fghij")); 383 test(S("abcdefghij"), 0, 5, "1234567890", 1, S("1fghij")); 384 test(S("abcdefghij"), 0, 5, "1234567890", 5, S("12345fghij")); 385 test(S("abcdefghij"), 0, 5, "1234567890", 9, S("123456789fghij")); 386 test(S("abcdefghij"), 0, 5, "1234567890", 10, S("1234567890fghij")); 387 test(S("abcdefghij"), 0, 5, "12345678901234567890", 0, S("fghij")); 388 test(S("abcdefghij"), 0, 5, "12345678901234567890", 1, S("1fghij")); 389 test(S("abcdefghij"), 0, 5, "12345678901234567890", 10, S("1234567890fghij")); 390 test(S("abcdefghij"), 0, 5, "12345678901234567890", 19, S("1234567890123456789fghij")); 391 test(S("abcdefghij"), 0, 5, "12345678901234567890", 20, S("12345678901234567890fghij")); 392 test(S("abcdefghij"), 0, 9, "", 0, S("j")); 393 test(S("abcdefghij"), 0, 9, "12345", 0, S("j")); 394 test(S("abcdefghij"), 0, 9, "12345", 1, S("1j")); 395 test(S("abcdefghij"), 0, 9, "12345", 2, S("12j")); 396 test(S("abcdefghij"), 0, 9, "12345", 4, S("1234j")); 397 test(S("abcdefghij"), 0, 9, "12345", 5, S("12345j")); 398 test(S("abcdefghij"), 0, 9, "1234567890", 0, S("j")); 399 test(S("abcdefghij"), 0, 9, "1234567890", 1, S("1j")); 400 test(S("abcdefghij"), 0, 9, "1234567890", 5, S("12345j")); 401 test(S("abcdefghij"), 0, 9, "1234567890", 9, S("123456789j")); 402 test(S("abcdefghij"), 0, 9, "1234567890", 10, S("1234567890j")); 403 test(S("abcdefghij"), 0, 9, "12345678901234567890", 0, S("j")); 404 test(S("abcdefghij"), 0, 9, "12345678901234567890", 1, S("1j")); 405 test(S("abcdefghij"), 0, 9, "12345678901234567890", 10, S("1234567890j")); 406 test(S("abcdefghij"), 0, 9, "12345678901234567890", 19, S("1234567890123456789j")); 407 test(S("abcdefghij"), 0, 9, "12345678901234567890", 20, S("12345678901234567890j")); 408 test(S("abcdefghij"), 0, 10, "", 0, S("")); 409 test(S("abcdefghij"), 0, 10, "12345", 0, S("")); 410 test(S("abcdefghij"), 0, 10, "12345", 1, S("1")); 411 test(S("abcdefghij"), 0, 10, "12345", 2, S("12")); 412 test(S("abcdefghij"), 0, 10, "12345", 4, S("1234")); 413 test(S("abcdefghij"), 0, 10, "12345", 5, S("12345")); 414 test(S("abcdefghij"), 0, 10, "1234567890", 0, S("")); 415 test(S("abcdefghij"), 0, 10, "1234567890", 1, S("1")); 416 test(S("abcdefghij"), 0, 10, "1234567890", 5, S("12345")); 417 test(S("abcdefghij"), 0, 10, "1234567890", 9, S("123456789")); 418 test(S("abcdefghij"), 0, 10, "1234567890", 10, S("1234567890")); 419 test(S("abcdefghij"), 0, 10, "12345678901234567890", 0, S("")); 420 test(S("abcdefghij"), 0, 10, "12345678901234567890", 1, S("1")); 421 test(S("abcdefghij"), 0, 10, "12345678901234567890", 10, S("1234567890")); 422 test(S("abcdefghij"), 0, 10, "12345678901234567890", 19, S("1234567890123456789")); 423 test(S("abcdefghij"), 0, 10, "12345678901234567890", 20, S("12345678901234567890")); 424 test(S("abcdefghij"), 1, 0, "", 0, S("abcdefghij")); 425 test(S("abcdefghij"), 1, 0, "12345", 0, S("abcdefghij")); 426 test(S("abcdefghij"), 1, 0, "12345", 1, S("a1bcdefghij")); 427 test(S("abcdefghij"), 1, 0, "12345", 2, S("a12bcdefghij")); 428 test(S("abcdefghij"), 1, 0, "12345", 4, S("a1234bcdefghij")); 429 test(S("abcdefghij"), 1, 0, "12345", 5, S("a12345bcdefghij")); 430 test(S("abcdefghij"), 1, 0, "1234567890", 0, S("abcdefghij")); 431 test(S("abcdefghij"), 1, 0, "1234567890", 1, S("a1bcdefghij")); 432 test(S("abcdefghij"), 1, 0, "1234567890", 5, S("a12345bcdefghij")); 433 test(S("abcdefghij"), 1, 0, "1234567890", 9, S("a123456789bcdefghij")); 434 test(S("abcdefghij"), 1, 0, "1234567890", 10, S("a1234567890bcdefghij")); 435 test(S("abcdefghij"), 1, 0, "12345678901234567890", 0, S("abcdefghij")); 436 test(S("abcdefghij"), 1, 0, "12345678901234567890", 1, S("a1bcdefghij")); 437 test(S("abcdefghij"), 1, 0, "12345678901234567890", 10, S("a1234567890bcdefghij")); 438 test(S("abcdefghij"), 1, 0, "12345678901234567890", 19, S("a1234567890123456789bcdefghij")); 439 test(S("abcdefghij"), 1, 0, "12345678901234567890", 20, S("a12345678901234567890bcdefghij")); 440 test(S("abcdefghij"), 1, 1, "", 0, S("acdefghij")); 441 test(S("abcdefghij"), 1, 1, "12345", 0, S("acdefghij")); 442 test(S("abcdefghij"), 1, 1, "12345", 1, S("a1cdefghij")); 443 test(S("abcdefghij"), 1, 1, "12345", 2, S("a12cdefghij")); 444 test(S("abcdefghij"), 1, 1, "12345", 4, S("a1234cdefghij")); 445 test(S("abcdefghij"), 1, 1, "12345", 5, S("a12345cdefghij")); 446 test(S("abcdefghij"), 1, 1, "1234567890", 0, S("acdefghij")); 447 test(S("abcdefghij"), 1, 1, "1234567890", 1, S("a1cdefghij")); 448 test(S("abcdefghij"), 1, 1, "1234567890", 5, S("a12345cdefghij")); 449 test(S("abcdefghij"), 1, 1, "1234567890", 9, S("a123456789cdefghij")); 450 test(S("abcdefghij"), 1, 1, "1234567890", 10, S("a1234567890cdefghij")); 451 test(S("abcdefghij"), 1, 1, "12345678901234567890", 0, S("acdefghij")); 452 test(S("abcdefghij"), 1, 1, "12345678901234567890", 1, S("a1cdefghij")); 453 test(S("abcdefghij"), 1, 1, "12345678901234567890", 10, S("a1234567890cdefghij")); 454 test(S("abcdefghij"), 1, 1, "12345678901234567890", 19, S("a1234567890123456789cdefghij")); 455 test(S("abcdefghij"), 1, 1, "12345678901234567890", 20, S("a12345678901234567890cdefghij")); 456 } 457 458 template <class S> 459 void test4() 460 { 461 test(S("abcdefghij"), 1, 4, "", 0, S("afghij")); 462 test(S("abcdefghij"), 1, 4, "12345", 0, S("afghij")); 463 test(S("abcdefghij"), 1, 4, "12345", 1, S("a1fghij")); 464 test(S("abcdefghij"), 1, 4, "12345", 2, S("a12fghij")); 465 test(S("abcdefghij"), 1, 4, "12345", 4, S("a1234fghij")); 466 test(S("abcdefghij"), 1, 4, "12345", 5, S("a12345fghij")); 467 test(S("abcdefghij"), 1, 4, "1234567890", 0, S("afghij")); 468 test(S("abcdefghij"), 1, 4, "1234567890", 1, S("a1fghij")); 469 test(S("abcdefghij"), 1, 4, "1234567890", 5, S("a12345fghij")); 470 test(S("abcdefghij"), 1, 4, "1234567890", 9, S("a123456789fghij")); 471 test(S("abcdefghij"), 1, 4, "1234567890", 10, S("a1234567890fghij")); 472 test(S("abcdefghij"), 1, 4, "12345678901234567890", 0, S("afghij")); 473 test(S("abcdefghij"), 1, 4, "12345678901234567890", 1, S("a1fghij")); 474 test(S("abcdefghij"), 1, 4, "12345678901234567890", 10, S("a1234567890fghij")); 475 test(S("abcdefghij"), 1, 4, "12345678901234567890", 19, S("a1234567890123456789fghij")); 476 test(S("abcdefghij"), 1, 4, "12345678901234567890", 20, S("a12345678901234567890fghij")); 477 test(S("abcdefghij"), 1, 8, "", 0, S("aj")); 478 test(S("abcdefghij"), 1, 8, "12345", 0, S("aj")); 479 test(S("abcdefghij"), 1, 8, "12345", 1, S("a1j")); 480 test(S("abcdefghij"), 1, 8, "12345", 2, S("a12j")); 481 test(S("abcdefghij"), 1, 8, "12345", 4, S("a1234j")); 482 test(S("abcdefghij"), 1, 8, "12345", 5, S("a12345j")); 483 test(S("abcdefghij"), 1, 8, "1234567890", 0, S("aj")); 484 test(S("abcdefghij"), 1, 8, "1234567890", 1, S("a1j")); 485 test(S("abcdefghij"), 1, 8, "1234567890", 5, S("a12345j")); 486 test(S("abcdefghij"), 1, 8, "1234567890", 9, S("a123456789j")); 487 test(S("abcdefghij"), 1, 8, "1234567890", 10, S("a1234567890j")); 488 test(S("abcdefghij"), 1, 8, "12345678901234567890", 0, S("aj")); 489 test(S("abcdefghij"), 1, 8, "12345678901234567890", 1, S("a1j")); 490 test(S("abcdefghij"), 1, 8, "12345678901234567890", 10, S("a1234567890j")); 491 test(S("abcdefghij"), 1, 8, "12345678901234567890", 19, S("a1234567890123456789j")); 492 test(S("abcdefghij"), 1, 8, "12345678901234567890", 20, S("a12345678901234567890j")); 493 test(S("abcdefghij"), 1, 9, "", 0, S("a")); 494 test(S("abcdefghij"), 1, 9, "12345", 0, S("a")); 495 test(S("abcdefghij"), 1, 9, "12345", 1, S("a1")); 496 test(S("abcdefghij"), 1, 9, "12345", 2, S("a12")); 497 test(S("abcdefghij"), 1, 9, "12345", 4, S("a1234")); 498 test(S("abcdefghij"), 1, 9, "12345", 5, S("a12345")); 499 test(S("abcdefghij"), 1, 9, "1234567890", 0, S("a")); 500 test(S("abcdefghij"), 1, 9, "1234567890", 1, S("a1")); 501 test(S("abcdefghij"), 1, 9, "1234567890", 5, S("a12345")); 502 test(S("abcdefghij"), 1, 9, "1234567890", 9, S("a123456789")); 503 test(S("abcdefghij"), 1, 9, "1234567890", 10, S("a1234567890")); 504 test(S("abcdefghij"), 1, 9, "12345678901234567890", 0, S("a")); 505 test(S("abcdefghij"), 1, 9, "12345678901234567890", 1, S("a1")); 506 test(S("abcdefghij"), 1, 9, "12345678901234567890", 10, S("a1234567890")); 507 test(S("abcdefghij"), 1, 9, "12345678901234567890", 19, S("a1234567890123456789")); 508 test(S("abcdefghij"), 1, 9, "12345678901234567890", 20, S("a12345678901234567890")); 509 test(S("abcdefghij"), 5, 0, "", 0, S("abcdefghij")); 510 test(S("abcdefghij"), 5, 0, "12345", 0, S("abcdefghij")); 511 test(S("abcdefghij"), 5, 0, "12345", 1, S("abcde1fghij")); 512 test(S("abcdefghij"), 5, 0, "12345", 2, S("abcde12fghij")); 513 test(S("abcdefghij"), 5, 0, "12345", 4, S("abcde1234fghij")); 514 test(S("abcdefghij"), 5, 0, "12345", 5, S("abcde12345fghij")); 515 test(S("abcdefghij"), 5, 0, "1234567890", 0, S("abcdefghij")); 516 test(S("abcdefghij"), 5, 0, "1234567890", 1, S("abcde1fghij")); 517 test(S("abcdefghij"), 5, 0, "1234567890", 5, S("abcde12345fghij")); 518 test(S("abcdefghij"), 5, 0, "1234567890", 9, S("abcde123456789fghij")); 519 test(S("abcdefghij"), 5, 0, "1234567890", 10, S("abcde1234567890fghij")); 520 test(S("abcdefghij"), 5, 0, "12345678901234567890", 0, S("abcdefghij")); 521 test(S("abcdefghij"), 5, 0, "12345678901234567890", 1, S("abcde1fghij")); 522 test(S("abcdefghij"), 5, 0, "12345678901234567890", 10, S("abcde1234567890fghij")); 523 test(S("abcdefghij"), 5, 0, "12345678901234567890", 19, S("abcde1234567890123456789fghij")); 524 test(S("abcdefghij"), 5, 0, "12345678901234567890", 20, S("abcde12345678901234567890fghij")); 525 test(S("abcdefghij"), 5, 1, "", 0, S("abcdeghij")); 526 test(S("abcdefghij"), 5, 1, "12345", 0, S("abcdeghij")); 527 test(S("abcdefghij"), 5, 1, "12345", 1, S("abcde1ghij")); 528 test(S("abcdefghij"), 5, 1, "12345", 2, S("abcde12ghij")); 529 test(S("abcdefghij"), 5, 1, "12345", 4, S("abcde1234ghij")); 530 test(S("abcdefghij"), 5, 1, "12345", 5, S("abcde12345ghij")); 531 test(S("abcdefghij"), 5, 1, "1234567890", 0, S("abcdeghij")); 532 test(S("abcdefghij"), 5, 1, "1234567890", 1, S("abcde1ghij")); 533 test(S("abcdefghij"), 5, 1, "1234567890", 5, S("abcde12345ghij")); 534 test(S("abcdefghij"), 5, 1, "1234567890", 9, S("abcde123456789ghij")); 535 test(S("abcdefghij"), 5, 1, "1234567890", 10, S("abcde1234567890ghij")); 536 test(S("abcdefghij"), 5, 1, "12345678901234567890", 0, S("abcdeghij")); 537 test(S("abcdefghij"), 5, 1, "12345678901234567890", 1, S("abcde1ghij")); 538 test(S("abcdefghij"), 5, 1, "12345678901234567890", 10, S("abcde1234567890ghij")); 539 test(S("abcdefghij"), 5, 1, "12345678901234567890", 19, S("abcde1234567890123456789ghij")); 540 test(S("abcdefghij"), 5, 1, "12345678901234567890", 20, S("abcde12345678901234567890ghij")); 541 test(S("abcdefghij"), 5, 2, "", 0, S("abcdehij")); 542 test(S("abcdefghij"), 5, 2, "12345", 0, S("abcdehij")); 543 test(S("abcdefghij"), 5, 2, "12345", 1, S("abcde1hij")); 544 test(S("abcdefghij"), 5, 2, "12345", 2, S("abcde12hij")); 545 test(S("abcdefghij"), 5, 2, "12345", 4, S("abcde1234hij")); 546 test(S("abcdefghij"), 5, 2, "12345", 5, S("abcde12345hij")); 547 test(S("abcdefghij"), 5, 2, "1234567890", 0, S("abcdehij")); 548 test(S("abcdefghij"), 5, 2, "1234567890", 1, S("abcde1hij")); 549 test(S("abcdefghij"), 5, 2, "1234567890", 5, S("abcde12345hij")); 550 test(S("abcdefghij"), 5, 2, "1234567890", 9, S("abcde123456789hij")); 551 test(S("abcdefghij"), 5, 2, "1234567890", 10, S("abcde1234567890hij")); 552 test(S("abcdefghij"), 5, 2, "12345678901234567890", 0, S("abcdehij")); 553 test(S("abcdefghij"), 5, 2, "12345678901234567890", 1, S("abcde1hij")); 554 test(S("abcdefghij"), 5, 2, "12345678901234567890", 10, S("abcde1234567890hij")); 555 test(S("abcdefghij"), 5, 2, "12345678901234567890", 19, S("abcde1234567890123456789hij")); 556 test(S("abcdefghij"), 5, 2, "12345678901234567890", 20, S("abcde12345678901234567890hij")); 557 test(S("abcdefghij"), 5, 4, "", 0, S("abcdej")); 558 test(S("abcdefghij"), 5, 4, "12345", 0, S("abcdej")); 559 test(S("abcdefghij"), 5, 4, "12345", 1, S("abcde1j")); 560 test(S("abcdefghij"), 5, 4, "12345", 2, S("abcde12j")); 561 } 562 563 template <class S> 564 void test5() 565 { 566 test(S("abcdefghij"), 5, 4, "12345", 4, S("abcde1234j")); 567 test(S("abcdefghij"), 5, 4, "12345", 5, S("abcde12345j")); 568 test(S("abcdefghij"), 5, 4, "1234567890", 0, S("abcdej")); 569 test(S("abcdefghij"), 5, 4, "1234567890", 1, S("abcde1j")); 570 test(S("abcdefghij"), 5, 4, "1234567890", 5, S("abcde12345j")); 571 test(S("abcdefghij"), 5, 4, "1234567890", 9, S("abcde123456789j")); 572 test(S("abcdefghij"), 5, 4, "1234567890", 10, S("abcde1234567890j")); 573 test(S("abcdefghij"), 5, 4, "12345678901234567890", 0, S("abcdej")); 574 test(S("abcdefghij"), 5, 4, "12345678901234567890", 1, S("abcde1j")); 575 test(S("abcdefghij"), 5, 4, "12345678901234567890", 10, S("abcde1234567890j")); 576 test(S("abcdefghij"), 5, 4, "12345678901234567890", 19, S("abcde1234567890123456789j")); 577 test(S("abcdefghij"), 5, 4, "12345678901234567890", 20, S("abcde12345678901234567890j")); 578 test(S("abcdefghij"), 5, 5, "", 0, S("abcde")); 579 test(S("abcdefghij"), 5, 5, "12345", 0, S("abcde")); 580 test(S("abcdefghij"), 5, 5, "12345", 1, S("abcde1")); 581 test(S("abcdefghij"), 5, 5, "12345", 2, S("abcde12")); 582 test(S("abcdefghij"), 5, 5, "12345", 4, S("abcde1234")); 583 test(S("abcdefghij"), 5, 5, "12345", 5, S("abcde12345")); 584 test(S("abcdefghij"), 5, 5, "1234567890", 0, S("abcde")); 585 test(S("abcdefghij"), 5, 5, "1234567890", 1, S("abcde1")); 586 test(S("abcdefghij"), 5, 5, "1234567890", 5, S("abcde12345")); 587 test(S("abcdefghij"), 5, 5, "1234567890", 9, S("abcde123456789")); 588 test(S("abcdefghij"), 5, 5, "1234567890", 10, S("abcde1234567890")); 589 test(S("abcdefghij"), 5, 5, "12345678901234567890", 0, S("abcde")); 590 test(S("abcdefghij"), 5, 5, "12345678901234567890", 1, S("abcde1")); 591 test(S("abcdefghij"), 5, 5, "12345678901234567890", 10, S("abcde1234567890")); 592 test(S("abcdefghij"), 5, 5, "12345678901234567890", 19, S("abcde1234567890123456789")); 593 test(S("abcdefghij"), 5, 5, "12345678901234567890", 20, S("abcde12345678901234567890")); 594 test(S("abcdefghij"), 9, 0, "", 0, S("abcdefghij")); 595 test(S("abcdefghij"), 9, 0, "12345", 0, S("abcdefghij")); 596 test(S("abcdefghij"), 9, 0, "12345", 1, S("abcdefghi1j")); 597 test(S("abcdefghij"), 9, 0, "12345", 2, S("abcdefghi12j")); 598 test(S("abcdefghij"), 9, 0, "12345", 4, S("abcdefghi1234j")); 599 test(S("abcdefghij"), 9, 0, "12345", 5, S("abcdefghi12345j")); 600 test(S("abcdefghij"), 9, 0, "1234567890", 0, S("abcdefghij")); 601 test(S("abcdefghij"), 9, 0, "1234567890", 1, S("abcdefghi1j")); 602 test(S("abcdefghij"), 9, 0, "1234567890", 5, S("abcdefghi12345j")); 603 test(S("abcdefghij"), 9, 0, "1234567890", 9, S("abcdefghi123456789j")); 604 test(S("abcdefghij"), 9, 0, "1234567890", 10, S("abcdefghi1234567890j")); 605 test(S("abcdefghij"), 9, 0, "12345678901234567890", 0, S("abcdefghij")); 606 test(S("abcdefghij"), 9, 0, "12345678901234567890", 1, S("abcdefghi1j")); 607 test(S("abcdefghij"), 9, 0, "12345678901234567890", 10, S("abcdefghi1234567890j")); 608 test(S("abcdefghij"), 9, 0, "12345678901234567890", 19, S("abcdefghi1234567890123456789j")); 609 test(S("abcdefghij"), 9, 0, "12345678901234567890", 20, S("abcdefghi12345678901234567890j")); 610 test(S("abcdefghij"), 9, 1, "", 0, S("abcdefghi")); 611 test(S("abcdefghij"), 9, 1, "12345", 0, S("abcdefghi")); 612 test(S("abcdefghij"), 9, 1, "12345", 1, S("abcdefghi1")); 613 test(S("abcdefghij"), 9, 1, "12345", 2, S("abcdefghi12")); 614 test(S("abcdefghij"), 9, 1, "12345", 4, S("abcdefghi1234")); 615 test(S("abcdefghij"), 9, 1, "12345", 5, S("abcdefghi12345")); 616 test(S("abcdefghij"), 9, 1, "1234567890", 0, S("abcdefghi")); 617 test(S("abcdefghij"), 9, 1, "1234567890", 1, S("abcdefghi1")); 618 test(S("abcdefghij"), 9, 1, "1234567890", 5, S("abcdefghi12345")); 619 test(S("abcdefghij"), 9, 1, "1234567890", 9, S("abcdefghi123456789")); 620 test(S("abcdefghij"), 9, 1, "1234567890", 10, S("abcdefghi1234567890")); 621 test(S("abcdefghij"), 9, 1, "12345678901234567890", 0, S("abcdefghi")); 622 test(S("abcdefghij"), 9, 1, "12345678901234567890", 1, S("abcdefghi1")); 623 test(S("abcdefghij"), 9, 1, "12345678901234567890", 10, S("abcdefghi1234567890")); 624 test(S("abcdefghij"), 9, 1, "12345678901234567890", 19, S("abcdefghi1234567890123456789")); 625 test(S("abcdefghij"), 9, 1, "12345678901234567890", 20, S("abcdefghi12345678901234567890")); 626 test(S("abcdefghij"), 10, 0, "", 0, S("abcdefghij")); 627 test(S("abcdefghij"), 10, 0, "12345", 0, S("abcdefghij")); 628 test(S("abcdefghij"), 10, 0, "12345", 1, S("abcdefghij1")); 629 test(S("abcdefghij"), 10, 0, "12345", 2, S("abcdefghij12")); 630 test(S("abcdefghij"), 10, 0, "12345", 4, S("abcdefghij1234")); 631 test(S("abcdefghij"), 10, 0, "12345", 5, S("abcdefghij12345")); 632 test(S("abcdefghij"), 10, 0, "1234567890", 0, S("abcdefghij")); 633 test(S("abcdefghij"), 10, 0, "1234567890", 1, S("abcdefghij1")); 634 test(S("abcdefghij"), 10, 0, "1234567890", 5, S("abcdefghij12345")); 635 test(S("abcdefghij"), 10, 0, "1234567890", 9, S("abcdefghij123456789")); 636 test(S("abcdefghij"), 10, 0, "1234567890", 10, S("abcdefghij1234567890")); 637 test(S("abcdefghij"), 10, 0, "12345678901234567890", 0, S("abcdefghij")); 638 test(S("abcdefghij"), 10, 0, "12345678901234567890", 1, S("abcdefghij1")); 639 test(S("abcdefghij"), 10, 0, "12345678901234567890", 10, S("abcdefghij1234567890")); 640 test(S("abcdefghij"), 10, 0, "12345678901234567890", 19, S("abcdefghij1234567890123456789")); 641 test(S("abcdefghij"), 10, 0, "12345678901234567890", 20, S("abcdefghij12345678901234567890")); 642 test(S("abcdefghijklmnopqrst"), 0, 0, "", 0, S("abcdefghijklmnopqrst")); 643 test(S("abcdefghijklmnopqrst"), 0, 0, "12345", 0, S("abcdefghijklmnopqrst")); 644 test(S("abcdefghijklmnopqrst"), 0, 0, "12345", 1, S("1abcdefghijklmnopqrst")); 645 test(S("abcdefghijklmnopqrst"), 0, 0, "12345", 2, S("12abcdefghijklmnopqrst")); 646 test(S("abcdefghijklmnopqrst"), 0, 0, "12345", 4, S("1234abcdefghijklmnopqrst")); 647 test(S("abcdefghijklmnopqrst"), 0, 0, "12345", 5, S("12345abcdefghijklmnopqrst")); 648 test(S("abcdefghijklmnopqrst"), 0, 0, "1234567890", 0, S("abcdefghijklmnopqrst")); 649 test(S("abcdefghijklmnopqrst"), 0, 0, "1234567890", 1, S("1abcdefghijklmnopqrst")); 650 test(S("abcdefghijklmnopqrst"), 0, 0, "1234567890", 5, S("12345abcdefghijklmnopqrst")); 651 test(S("abcdefghijklmnopqrst"), 0, 0, "1234567890", 9, S("123456789abcdefghijklmnopqrst")); 652 test(S("abcdefghijklmnopqrst"), 0, 0, "1234567890", 10, S("1234567890abcdefghijklmnopqrst")); 653 test(S("abcdefghijklmnopqrst"), 0, 0, "12345678901234567890", 0, S("abcdefghijklmnopqrst")); 654 test(S("abcdefghijklmnopqrst"), 0, 0, "12345678901234567890", 1, S("1abcdefghijklmnopqrst")); 655 test(S("abcdefghijklmnopqrst"), 0, 0, "12345678901234567890", 10, S("1234567890abcdefghijklmnopqrst")); 656 test(S("abcdefghijklmnopqrst"), 0, 0, "12345678901234567890", 19, S("1234567890123456789abcdefghijklmnopqrst")); 657 test(S("abcdefghijklmnopqrst"), 0, 0, "12345678901234567890", 20, S("12345678901234567890abcdefghijklmnopqrst")); 658 test(S("abcdefghijklmnopqrst"), 0, 1, "", 0, S("bcdefghijklmnopqrst")); 659 test(S("abcdefghijklmnopqrst"), 0, 1, "12345", 0, S("bcdefghijklmnopqrst")); 660 test(S("abcdefghijklmnopqrst"), 0, 1, "12345", 1, S("1bcdefghijklmnopqrst")); 661 test(S("abcdefghijklmnopqrst"), 0, 1, "12345", 2, S("12bcdefghijklmnopqrst")); 662 test(S("abcdefghijklmnopqrst"), 0, 1, "12345", 4, S("1234bcdefghijklmnopqrst")); 663 test(S("abcdefghijklmnopqrst"), 0, 1, "12345", 5, S("12345bcdefghijklmnopqrst")); 664 test(S("abcdefghijklmnopqrst"), 0, 1, "1234567890", 0, S("bcdefghijklmnopqrst")); 665 test(S("abcdefghijklmnopqrst"), 0, 1, "1234567890", 1, S("1bcdefghijklmnopqrst")); 666 } 667 668 template <class S> 669 void test6() 670 { 671 test(S("abcdefghijklmnopqrst"), 0, 1, "1234567890", 5, S("12345bcdefghijklmnopqrst")); 672 test(S("abcdefghijklmnopqrst"), 0, 1, "1234567890", 9, S("123456789bcdefghijklmnopqrst")); 673 test(S("abcdefghijklmnopqrst"), 0, 1, "1234567890", 10, S("1234567890bcdefghijklmnopqrst")); 674 test(S("abcdefghijklmnopqrst"), 0, 1, "12345678901234567890", 0, S("bcdefghijklmnopqrst")); 675 test(S("abcdefghijklmnopqrst"), 0, 1, "12345678901234567890", 1, S("1bcdefghijklmnopqrst")); 676 test(S("abcdefghijklmnopqrst"), 0, 1, "12345678901234567890", 10, S("1234567890bcdefghijklmnopqrst")); 677 test(S("abcdefghijklmnopqrst"), 0, 1, "12345678901234567890", 19, S("1234567890123456789bcdefghijklmnopqrst")); 678 test(S("abcdefghijklmnopqrst"), 0, 1, "12345678901234567890", 20, S("12345678901234567890bcdefghijklmnopqrst")); 679 test(S("abcdefghijklmnopqrst"), 0, 10, "", 0, S("klmnopqrst")); 680 test(S("abcdefghijklmnopqrst"), 0, 10, "12345", 0, S("klmnopqrst")); 681 test(S("abcdefghijklmnopqrst"), 0, 10, "12345", 1, S("1klmnopqrst")); 682 test(S("abcdefghijklmnopqrst"), 0, 10, "12345", 2, S("12klmnopqrst")); 683 test(S("abcdefghijklmnopqrst"), 0, 10, "12345", 4, S("1234klmnopqrst")); 684 test(S("abcdefghijklmnopqrst"), 0, 10, "12345", 5, S("12345klmnopqrst")); 685 test(S("abcdefghijklmnopqrst"), 0, 10, "1234567890", 0, S("klmnopqrst")); 686 test(S("abcdefghijklmnopqrst"), 0, 10, "1234567890", 1, S("1klmnopqrst")); 687 test(S("abcdefghijklmnopqrst"), 0, 10, "1234567890", 5, S("12345klmnopqrst")); 688 test(S("abcdefghijklmnopqrst"), 0, 10, "1234567890", 9, S("123456789klmnopqrst")); 689 test(S("abcdefghijklmnopqrst"), 0, 10, "1234567890", 10, S("1234567890klmnopqrst")); 690 test(S("abcdefghijklmnopqrst"), 0, 10, "12345678901234567890", 0, S("klmnopqrst")); 691 test(S("abcdefghijklmnopqrst"), 0, 10, "12345678901234567890", 1, S("1klmnopqrst")); 692 test(S("abcdefghijklmnopqrst"), 0, 10, "12345678901234567890", 10, S("1234567890klmnopqrst")); 693 test(S("abcdefghijklmnopqrst"), 0, 10, "12345678901234567890", 19, S("1234567890123456789klmnopqrst")); 694 test(S("abcdefghijklmnopqrst"), 0, 10, "12345678901234567890", 20, S("12345678901234567890klmnopqrst")); 695 test(S("abcdefghijklmnopqrst"), 0, 19, "", 0, S("t")); 696 test(S("abcdefghijklmnopqrst"), 0, 19, "12345", 0, S("t")); 697 test(S("abcdefghijklmnopqrst"), 0, 19, "12345", 1, S("1t")); 698 test(S("abcdefghijklmnopqrst"), 0, 19, "12345", 2, S("12t")); 699 test(S("abcdefghijklmnopqrst"), 0, 19, "12345", 4, S("1234t")); 700 test(S("abcdefghijklmnopqrst"), 0, 19, "12345", 5, S("12345t")); 701 test(S("abcdefghijklmnopqrst"), 0, 19, "1234567890", 0, S("t")); 702 test(S("abcdefghijklmnopqrst"), 0, 19, "1234567890", 1, S("1t")); 703 test(S("abcdefghijklmnopqrst"), 0, 19, "1234567890", 5, S("12345t")); 704 test(S("abcdefghijklmnopqrst"), 0, 19, "1234567890", 9, S("123456789t")); 705 test(S("abcdefghijklmnopqrst"), 0, 19, "1234567890", 10, S("1234567890t")); 706 test(S("abcdefghijklmnopqrst"), 0, 19, "12345678901234567890", 0, S("t")); 707 test(S("abcdefghijklmnopqrst"), 0, 19, "12345678901234567890", 1, S("1t")); 708 test(S("abcdefghijklmnopqrst"), 0, 19, "12345678901234567890", 10, S("1234567890t")); 709 test(S("abcdefghijklmnopqrst"), 0, 19, "12345678901234567890", 19, S("1234567890123456789t")); 710 test(S("abcdefghijklmnopqrst"), 0, 19, "12345678901234567890", 20, S("12345678901234567890t")); 711 test(S("abcdefghijklmnopqrst"), 0, 20, "", 0, S("")); 712 test(S("abcdefghijklmnopqrst"), 0, 20, "12345", 0, S("")); 713 test(S("abcdefghijklmnopqrst"), 0, 20, "12345", 1, S("1")); 714 test(S("abcdefghijklmnopqrst"), 0, 20, "12345", 2, S("12")); 715 test(S("abcdefghijklmnopqrst"), 0, 20, "12345", 4, S("1234")); 716 test(S("abcdefghijklmnopqrst"), 0, 20, "12345", 5, S("12345")); 717 test(S("abcdefghijklmnopqrst"), 0, 20, "1234567890", 0, S("")); 718 test(S("abcdefghijklmnopqrst"), 0, 20, "1234567890", 1, S("1")); 719 test(S("abcdefghijklmnopqrst"), 0, 20, "1234567890", 5, S("12345")); 720 test(S("abcdefghijklmnopqrst"), 0, 20, "1234567890", 9, S("123456789")); 721 test(S("abcdefghijklmnopqrst"), 0, 20, "1234567890", 10, S("1234567890")); 722 test(S("abcdefghijklmnopqrst"), 0, 20, "12345678901234567890", 0, S("")); 723 test(S("abcdefghijklmnopqrst"), 0, 20, "12345678901234567890", 1, S("1")); 724 test(S("abcdefghijklmnopqrst"), 0, 20, "12345678901234567890", 10, S("1234567890")); 725 test(S("abcdefghijklmnopqrst"), 0, 20, "12345678901234567890", 19, S("1234567890123456789")); 726 test(S("abcdefghijklmnopqrst"), 0, 20, "12345678901234567890", 20, S("12345678901234567890")); 727 test(S("abcdefghijklmnopqrst"), 1, 0, "", 0, S("abcdefghijklmnopqrst")); 728 test(S("abcdefghijklmnopqrst"), 1, 0, "12345", 0, S("abcdefghijklmnopqrst")); 729 test(S("abcdefghijklmnopqrst"), 1, 0, "12345", 1, S("a1bcdefghijklmnopqrst")); 730 test(S("abcdefghijklmnopqrst"), 1, 0, "12345", 2, S("a12bcdefghijklmnopqrst")); 731 test(S("abcdefghijklmnopqrst"), 1, 0, "12345", 4, S("a1234bcdefghijklmnopqrst")); 732 test(S("abcdefghijklmnopqrst"), 1, 0, "12345", 5, S("a12345bcdefghijklmnopqrst")); 733 test(S("abcdefghijklmnopqrst"), 1, 0, "1234567890", 0, S("abcdefghijklmnopqrst")); 734 test(S("abcdefghijklmnopqrst"), 1, 0, "1234567890", 1, S("a1bcdefghijklmnopqrst")); 735 test(S("abcdefghijklmnopqrst"), 1, 0, "1234567890", 5, S("a12345bcdefghijklmnopqrst")); 736 test(S("abcdefghijklmnopqrst"), 1, 0, "1234567890", 9, S("a123456789bcdefghijklmnopqrst")); 737 test(S("abcdefghijklmnopqrst"), 1, 0, "1234567890", 10, S("a1234567890bcdefghijklmnopqrst")); 738 test(S("abcdefghijklmnopqrst"), 1, 0, "12345678901234567890", 0, S("abcdefghijklmnopqrst")); 739 test(S("abcdefghijklmnopqrst"), 1, 0, "12345678901234567890", 1, S("a1bcdefghijklmnopqrst")); 740 test(S("abcdefghijklmnopqrst"), 1, 0, "12345678901234567890", 10, S("a1234567890bcdefghijklmnopqrst")); 741 test(S("abcdefghijklmnopqrst"), 1, 0, "12345678901234567890", 19, S("a1234567890123456789bcdefghijklmnopqrst")); 742 test(S("abcdefghijklmnopqrst"), 1, 0, "12345678901234567890", 20, S("a12345678901234567890bcdefghijklmnopqrst")); 743 test(S("abcdefghijklmnopqrst"), 1, 1, "", 0, S("acdefghijklmnopqrst")); 744 test(S("abcdefghijklmnopqrst"), 1, 1, "12345", 0, S("acdefghijklmnopqrst")); 745 test(S("abcdefghijklmnopqrst"), 1, 1, "12345", 1, S("a1cdefghijklmnopqrst")); 746 test(S("abcdefghijklmnopqrst"), 1, 1, "12345", 2, S("a12cdefghijklmnopqrst")); 747 test(S("abcdefghijklmnopqrst"), 1, 1, "12345", 4, S("a1234cdefghijklmnopqrst")); 748 test(S("abcdefghijklmnopqrst"), 1, 1, "12345", 5, S("a12345cdefghijklmnopqrst")); 749 test(S("abcdefghijklmnopqrst"), 1, 1, "1234567890", 0, S("acdefghijklmnopqrst")); 750 test(S("abcdefghijklmnopqrst"), 1, 1, "1234567890", 1, S("a1cdefghijklmnopqrst")); 751 test(S("abcdefghijklmnopqrst"), 1, 1, "1234567890", 5, S("a12345cdefghijklmnopqrst")); 752 test(S("abcdefghijklmnopqrst"), 1, 1, "1234567890", 9, S("a123456789cdefghijklmnopqrst")); 753 test(S("abcdefghijklmnopqrst"), 1, 1, "1234567890", 10, S("a1234567890cdefghijklmnopqrst")); 754 test(S("abcdefghijklmnopqrst"), 1, 1, "12345678901234567890", 0, S("acdefghijklmnopqrst")); 755 test(S("abcdefghijklmnopqrst"), 1, 1, "12345678901234567890", 1, S("a1cdefghijklmnopqrst")); 756 test(S("abcdefghijklmnopqrst"), 1, 1, "12345678901234567890", 10, S("a1234567890cdefghijklmnopqrst")); 757 test(S("abcdefghijklmnopqrst"), 1, 1, "12345678901234567890", 19, S("a1234567890123456789cdefghijklmnopqrst")); 758 test(S("abcdefghijklmnopqrst"), 1, 1, "12345678901234567890", 20, S("a12345678901234567890cdefghijklmnopqrst")); 759 test(S("abcdefghijklmnopqrst"), 1, 9, "", 0, S("aklmnopqrst")); 760 test(S("abcdefghijklmnopqrst"), 1, 9, "12345", 0, S("aklmnopqrst")); 761 test(S("abcdefghijklmnopqrst"), 1, 9, "12345", 1, S("a1klmnopqrst")); 762 test(S("abcdefghijklmnopqrst"), 1, 9, "12345", 2, S("a12klmnopqrst")); 763 test(S("abcdefghijklmnopqrst"), 1, 9, "12345", 4, S("a1234klmnopqrst")); 764 test(S("abcdefghijklmnopqrst"), 1, 9, "12345", 5, S("a12345klmnopqrst")); 765 test(S("abcdefghijklmnopqrst"), 1, 9, "1234567890", 0, S("aklmnopqrst")); 766 test(S("abcdefghijklmnopqrst"), 1, 9, "1234567890", 1, S("a1klmnopqrst")); 767 test(S("abcdefghijklmnopqrst"), 1, 9, "1234567890", 5, S("a12345klmnopqrst")); 768 test(S("abcdefghijklmnopqrst"), 1, 9, "1234567890", 9, S("a123456789klmnopqrst")); 769 test(S("abcdefghijklmnopqrst"), 1, 9, "1234567890", 10, S("a1234567890klmnopqrst")); 770 test(S("abcdefghijklmnopqrst"), 1, 9, "12345678901234567890", 0, S("aklmnopqrst")); 771 } 772 773 template <class S> 774 void test7() 775 { 776 test(S("abcdefghijklmnopqrst"), 1, 9, "12345678901234567890", 1, S("a1klmnopqrst")); 777 test(S("abcdefghijklmnopqrst"), 1, 9, "12345678901234567890", 10, S("a1234567890klmnopqrst")); 778 test(S("abcdefghijklmnopqrst"), 1, 9, "12345678901234567890", 19, S("a1234567890123456789klmnopqrst")); 779 test(S("abcdefghijklmnopqrst"), 1, 9, "12345678901234567890", 20, S("a12345678901234567890klmnopqrst")); 780 test(S("abcdefghijklmnopqrst"), 1, 18, "", 0, S("at")); 781 test(S("abcdefghijklmnopqrst"), 1, 18, "12345", 0, S("at")); 782 test(S("abcdefghijklmnopqrst"), 1, 18, "12345", 1, S("a1t")); 783 test(S("abcdefghijklmnopqrst"), 1, 18, "12345", 2, S("a12t")); 784 test(S("abcdefghijklmnopqrst"), 1, 18, "12345", 4, S("a1234t")); 785 test(S("abcdefghijklmnopqrst"), 1, 18, "12345", 5, S("a12345t")); 786 test(S("abcdefghijklmnopqrst"), 1, 18, "1234567890", 0, S("at")); 787 test(S("abcdefghijklmnopqrst"), 1, 18, "1234567890", 1, S("a1t")); 788 test(S("abcdefghijklmnopqrst"), 1, 18, "1234567890", 5, S("a12345t")); 789 test(S("abcdefghijklmnopqrst"), 1, 18, "1234567890", 9, S("a123456789t")); 790 test(S("abcdefghijklmnopqrst"), 1, 18, "1234567890", 10, S("a1234567890t")); 791 test(S("abcdefghijklmnopqrst"), 1, 18, "12345678901234567890", 0, S("at")); 792 test(S("abcdefghijklmnopqrst"), 1, 18, "12345678901234567890", 1, S("a1t")); 793 test(S("abcdefghijklmnopqrst"), 1, 18, "12345678901234567890", 10, S("a1234567890t")); 794 test(S("abcdefghijklmnopqrst"), 1, 18, "12345678901234567890", 19, S("a1234567890123456789t")); 795 test(S("abcdefghijklmnopqrst"), 1, 18, "12345678901234567890", 20, S("a12345678901234567890t")); 796 test(S("abcdefghijklmnopqrst"), 1, 19, "", 0, S("a")); 797 test(S("abcdefghijklmnopqrst"), 1, 19, "12345", 0, S("a")); 798 test(S("abcdefghijklmnopqrst"), 1, 19, "12345", 1, S("a1")); 799 test(S("abcdefghijklmnopqrst"), 1, 19, "12345", 2, S("a12")); 800 test(S("abcdefghijklmnopqrst"), 1, 19, "12345", 4, S("a1234")); 801 test(S("abcdefghijklmnopqrst"), 1, 19, "12345", 5, S("a12345")); 802 test(S("abcdefghijklmnopqrst"), 1, 19, "1234567890", 0, S("a")); 803 test(S("abcdefghijklmnopqrst"), 1, 19, "1234567890", 1, S("a1")); 804 test(S("abcdefghijklmnopqrst"), 1, 19, "1234567890", 5, S("a12345")); 805 test(S("abcdefghijklmnopqrst"), 1, 19, "1234567890", 9, S("a123456789")); 806 test(S("abcdefghijklmnopqrst"), 1, 19, "1234567890", 10, S("a1234567890")); 807 test(S("abcdefghijklmnopqrst"), 1, 19, "12345678901234567890", 0, S("a")); 808 test(S("abcdefghijklmnopqrst"), 1, 19, "12345678901234567890", 1, S("a1")); 809 test(S("abcdefghijklmnopqrst"), 1, 19, "12345678901234567890", 10, S("a1234567890")); 810 test(S("abcdefghijklmnopqrst"), 1, 19, "12345678901234567890", 19, S("a1234567890123456789")); 811 test(S("abcdefghijklmnopqrst"), 1, 19, "12345678901234567890", 20, S("a12345678901234567890")); 812 test(S("abcdefghijklmnopqrst"), 10, 0, "", 0, S("abcdefghijklmnopqrst")); 813 test(S("abcdefghijklmnopqrst"), 10, 0, "12345", 0, S("abcdefghijklmnopqrst")); 814 test(S("abcdefghijklmnopqrst"), 10, 0, "12345", 1, S("abcdefghij1klmnopqrst")); 815 test(S("abcdefghijklmnopqrst"), 10, 0, "12345", 2, S("abcdefghij12klmnopqrst")); 816 test(S("abcdefghijklmnopqrst"), 10, 0, "12345", 4, S("abcdefghij1234klmnopqrst")); 817 test(S("abcdefghijklmnopqrst"), 10, 0, "12345", 5, S("abcdefghij12345klmnopqrst")); 818 test(S("abcdefghijklmnopqrst"), 10, 0, "1234567890", 0, S("abcdefghijklmnopqrst")); 819 test(S("abcdefghijklmnopqrst"), 10, 0, "1234567890", 1, S("abcdefghij1klmnopqrst")); 820 test(S("abcdefghijklmnopqrst"), 10, 0, "1234567890", 5, S("abcdefghij12345klmnopqrst")); 821 test(S("abcdefghijklmnopqrst"), 10, 0, "1234567890", 9, S("abcdefghij123456789klmnopqrst")); 822 test(S("abcdefghijklmnopqrst"), 10, 0, "1234567890", 10, S("abcdefghij1234567890klmnopqrst")); 823 test(S("abcdefghijklmnopqrst"), 10, 0, "12345678901234567890", 0, S("abcdefghijklmnopqrst")); 824 test(S("abcdefghijklmnopqrst"), 10, 0, "12345678901234567890", 1, S("abcdefghij1klmnopqrst")); 825 test(S("abcdefghijklmnopqrst"), 10, 0, "12345678901234567890", 10, S("abcdefghij1234567890klmnopqrst")); 826 test(S("abcdefghijklmnopqrst"), 10, 0, "12345678901234567890", 19, S("abcdefghij1234567890123456789klmnopqrst")); 827 test(S("abcdefghijklmnopqrst"), 10, 0, "12345678901234567890", 20, S("abcdefghij12345678901234567890klmnopqrst")); 828 test(S("abcdefghijklmnopqrst"), 10, 1, "", 0, S("abcdefghijlmnopqrst")); 829 test(S("abcdefghijklmnopqrst"), 10, 1, "12345", 0, S("abcdefghijlmnopqrst")); 830 test(S("abcdefghijklmnopqrst"), 10, 1, "12345", 1, S("abcdefghij1lmnopqrst")); 831 test(S("abcdefghijklmnopqrst"), 10, 1, "12345", 2, S("abcdefghij12lmnopqrst")); 832 test(S("abcdefghijklmnopqrst"), 10, 1, "12345", 4, S("abcdefghij1234lmnopqrst")); 833 test(S("abcdefghijklmnopqrst"), 10, 1, "12345", 5, S("abcdefghij12345lmnopqrst")); 834 test(S("abcdefghijklmnopqrst"), 10, 1, "1234567890", 0, S("abcdefghijlmnopqrst")); 835 test(S("abcdefghijklmnopqrst"), 10, 1, "1234567890", 1, S("abcdefghij1lmnopqrst")); 836 test(S("abcdefghijklmnopqrst"), 10, 1, "1234567890", 5, S("abcdefghij12345lmnopqrst")); 837 test(S("abcdefghijklmnopqrst"), 10, 1, "1234567890", 9, S("abcdefghij123456789lmnopqrst")); 838 test(S("abcdefghijklmnopqrst"), 10, 1, "1234567890", 10, S("abcdefghij1234567890lmnopqrst")); 839 test(S("abcdefghijklmnopqrst"), 10, 1, "12345678901234567890", 0, S("abcdefghijlmnopqrst")); 840 test(S("abcdefghijklmnopqrst"), 10, 1, "12345678901234567890", 1, S("abcdefghij1lmnopqrst")); 841 test(S("abcdefghijklmnopqrst"), 10, 1, "12345678901234567890", 10, S("abcdefghij1234567890lmnopqrst")); 842 test(S("abcdefghijklmnopqrst"), 10, 1, "12345678901234567890", 19, S("abcdefghij1234567890123456789lmnopqrst")); 843 test(S("abcdefghijklmnopqrst"), 10, 1, "12345678901234567890", 20, S("abcdefghij12345678901234567890lmnopqrst")); 844 test(S("abcdefghijklmnopqrst"), 10, 5, "", 0, S("abcdefghijpqrst")); 845 test(S("abcdefghijklmnopqrst"), 10, 5, "12345", 0, S("abcdefghijpqrst")); 846 test(S("abcdefghijklmnopqrst"), 10, 5, "12345", 1, S("abcdefghij1pqrst")); 847 test(S("abcdefghijklmnopqrst"), 10, 5, "12345", 2, S("abcdefghij12pqrst")); 848 test(S("abcdefghijklmnopqrst"), 10, 5, "12345", 4, S("abcdefghij1234pqrst")); 849 test(S("abcdefghijklmnopqrst"), 10, 5, "12345", 5, S("abcdefghij12345pqrst")); 850 test(S("abcdefghijklmnopqrst"), 10, 5, "1234567890", 0, S("abcdefghijpqrst")); 851 test(S("abcdefghijklmnopqrst"), 10, 5, "1234567890", 1, S("abcdefghij1pqrst")); 852 test(S("abcdefghijklmnopqrst"), 10, 5, "1234567890", 5, S("abcdefghij12345pqrst")); 853 test(S("abcdefghijklmnopqrst"), 10, 5, "1234567890", 9, S("abcdefghij123456789pqrst")); 854 test(S("abcdefghijklmnopqrst"), 10, 5, "1234567890", 10, S("abcdefghij1234567890pqrst")); 855 test(S("abcdefghijklmnopqrst"), 10, 5, "12345678901234567890", 0, S("abcdefghijpqrst")); 856 test(S("abcdefghijklmnopqrst"), 10, 5, "12345678901234567890", 1, S("abcdefghij1pqrst")); 857 test(S("abcdefghijklmnopqrst"), 10, 5, "12345678901234567890", 10, S("abcdefghij1234567890pqrst")); 858 test(S("abcdefghijklmnopqrst"), 10, 5, "12345678901234567890", 19, S("abcdefghij1234567890123456789pqrst")); 859 test(S("abcdefghijklmnopqrst"), 10, 5, "12345678901234567890", 20, S("abcdefghij12345678901234567890pqrst")); 860 test(S("abcdefghijklmnopqrst"), 10, 9, "", 0, S("abcdefghijt")); 861 test(S("abcdefghijklmnopqrst"), 10, 9, "12345", 0, S("abcdefghijt")); 862 test(S("abcdefghijklmnopqrst"), 10, 9, "12345", 1, S("abcdefghij1t")); 863 test(S("abcdefghijklmnopqrst"), 10, 9, "12345", 2, S("abcdefghij12t")); 864 test(S("abcdefghijklmnopqrst"), 10, 9, "12345", 4, S("abcdefghij1234t")); 865 test(S("abcdefghijklmnopqrst"), 10, 9, "12345", 5, S("abcdefghij12345t")); 866 test(S("abcdefghijklmnopqrst"), 10, 9, "1234567890", 0, S("abcdefghijt")); 867 test(S("abcdefghijklmnopqrst"), 10, 9, "1234567890", 1, S("abcdefghij1t")); 868 test(S("abcdefghijklmnopqrst"), 10, 9, "1234567890", 5, S("abcdefghij12345t")); 869 test(S("abcdefghijklmnopqrst"), 10, 9, "1234567890", 9, S("abcdefghij123456789t")); 870 test(S("abcdefghijklmnopqrst"), 10, 9, "1234567890", 10, S("abcdefghij1234567890t")); 871 test(S("abcdefghijklmnopqrst"), 10, 9, "12345678901234567890", 0, S("abcdefghijt")); 872 test(S("abcdefghijklmnopqrst"), 10, 9, "12345678901234567890", 1, S("abcdefghij1t")); 873 test(S("abcdefghijklmnopqrst"), 10, 9, "12345678901234567890", 10, S("abcdefghij1234567890t")); 874 test(S("abcdefghijklmnopqrst"), 10, 9, "12345678901234567890", 19, S("abcdefghij1234567890123456789t")); 875 test(S("abcdefghijklmnopqrst"), 10, 9, "12345678901234567890", 20, S("abcdefghij12345678901234567890t")); 876 } 877 878 template <class S> 879 void test8() 880 { 881 test(S("abcdefghijklmnopqrst"), 10, 10, "", 0, S("abcdefghij")); 882 test(S("abcdefghijklmnopqrst"), 10, 10, "12345", 0, S("abcdefghij")); 883 test(S("abcdefghijklmnopqrst"), 10, 10, "12345", 1, S("abcdefghij1")); 884 test(S("abcdefghijklmnopqrst"), 10, 10, "12345", 2, S("abcdefghij12")); 885 test(S("abcdefghijklmnopqrst"), 10, 10, "12345", 4, S("abcdefghij1234")); 886 test(S("abcdefghijklmnopqrst"), 10, 10, "12345", 5, S("abcdefghij12345")); 887 test(S("abcdefghijklmnopqrst"), 10, 10, "1234567890", 0, S("abcdefghij")); 888 test(S("abcdefghijklmnopqrst"), 10, 10, "1234567890", 1, S("abcdefghij1")); 889 test(S("abcdefghijklmnopqrst"), 10, 10, "1234567890", 5, S("abcdefghij12345")); 890 test(S("abcdefghijklmnopqrst"), 10, 10, "1234567890", 9, S("abcdefghij123456789")); 891 test(S("abcdefghijklmnopqrst"), 10, 10, "1234567890", 10, S("abcdefghij1234567890")); 892 test(S("abcdefghijklmnopqrst"), 10, 10, "12345678901234567890", 0, S("abcdefghij")); 893 test(S("abcdefghijklmnopqrst"), 10, 10, "12345678901234567890", 1, S("abcdefghij1")); 894 test(S("abcdefghijklmnopqrst"), 10, 10, "12345678901234567890", 10, S("abcdefghij1234567890")); 895 test(S("abcdefghijklmnopqrst"), 10, 10, "12345678901234567890", 19, S("abcdefghij1234567890123456789")); 896 test(S("abcdefghijklmnopqrst"), 10, 10, "12345678901234567890", 20, S("abcdefghij12345678901234567890")); 897 test(S("abcdefghijklmnopqrst"), 19, 0, "", 0, S("abcdefghijklmnopqrst")); 898 test(S("abcdefghijklmnopqrst"), 19, 0, "12345", 0, S("abcdefghijklmnopqrst")); 899 test(S("abcdefghijklmnopqrst"), 19, 0, "12345", 1, S("abcdefghijklmnopqrs1t")); 900 test(S("abcdefghijklmnopqrst"), 19, 0, "12345", 2, S("abcdefghijklmnopqrs12t")); 901 test(S("abcdefghijklmnopqrst"), 19, 0, "12345", 4, S("abcdefghijklmnopqrs1234t")); 902 test(S("abcdefghijklmnopqrst"), 19, 0, "12345", 5, S("abcdefghijklmnopqrs12345t")); 903 test(S("abcdefghijklmnopqrst"), 19, 0, "1234567890", 0, S("abcdefghijklmnopqrst")); 904 test(S("abcdefghijklmnopqrst"), 19, 0, "1234567890", 1, S("abcdefghijklmnopqrs1t")); 905 test(S("abcdefghijklmnopqrst"), 19, 0, "1234567890", 5, S("abcdefghijklmnopqrs12345t")); 906 test(S("abcdefghijklmnopqrst"), 19, 0, "1234567890", 9, S("abcdefghijklmnopqrs123456789t")); 907 test(S("abcdefghijklmnopqrst"), 19, 0, "1234567890", 10, S("abcdefghijklmnopqrs1234567890t")); 908 test(S("abcdefghijklmnopqrst"), 19, 0, "12345678901234567890", 0, S("abcdefghijklmnopqrst")); 909 test(S("abcdefghijklmnopqrst"), 19, 0, "12345678901234567890", 1, S("abcdefghijklmnopqrs1t")); 910 test(S("abcdefghijklmnopqrst"), 19, 0, "12345678901234567890", 10, S("abcdefghijklmnopqrs1234567890t")); 911 test(S("abcdefghijklmnopqrst"), 19, 0, "12345678901234567890", 19, S("abcdefghijklmnopqrs1234567890123456789t")); 912 test(S("abcdefghijklmnopqrst"), 19, 0, "12345678901234567890", 20, S("abcdefghijklmnopqrs12345678901234567890t")); 913 test(S("abcdefghijklmnopqrst"), 19, 1, "", 0, S("abcdefghijklmnopqrs")); 914 test(S("abcdefghijklmnopqrst"), 19, 1, "12345", 0, S("abcdefghijklmnopqrs")); 915 test(S("abcdefghijklmnopqrst"), 19, 1, "12345", 1, S("abcdefghijklmnopqrs1")); 916 test(S("abcdefghijklmnopqrst"), 19, 1, "12345", 2, S("abcdefghijklmnopqrs12")); 917 test(S("abcdefghijklmnopqrst"), 19, 1, "12345", 4, S("abcdefghijklmnopqrs1234")); 918 test(S("abcdefghijklmnopqrst"), 19, 1, "12345", 5, S("abcdefghijklmnopqrs12345")); 919 test(S("abcdefghijklmnopqrst"), 19, 1, "1234567890", 0, S("abcdefghijklmnopqrs")); 920 test(S("abcdefghijklmnopqrst"), 19, 1, "1234567890", 1, S("abcdefghijklmnopqrs1")); 921 test(S("abcdefghijklmnopqrst"), 19, 1, "1234567890", 5, S("abcdefghijklmnopqrs12345")); 922 test(S("abcdefghijklmnopqrst"), 19, 1, "1234567890", 9, S("abcdefghijklmnopqrs123456789")); 923 test(S("abcdefghijklmnopqrst"), 19, 1, "1234567890", 10, S("abcdefghijklmnopqrs1234567890")); 924 test(S("abcdefghijklmnopqrst"), 19, 1, "12345678901234567890", 0, S("abcdefghijklmnopqrs")); 925 test(S("abcdefghijklmnopqrst"), 19, 1, "12345678901234567890", 1, S("abcdefghijklmnopqrs1")); 926 test(S("abcdefghijklmnopqrst"), 19, 1, "12345678901234567890", 10, S("abcdefghijklmnopqrs1234567890")); 927 test(S("abcdefghijklmnopqrst"), 19, 1, "12345678901234567890", 19, S("abcdefghijklmnopqrs1234567890123456789")); 928 test(S("abcdefghijklmnopqrst"), 19, 1, "12345678901234567890", 20, S("abcdefghijklmnopqrs12345678901234567890")); 929 test(S("abcdefghijklmnopqrst"), 20, 0, "", 0, S("abcdefghijklmnopqrst")); 930 test(S("abcdefghijklmnopqrst"), 20, 0, "12345", 0, S("abcdefghijklmnopqrst")); 931 test(S("abcdefghijklmnopqrst"), 20, 0, "12345", 1, S("abcdefghijklmnopqrst1")); 932 test(S("abcdefghijklmnopqrst"), 20, 0, "12345", 2, S("abcdefghijklmnopqrst12")); 933 test(S("abcdefghijklmnopqrst"), 20, 0, "12345", 4, S("abcdefghijklmnopqrst1234")); 934 test(S("abcdefghijklmnopqrst"), 20, 0, "12345", 5, S("abcdefghijklmnopqrst12345")); 935 test(S("abcdefghijklmnopqrst"), 20, 0, "1234567890", 0, S("abcdefghijklmnopqrst")); 936 test(S("abcdefghijklmnopqrst"), 20, 0, "1234567890", 1, S("abcdefghijklmnopqrst1")); 937 test(S("abcdefghijklmnopqrst"), 20, 0, "1234567890", 5, S("abcdefghijklmnopqrst12345")); 938 test(S("abcdefghijklmnopqrst"), 20, 0, "1234567890", 9, S("abcdefghijklmnopqrst123456789")); 939 test(S("abcdefghijklmnopqrst"), 20, 0, "1234567890", 10, S("abcdefghijklmnopqrst1234567890")); 940 test(S("abcdefghijklmnopqrst"), 20, 0, "12345678901234567890", 0, S("abcdefghijklmnopqrst")); 941 test(S("abcdefghijklmnopqrst"), 20, 0, "12345678901234567890", 1, S("abcdefghijklmnopqrst1")); 942 test(S("abcdefghijklmnopqrst"), 20, 0, "12345678901234567890", 10, S("abcdefghijklmnopqrst1234567890")); 943 test(S("abcdefghijklmnopqrst"), 20, 0, "12345678901234567890", 19, S("abcdefghijklmnopqrst1234567890123456789")); 944 test(S("abcdefghijklmnopqrst"), 20, 0, "12345678901234567890", 20, S("abcdefghijklmnopqrst12345678901234567890")); 945 } 946 947 int main() 948 { 949 { 950 typedef std::string S; 951 test0<S>(); 952 test1<S>(); 953 test2<S>(); 954 test3<S>(); 955 test4<S>(); 956 test5<S>(); 957 test6<S>(); 958 test7<S>(); 959 test8<S>(); 960 } 961 #if TEST_STD_VER >= 11 962 { 963 typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; 964 test0<S>(); 965 test1<S>(); 966 test2<S>(); 967 test3<S>(); 968 test4<S>(); 969 test5<S>(); 970 test6<S>(); 971 test7<S>(); 972 test8<S>(); 973 } 974 #endif 975 976 { // test replacing into self 977 typedef std::string S; 978 S s_short = "123/"; 979 S s_long = "Lorem ipsum dolor sit amet, consectetur/"; 980 981 s_short.replace(s_short.begin(), s_short.begin(), s_short.data(), s_short.size()); 982 assert(s_short == "123/123/"); 983 s_short.replace(s_short.begin(), s_short.begin(), s_short.data(), s_short.size()); 984 assert(s_short == "123/123/123/123/"); 985 s_short.replace(s_short.begin(), s_short.begin(), s_short.data(), s_short.size()); 986 assert(s_short == "123/123/123/123/123/123/123/123/"); 987 988 s_long.replace(s_long.begin(), s_long.begin(), s_long.data(), s_long.size()); 989 assert(s_long == "Lorem ipsum dolor sit amet, consectetur/Lorem ipsum dolor sit amet, consectetur/"); 990 } 991 } 992