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