Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1 | //===----------------------------------------------------------------------===// |
| 2 | // |
Howard Hinnant | f5256e1 | 2010-05-11 21:36:01 +0000 | [diff] [blame] | 3 | // The LLVM Compiler Infrastructure |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4 | // |
Howard Hinnant | b64f8b0 | 2010-11-16 22:09:02 +0000 | [diff] [blame] | 5 | // This file is dual licensed under the MIT and the University of Illinois Open |
| 6 | // Source Licenses. See LICENSE.TXT for details. |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | // <string> |
| 11 | |
Howard Hinnant | 6e0a1f4 | 2010-08-22 00:47:54 +0000 | [diff] [blame] | 12 | // basic_string<charT,traits,Allocator>& |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 13 | // insert(size_type pos, const charT* s, size_type n); |
| 14 | |
| 15 | #include <string> |
| 16 | #include <stdexcept> |
| 17 | #include <cassert> |
| 18 | |
Marshall Clow | 061d0cc | 2013-11-26 20:58:02 +0000 | [diff] [blame] | 19 | #include "min_allocator.h" |
Howard Hinnant | 9dcdcde | 2013-06-28 16:59:19 +0000 | [diff] [blame] | 20 | |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 21 | template <class S> |
| 22 | void |
| 23 | test(S s, typename S::size_type pos, const typename S::value_type* str, |
| 24 | typename S::size_type n, S expected) |
| 25 | { |
| 26 | typename S::size_type old_size = s.size(); |
| 27 | S s0 = s; |
| 28 | try |
| 29 | { |
| 30 | s.insert(pos, str, n); |
Dan Albert | 1d4a1ed | 2016-05-25 22:36:09 -0700 | [diff] [blame^] | 31 | assert(s.__invariants()); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 32 | assert(pos <= old_size); |
| 33 | assert(s == expected); |
| 34 | } |
| 35 | catch (std::out_of_range&) |
| 36 | { |
| 37 | assert(pos > old_size); |
| 38 | assert(s == s0); |
| 39 | } |
| 40 | } |
| 41 | |
| 42 | int main() |
| 43 | { |
Howard Hinnant | 9dcdcde | 2013-06-28 16:59:19 +0000 | [diff] [blame] | 44 | { |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 45 | typedef std::string S; |
| 46 | test(S(""), 0, "", 0, S("")); |
| 47 | test(S(""), 0, "12345", 0, S("")); |
| 48 | test(S(""), 0, "12345", 1, S("1")); |
| 49 | test(S(""), 0, "12345", 2, S("12")); |
| 50 | test(S(""), 0, "12345", 4, S("1234")); |
| 51 | test(S(""), 0, "12345", 5, S("12345")); |
| 52 | test(S(""), 0, "1234567890", 0, S("")); |
| 53 | test(S(""), 0, "1234567890", 1, S("1")); |
| 54 | test(S(""), 0, "1234567890", 5, S("12345")); |
| 55 | test(S(""), 0, "1234567890", 9, S("123456789")); |
| 56 | test(S(""), 0, "1234567890", 10, S("1234567890")); |
| 57 | test(S(""), 0, "12345678901234567890", 0, S("")); |
| 58 | test(S(""), 0, "12345678901234567890", 1, S("1")); |
| 59 | test(S(""), 0, "12345678901234567890", 10, S("1234567890")); |
| 60 | test(S(""), 0, "12345678901234567890", 19, S("1234567890123456789")); |
| 61 | test(S(""), 0, "12345678901234567890", 20, S("12345678901234567890")); |
| 62 | test(S(""), 1, "", 0, S("can't happen")); |
| 63 | test(S(""), 1, "12345", 0, S("can't happen")); |
| 64 | test(S(""), 1, "12345", 1, S("can't happen")); |
| 65 | test(S(""), 1, "12345", 2, S("can't happen")); |
| 66 | test(S(""), 1, "12345", 4, S("can't happen")); |
| 67 | test(S(""), 1, "12345", 5, S("can't happen")); |
| 68 | test(S(""), 1, "1234567890", 0, S("can't happen")); |
| 69 | test(S(""), 1, "1234567890", 1, S("can't happen")); |
| 70 | test(S(""), 1, "1234567890", 5, S("can't happen")); |
| 71 | test(S(""), 1, "1234567890", 9, S("can't happen")); |
| 72 | test(S(""), 1, "1234567890", 10, S("can't happen")); |
| 73 | test(S(""), 1, "12345678901234567890", 0, S("can't happen")); |
| 74 | test(S(""), 1, "12345678901234567890", 1, S("can't happen")); |
| 75 | test(S(""), 1, "12345678901234567890", 10, S("can't happen")); |
| 76 | test(S(""), 1, "12345678901234567890", 19, S("can't happen")); |
| 77 | test(S(""), 1, "12345678901234567890", 20, S("can't happen")); |
| 78 | test(S("abcde"), 0, "", 0, S("abcde")); |
| 79 | test(S("abcde"), 0, "12345", 0, S("abcde")); |
| 80 | test(S("abcde"), 0, "12345", 1, S("1abcde")); |
| 81 | test(S("abcde"), 0, "12345", 2, S("12abcde")); |
| 82 | test(S("abcde"), 0, "12345", 4, S("1234abcde")); |
| 83 | test(S("abcde"), 0, "12345", 5, S("12345abcde")); |
| 84 | test(S("abcde"), 0, "1234567890", 0, S("abcde")); |
| 85 | test(S("abcde"), 0, "1234567890", 1, S("1abcde")); |
| 86 | test(S("abcde"), 0, "1234567890", 5, S("12345abcde")); |
| 87 | test(S("abcde"), 0, "1234567890", 9, S("123456789abcde")); |
| 88 | test(S("abcde"), 0, "1234567890", 10, S("1234567890abcde")); |
| 89 | test(S("abcde"), 0, "12345678901234567890", 0, S("abcde")); |
| 90 | test(S("abcde"), 0, "12345678901234567890", 1, S("1abcde")); |
| 91 | test(S("abcde"), 0, "12345678901234567890", 10, S("1234567890abcde")); |
| 92 | test(S("abcde"), 0, "12345678901234567890", 19, S("1234567890123456789abcde")); |
| 93 | test(S("abcde"), 0, "12345678901234567890", 20, S("12345678901234567890abcde")); |
| 94 | test(S("abcde"), 1, "", 0, S("abcde")); |
| 95 | test(S("abcde"), 1, "12345", 0, S("abcde")); |
| 96 | test(S("abcde"), 1, "12345", 1, S("a1bcde")); |
| 97 | test(S("abcde"), 1, "12345", 2, S("a12bcde")); |
| 98 | test(S("abcde"), 1, "12345", 4, S("a1234bcde")); |
| 99 | test(S("abcde"), 1, "12345", 5, S("a12345bcde")); |
| 100 | test(S("abcde"), 1, "1234567890", 0, S("abcde")); |
| 101 | test(S("abcde"), 1, "1234567890", 1, S("a1bcde")); |
| 102 | test(S("abcde"), 1, "1234567890", 5, S("a12345bcde")); |
| 103 | test(S("abcde"), 1, "1234567890", 9, S("a123456789bcde")); |
| 104 | test(S("abcde"), 1, "1234567890", 10, S("a1234567890bcde")); |
| 105 | test(S("abcde"), 1, "12345678901234567890", 0, S("abcde")); |
| 106 | test(S("abcde"), 1, "12345678901234567890", 1, S("a1bcde")); |
| 107 | test(S("abcde"), 1, "12345678901234567890", 10, S("a1234567890bcde")); |
| 108 | test(S("abcde"), 1, "12345678901234567890", 19, S("a1234567890123456789bcde")); |
| 109 | test(S("abcde"), 1, "12345678901234567890", 20, S("a12345678901234567890bcde")); |
| 110 | test(S("abcde"), 2, "", 0, S("abcde")); |
| 111 | test(S("abcde"), 2, "12345", 0, S("abcde")); |
| 112 | test(S("abcde"), 2, "12345", 1, S("ab1cde")); |
| 113 | test(S("abcde"), 2, "12345", 2, S("ab12cde")); |
| 114 | test(S("abcde"), 2, "12345", 4, S("ab1234cde")); |
| 115 | test(S("abcde"), 2, "12345", 5, S("ab12345cde")); |
| 116 | test(S("abcde"), 2, "1234567890", 0, S("abcde")); |
| 117 | test(S("abcde"), 2, "1234567890", 1, S("ab1cde")); |
| 118 | test(S("abcde"), 2, "1234567890", 5, S("ab12345cde")); |
| 119 | test(S("abcde"), 2, "1234567890", 9, S("ab123456789cde")); |
| 120 | test(S("abcde"), 2, "1234567890", 10, S("ab1234567890cde")); |
| 121 | test(S("abcde"), 2, "12345678901234567890", 0, S("abcde")); |
| 122 | test(S("abcde"), 2, "12345678901234567890", 1, S("ab1cde")); |
| 123 | test(S("abcde"), 2, "12345678901234567890", 10, S("ab1234567890cde")); |
| 124 | test(S("abcde"), 2, "12345678901234567890", 19, S("ab1234567890123456789cde")); |
| 125 | test(S("abcde"), 2, "12345678901234567890", 20, S("ab12345678901234567890cde")); |
| 126 | test(S("abcde"), 4, "", 0, S("abcde")); |
| 127 | test(S("abcde"), 4, "12345", 0, S("abcde")); |
| 128 | test(S("abcde"), 4, "12345", 1, S("abcd1e")); |
| 129 | test(S("abcde"), 4, "12345", 2, S("abcd12e")); |
| 130 | test(S("abcde"), 4, "12345", 4, S("abcd1234e")); |
| 131 | test(S("abcde"), 4, "12345", 5, S("abcd12345e")); |
| 132 | test(S("abcde"), 4, "1234567890", 0, S("abcde")); |
| 133 | test(S("abcde"), 4, "1234567890", 1, S("abcd1e")); |
| 134 | test(S("abcde"), 4, "1234567890", 5, S("abcd12345e")); |
| 135 | test(S("abcde"), 4, "1234567890", 9, S("abcd123456789e")); |
| 136 | test(S("abcde"), 4, "1234567890", 10, S("abcd1234567890e")); |
| 137 | test(S("abcde"), 4, "12345678901234567890", 0, S("abcde")); |
| 138 | test(S("abcde"), 4, "12345678901234567890", 1, S("abcd1e")); |
| 139 | test(S("abcde"), 4, "12345678901234567890", 10, S("abcd1234567890e")); |
| 140 | test(S("abcde"), 4, "12345678901234567890", 19, S("abcd1234567890123456789e")); |
| 141 | test(S("abcde"), 4, "12345678901234567890", 20, S("abcd12345678901234567890e")); |
| 142 | test(S("abcde"), 5, "", 0, S("abcde")); |
| 143 | test(S("abcde"), 5, "12345", 0, S("abcde")); |
| 144 | test(S("abcde"), 5, "12345", 1, S("abcde1")); |
| 145 | test(S("abcde"), 5, "12345", 2, S("abcde12")); |
| 146 | test(S("abcde"), 5, "12345", 4, S("abcde1234")); |
| 147 | test(S("abcde"), 5, "12345", 5, S("abcde12345")); |
| 148 | test(S("abcde"), 5, "1234567890", 0, S("abcde")); |
| 149 | test(S("abcde"), 5, "1234567890", 1, S("abcde1")); |
| 150 | test(S("abcde"), 5, "1234567890", 5, S("abcde12345")); |
| 151 | test(S("abcde"), 5, "1234567890", 9, S("abcde123456789")); |
| 152 | test(S("abcde"), 5, "1234567890", 10, S("abcde1234567890")); |
| 153 | test(S("abcde"), 5, "12345678901234567890", 0, S("abcde")); |
| 154 | test(S("abcde"), 5, "12345678901234567890", 1, S("abcde1")); |
| 155 | test(S("abcde"), 5, "12345678901234567890", 10, S("abcde1234567890")); |
| 156 | test(S("abcde"), 5, "12345678901234567890", 19, S("abcde1234567890123456789")); |
| 157 | test(S("abcde"), 5, "12345678901234567890", 20, S("abcde12345678901234567890")); |
| 158 | test(S("abcde"), 6, "", 0, S("can't happen")); |
| 159 | test(S("abcde"), 6, "12345", 0, S("can't happen")); |
| 160 | test(S("abcde"), 6, "12345", 1, S("can't happen")); |
| 161 | test(S("abcde"), 6, "12345", 2, S("can't happen")); |
| 162 | test(S("abcde"), 6, "12345", 4, S("can't happen")); |
| 163 | test(S("abcde"), 6, "12345", 5, S("can't happen")); |
| 164 | test(S("abcde"), 6, "1234567890", 0, S("can't happen")); |
| 165 | test(S("abcde"), 6, "1234567890", 1, S("can't happen")); |
| 166 | test(S("abcde"), 6, "1234567890", 5, S("can't happen")); |
| 167 | test(S("abcde"), 6, "1234567890", 9, S("can't happen")); |
| 168 | test(S("abcde"), 6, "1234567890", 10, S("can't happen")); |
| 169 | test(S("abcde"), 6, "12345678901234567890", 0, S("can't happen")); |
| 170 | test(S("abcde"), 6, "12345678901234567890", 1, S("can't happen")); |
| 171 | test(S("abcde"), 6, "12345678901234567890", 10, S("can't happen")); |
| 172 | test(S("abcde"), 6, "12345678901234567890", 19, S("can't happen")); |
| 173 | test(S("abcde"), 6, "12345678901234567890", 20, S("can't happen")); |
| 174 | test(S("abcdefghij"), 0, "", 0, S("abcdefghij")); |
| 175 | test(S("abcdefghij"), 0, "12345", 0, S("abcdefghij")); |
| 176 | test(S("abcdefghij"), 0, "12345", 1, S("1abcdefghij")); |
| 177 | test(S("abcdefghij"), 0, "12345", 2, S("12abcdefghij")); |
| 178 | test(S("abcdefghij"), 0, "12345", 4, S("1234abcdefghij")); |
| 179 | test(S("abcdefghij"), 0, "12345", 5, S("12345abcdefghij")); |
| 180 | test(S("abcdefghij"), 0, "1234567890", 0, S("abcdefghij")); |
| 181 | test(S("abcdefghij"), 0, "1234567890", 1, S("1abcdefghij")); |
| 182 | test(S("abcdefghij"), 0, "1234567890", 5, S("12345abcdefghij")); |
| 183 | test(S("abcdefghij"), 0, "1234567890", 9, S("123456789abcdefghij")); |
| 184 | test(S("abcdefghij"), 0, "1234567890", 10, S("1234567890abcdefghij")); |
| 185 | test(S("abcdefghij"), 0, "12345678901234567890", 0, S("abcdefghij")); |
| 186 | test(S("abcdefghij"), 0, "12345678901234567890", 1, S("1abcdefghij")); |
| 187 | test(S("abcdefghij"), 0, "12345678901234567890", 10, S("1234567890abcdefghij")); |
| 188 | test(S("abcdefghij"), 0, "12345678901234567890", 19, S("1234567890123456789abcdefghij")); |
| 189 | test(S("abcdefghij"), 0, "12345678901234567890", 20, S("12345678901234567890abcdefghij")); |
| 190 | test(S("abcdefghij"), 1, "", 0, S("abcdefghij")); |
| 191 | test(S("abcdefghij"), 1, "12345", 0, S("abcdefghij")); |
| 192 | test(S("abcdefghij"), 1, "12345", 1, S("a1bcdefghij")); |
| 193 | test(S("abcdefghij"), 1, "12345", 2, S("a12bcdefghij")); |
| 194 | test(S("abcdefghij"), 1, "12345", 4, S("a1234bcdefghij")); |
| 195 | test(S("abcdefghij"), 1, "12345", 5, S("a12345bcdefghij")); |
| 196 | test(S("abcdefghij"), 1, "1234567890", 0, S("abcdefghij")); |
| 197 | test(S("abcdefghij"), 1, "1234567890", 1, S("a1bcdefghij")); |
| 198 | test(S("abcdefghij"), 1, "1234567890", 5, S("a12345bcdefghij")); |
| 199 | test(S("abcdefghij"), 1, "1234567890", 9, S("a123456789bcdefghij")); |
| 200 | test(S("abcdefghij"), 1, "1234567890", 10, S("a1234567890bcdefghij")); |
| 201 | test(S("abcdefghij"), 1, "12345678901234567890", 0, S("abcdefghij")); |
| 202 | test(S("abcdefghij"), 1, "12345678901234567890", 1, S("a1bcdefghij")); |
| 203 | test(S("abcdefghij"), 1, "12345678901234567890", 10, S("a1234567890bcdefghij")); |
| 204 | test(S("abcdefghij"), 1, "12345678901234567890", 19, S("a1234567890123456789bcdefghij")); |
| 205 | test(S("abcdefghij"), 1, "12345678901234567890", 20, S("a12345678901234567890bcdefghij")); |
| 206 | test(S("abcdefghij"), 5, "", 0, S("abcdefghij")); |
| 207 | test(S("abcdefghij"), 5, "12345", 0, S("abcdefghij")); |
| 208 | test(S("abcdefghij"), 5, "12345", 1, S("abcde1fghij")); |
| 209 | test(S("abcdefghij"), 5, "12345", 2, S("abcde12fghij")); |
| 210 | test(S("abcdefghij"), 5, "12345", 4, S("abcde1234fghij")); |
| 211 | test(S("abcdefghij"), 5, "12345", 5, S("abcde12345fghij")); |
| 212 | test(S("abcdefghij"), 5, "1234567890", 0, S("abcdefghij")); |
| 213 | test(S("abcdefghij"), 5, "1234567890", 1, S("abcde1fghij")); |
| 214 | test(S("abcdefghij"), 5, "1234567890", 5, S("abcde12345fghij")); |
| 215 | test(S("abcdefghij"), 5, "1234567890", 9, S("abcde123456789fghij")); |
| 216 | test(S("abcdefghij"), 5, "1234567890", 10, S("abcde1234567890fghij")); |
| 217 | test(S("abcdefghij"), 5, "12345678901234567890", 0, S("abcdefghij")); |
| 218 | test(S("abcdefghij"), 5, "12345678901234567890", 1, S("abcde1fghij")); |
| 219 | test(S("abcdefghij"), 5, "12345678901234567890", 10, S("abcde1234567890fghij")); |
| 220 | test(S("abcdefghij"), 5, "12345678901234567890", 19, S("abcde1234567890123456789fghij")); |
| 221 | test(S("abcdefghij"), 5, "12345678901234567890", 20, S("abcde12345678901234567890fghij")); |
| 222 | test(S("abcdefghij"), 9, "", 0, S("abcdefghij")); |
| 223 | test(S("abcdefghij"), 9, "12345", 0, S("abcdefghij")); |
| 224 | test(S("abcdefghij"), 9, "12345", 1, S("abcdefghi1j")); |
| 225 | test(S("abcdefghij"), 9, "12345", 2, S("abcdefghi12j")); |
| 226 | test(S("abcdefghij"), 9, "12345", 4, S("abcdefghi1234j")); |
| 227 | test(S("abcdefghij"), 9, "12345", 5, S("abcdefghi12345j")); |
| 228 | test(S("abcdefghij"), 9, "1234567890", 0, S("abcdefghij")); |
| 229 | test(S("abcdefghij"), 9, "1234567890", 1, S("abcdefghi1j")); |
| 230 | test(S("abcdefghij"), 9, "1234567890", 5, S("abcdefghi12345j")); |
| 231 | test(S("abcdefghij"), 9, "1234567890", 9, S("abcdefghi123456789j")); |
| 232 | test(S("abcdefghij"), 9, "1234567890", 10, S("abcdefghi1234567890j")); |
| 233 | test(S("abcdefghij"), 9, "12345678901234567890", 0, S("abcdefghij")); |
| 234 | test(S("abcdefghij"), 9, "12345678901234567890", 1, S("abcdefghi1j")); |
| 235 | test(S("abcdefghij"), 9, "12345678901234567890", 10, S("abcdefghi1234567890j")); |
| 236 | test(S("abcdefghij"), 9, "12345678901234567890", 19, S("abcdefghi1234567890123456789j")); |
| 237 | test(S("abcdefghij"), 9, "12345678901234567890", 20, S("abcdefghi12345678901234567890j")); |
| 238 | test(S("abcdefghij"), 10, "", 0, S("abcdefghij")); |
| 239 | test(S("abcdefghij"), 10, "12345", 0, S("abcdefghij")); |
| 240 | test(S("abcdefghij"), 10, "12345", 1, S("abcdefghij1")); |
| 241 | test(S("abcdefghij"), 10, "12345", 2, S("abcdefghij12")); |
| 242 | test(S("abcdefghij"), 10, "12345", 4, S("abcdefghij1234")); |
| 243 | test(S("abcdefghij"), 10, "12345", 5, S("abcdefghij12345")); |
| 244 | test(S("abcdefghij"), 10, "1234567890", 0, S("abcdefghij")); |
| 245 | test(S("abcdefghij"), 10, "1234567890", 1, S("abcdefghij1")); |
| 246 | test(S("abcdefghij"), 10, "1234567890", 5, S("abcdefghij12345")); |
| 247 | test(S("abcdefghij"), 10, "1234567890", 9, S("abcdefghij123456789")); |
| 248 | test(S("abcdefghij"), 10, "1234567890", 10, S("abcdefghij1234567890")); |
| 249 | test(S("abcdefghij"), 10, "12345678901234567890", 0, S("abcdefghij")); |
| 250 | test(S("abcdefghij"), 10, "12345678901234567890", 1, S("abcdefghij1")); |
| 251 | test(S("abcdefghij"), 10, "12345678901234567890", 10, S("abcdefghij1234567890")); |
| 252 | test(S("abcdefghij"), 10, "12345678901234567890", 19, S("abcdefghij1234567890123456789")); |
| 253 | test(S("abcdefghij"), 10, "12345678901234567890", 20, S("abcdefghij12345678901234567890")); |
| 254 | test(S("abcdefghij"), 11, "", 0, S("can't happen")); |
| 255 | test(S("abcdefghij"), 11, "12345", 0, S("can't happen")); |
| 256 | test(S("abcdefghij"), 11, "12345", 1, S("can't happen")); |
| 257 | test(S("abcdefghij"), 11, "12345", 2, S("can't happen")); |
| 258 | test(S("abcdefghij"), 11, "12345", 4, S("can't happen")); |
| 259 | test(S("abcdefghij"), 11, "12345", 5, S("can't happen")); |
| 260 | test(S("abcdefghij"), 11, "1234567890", 0, S("can't happen")); |
| 261 | test(S("abcdefghij"), 11, "1234567890", 1, S("can't happen")); |
| 262 | test(S("abcdefghij"), 11, "1234567890", 5, S("can't happen")); |
| 263 | test(S("abcdefghij"), 11, "1234567890", 9, S("can't happen")); |
| 264 | test(S("abcdefghij"), 11, "1234567890", 10, S("can't happen")); |
| 265 | test(S("abcdefghij"), 11, "12345678901234567890", 0, S("can't happen")); |
| 266 | test(S("abcdefghij"), 11, "12345678901234567890", 1, S("can't happen")); |
| 267 | test(S("abcdefghij"), 11, "12345678901234567890", 10, S("can't happen")); |
| 268 | test(S("abcdefghij"), 11, "12345678901234567890", 19, S("can't happen")); |
| 269 | test(S("abcdefghij"), 11, "12345678901234567890", 20, S("can't happen")); |
| 270 | test(S("abcdefghijklmnopqrst"), 0, "", 0, S("abcdefghijklmnopqrst")); |
| 271 | test(S("abcdefghijklmnopqrst"), 0, "12345", 0, S("abcdefghijklmnopqrst")); |
| 272 | test(S("abcdefghijklmnopqrst"), 0, "12345", 1, S("1abcdefghijklmnopqrst")); |
| 273 | test(S("abcdefghijklmnopqrst"), 0, "12345", 2, S("12abcdefghijklmnopqrst")); |
| 274 | test(S("abcdefghijklmnopqrst"), 0, "12345", 4, S("1234abcdefghijklmnopqrst")); |
| 275 | test(S("abcdefghijklmnopqrst"), 0, "12345", 5, S("12345abcdefghijklmnopqrst")); |
| 276 | test(S("abcdefghijklmnopqrst"), 0, "1234567890", 0, S("abcdefghijklmnopqrst")); |
| 277 | test(S("abcdefghijklmnopqrst"), 0, "1234567890", 1, S("1abcdefghijklmnopqrst")); |
| 278 | test(S("abcdefghijklmnopqrst"), 0, "1234567890", 5, S("12345abcdefghijklmnopqrst")); |
| 279 | test(S("abcdefghijklmnopqrst"), 0, "1234567890", 9, S("123456789abcdefghijklmnopqrst")); |
| 280 | test(S("abcdefghijklmnopqrst"), 0, "1234567890", 10, S("1234567890abcdefghijklmnopqrst")); |
| 281 | test(S("abcdefghijklmnopqrst"), 0, "12345678901234567890", 0, S("abcdefghijklmnopqrst")); |
| 282 | test(S("abcdefghijklmnopqrst"), 0, "12345678901234567890", 1, S("1abcdefghijklmnopqrst")); |
| 283 | test(S("abcdefghijklmnopqrst"), 0, "12345678901234567890", 10, S("1234567890abcdefghijklmnopqrst")); |
| 284 | test(S("abcdefghijklmnopqrst"), 0, "12345678901234567890", 19, S("1234567890123456789abcdefghijklmnopqrst")); |
| 285 | test(S("abcdefghijklmnopqrst"), 0, "12345678901234567890", 20, S("12345678901234567890abcdefghijklmnopqrst")); |
| 286 | test(S("abcdefghijklmnopqrst"), 1, "", 0, S("abcdefghijklmnopqrst")); |
| 287 | test(S("abcdefghijklmnopqrst"), 1, "12345", 0, S("abcdefghijklmnopqrst")); |
| 288 | test(S("abcdefghijklmnopqrst"), 1, "12345", 1, S("a1bcdefghijklmnopqrst")); |
| 289 | test(S("abcdefghijklmnopqrst"), 1, "12345", 2, S("a12bcdefghijklmnopqrst")); |
| 290 | test(S("abcdefghijklmnopqrst"), 1, "12345", 4, S("a1234bcdefghijklmnopqrst")); |
| 291 | test(S("abcdefghijklmnopqrst"), 1, "12345", 5, S("a12345bcdefghijklmnopqrst")); |
| 292 | test(S("abcdefghijklmnopqrst"), 1, "1234567890", 0, S("abcdefghijklmnopqrst")); |
| 293 | test(S("abcdefghijklmnopqrst"), 1, "1234567890", 1, S("a1bcdefghijklmnopqrst")); |
| 294 | test(S("abcdefghijklmnopqrst"), 1, "1234567890", 5, S("a12345bcdefghijklmnopqrst")); |
| 295 | test(S("abcdefghijklmnopqrst"), 1, "1234567890", 9, S("a123456789bcdefghijklmnopqrst")); |
| 296 | test(S("abcdefghijklmnopqrst"), 1, "1234567890", 10, S("a1234567890bcdefghijklmnopqrst")); |
| 297 | test(S("abcdefghijklmnopqrst"), 1, "12345678901234567890", 0, S("abcdefghijklmnopqrst")); |
| 298 | test(S("abcdefghijklmnopqrst"), 1, "12345678901234567890", 1, S("a1bcdefghijklmnopqrst")); |
| 299 | test(S("abcdefghijklmnopqrst"), 1, "12345678901234567890", 10, S("a1234567890bcdefghijklmnopqrst")); |
| 300 | test(S("abcdefghijklmnopqrst"), 1, "12345678901234567890", 19, S("a1234567890123456789bcdefghijklmnopqrst")); |
| 301 | test(S("abcdefghijklmnopqrst"), 1, "12345678901234567890", 20, S("a12345678901234567890bcdefghijklmnopqrst")); |
| 302 | test(S("abcdefghijklmnopqrst"), 10, "", 0, S("abcdefghijklmnopqrst")); |
| 303 | test(S("abcdefghijklmnopqrst"), 10, "12345", 0, S("abcdefghijklmnopqrst")); |
| 304 | test(S("abcdefghijklmnopqrst"), 10, "12345", 1, S("abcdefghij1klmnopqrst")); |
| 305 | test(S("abcdefghijklmnopqrst"), 10, "12345", 2, S("abcdefghij12klmnopqrst")); |
| 306 | test(S("abcdefghijklmnopqrst"), 10, "12345", 4, S("abcdefghij1234klmnopqrst")); |
| 307 | test(S("abcdefghijklmnopqrst"), 10, "12345", 5, S("abcdefghij12345klmnopqrst")); |
| 308 | test(S("abcdefghijklmnopqrst"), 10, "1234567890", 0, S("abcdefghijklmnopqrst")); |
| 309 | test(S("abcdefghijklmnopqrst"), 10, "1234567890", 1, S("abcdefghij1klmnopqrst")); |
| 310 | test(S("abcdefghijklmnopqrst"), 10, "1234567890", 5, S("abcdefghij12345klmnopqrst")); |
| 311 | test(S("abcdefghijklmnopqrst"), 10, "1234567890", 9, S("abcdefghij123456789klmnopqrst")); |
| 312 | test(S("abcdefghijklmnopqrst"), 10, "1234567890", 10, S("abcdefghij1234567890klmnopqrst")); |
| 313 | test(S("abcdefghijklmnopqrst"), 10, "12345678901234567890", 0, S("abcdefghijklmnopqrst")); |
| 314 | test(S("abcdefghijklmnopqrst"), 10, "12345678901234567890", 1, S("abcdefghij1klmnopqrst")); |
| 315 | test(S("abcdefghijklmnopqrst"), 10, "12345678901234567890", 10, S("abcdefghij1234567890klmnopqrst")); |
| 316 | test(S("abcdefghijklmnopqrst"), 10, "12345678901234567890", 19, S("abcdefghij1234567890123456789klmnopqrst")); |
| 317 | test(S("abcdefghijklmnopqrst"), 10, "12345678901234567890", 20, S("abcdefghij12345678901234567890klmnopqrst")); |
| 318 | test(S("abcdefghijklmnopqrst"), 19, "", 0, S("abcdefghijklmnopqrst")); |
| 319 | test(S("abcdefghijklmnopqrst"), 19, "12345", 0, S("abcdefghijklmnopqrst")); |
| 320 | test(S("abcdefghijklmnopqrst"), 19, "12345", 1, S("abcdefghijklmnopqrs1t")); |
| 321 | test(S("abcdefghijklmnopqrst"), 19, "12345", 2, S("abcdefghijklmnopqrs12t")); |
| 322 | test(S("abcdefghijklmnopqrst"), 19, "12345", 4, S("abcdefghijklmnopqrs1234t")); |
| 323 | test(S("abcdefghijklmnopqrst"), 19, "12345", 5, S("abcdefghijklmnopqrs12345t")); |
| 324 | test(S("abcdefghijklmnopqrst"), 19, "1234567890", 0, S("abcdefghijklmnopqrst")); |
| 325 | test(S("abcdefghijklmnopqrst"), 19, "1234567890", 1, S("abcdefghijklmnopqrs1t")); |
| 326 | test(S("abcdefghijklmnopqrst"), 19, "1234567890", 5, S("abcdefghijklmnopqrs12345t")); |
| 327 | test(S("abcdefghijklmnopqrst"), 19, "1234567890", 9, S("abcdefghijklmnopqrs123456789t")); |
| 328 | test(S("abcdefghijklmnopqrst"), 19, "1234567890", 10, S("abcdefghijklmnopqrs1234567890t")); |
| 329 | test(S("abcdefghijklmnopqrst"), 19, "12345678901234567890", 0, S("abcdefghijklmnopqrst")); |
| 330 | test(S("abcdefghijklmnopqrst"), 19, "12345678901234567890", 1, S("abcdefghijklmnopqrs1t")); |
| 331 | test(S("abcdefghijklmnopqrst"), 19, "12345678901234567890", 10, S("abcdefghijklmnopqrs1234567890t")); |
| 332 | test(S("abcdefghijklmnopqrst"), 19, "12345678901234567890", 19, S("abcdefghijklmnopqrs1234567890123456789t")); |
| 333 | test(S("abcdefghijklmnopqrst"), 19, "12345678901234567890", 20, S("abcdefghijklmnopqrs12345678901234567890t")); |
| 334 | test(S("abcdefghijklmnopqrst"), 20, "", 0, S("abcdefghijklmnopqrst")); |
| 335 | test(S("abcdefghijklmnopqrst"), 20, "12345", 0, S("abcdefghijklmnopqrst")); |
| 336 | test(S("abcdefghijklmnopqrst"), 20, "12345", 1, S("abcdefghijklmnopqrst1")); |
| 337 | test(S("abcdefghijklmnopqrst"), 20, "12345", 2, S("abcdefghijklmnopqrst12")); |
| 338 | test(S("abcdefghijklmnopqrst"), 20, "12345", 4, S("abcdefghijklmnopqrst1234")); |
| 339 | test(S("abcdefghijklmnopqrst"), 20, "12345", 5, S("abcdefghijklmnopqrst12345")); |
| 340 | test(S("abcdefghijklmnopqrst"), 20, "1234567890", 0, S("abcdefghijklmnopqrst")); |
| 341 | test(S("abcdefghijklmnopqrst"), 20, "1234567890", 1, S("abcdefghijklmnopqrst1")); |
| 342 | test(S("abcdefghijklmnopqrst"), 20, "1234567890", 5, S("abcdefghijklmnopqrst12345")); |
| 343 | test(S("abcdefghijklmnopqrst"), 20, "1234567890", 9, S("abcdefghijklmnopqrst123456789")); |
| 344 | test(S("abcdefghijklmnopqrst"), 20, "1234567890", 10, S("abcdefghijklmnopqrst1234567890")); |
| 345 | test(S("abcdefghijklmnopqrst"), 20, "12345678901234567890", 0, S("abcdefghijklmnopqrst")); |
| 346 | test(S("abcdefghijklmnopqrst"), 20, "12345678901234567890", 1, S("abcdefghijklmnopqrst1")); |
| 347 | test(S("abcdefghijklmnopqrst"), 20, "12345678901234567890", 10, S("abcdefghijklmnopqrst1234567890")); |
| 348 | test(S("abcdefghijklmnopqrst"), 20, "12345678901234567890", 19, S("abcdefghijklmnopqrst1234567890123456789")); |
| 349 | test(S("abcdefghijklmnopqrst"), 20, "12345678901234567890", 20, S("abcdefghijklmnopqrst12345678901234567890")); |
| 350 | test(S("abcdefghijklmnopqrst"), 21, "", 0, S("can't happen")); |
| 351 | test(S("abcdefghijklmnopqrst"), 21, "12345", 0, S("can't happen")); |
| 352 | test(S("abcdefghijklmnopqrst"), 21, "12345", 1, S("can't happen")); |
| 353 | test(S("abcdefghijklmnopqrst"), 21, "12345", 2, S("can't happen")); |
| 354 | test(S("abcdefghijklmnopqrst"), 21, "12345", 4, S("can't happen")); |
| 355 | test(S("abcdefghijklmnopqrst"), 21, "12345", 5, S("can't happen")); |
| 356 | test(S("abcdefghijklmnopqrst"), 21, "1234567890", 0, S("can't happen")); |
| 357 | test(S("abcdefghijklmnopqrst"), 21, "1234567890", 1, S("can't happen")); |
| 358 | test(S("abcdefghijklmnopqrst"), 21, "1234567890", 5, S("can't happen")); |
| 359 | test(S("abcdefghijklmnopqrst"), 21, "1234567890", 9, S("can't happen")); |
| 360 | test(S("abcdefghijklmnopqrst"), 21, "1234567890", 10, S("can't happen")); |
| 361 | test(S("abcdefghijklmnopqrst"), 21, "12345678901234567890", 0, S("can't happen")); |
| 362 | test(S("abcdefghijklmnopqrst"), 21, "12345678901234567890", 1, S("can't happen")); |
| 363 | test(S("abcdefghijklmnopqrst"), 21, "12345678901234567890", 10, S("can't happen")); |
| 364 | test(S("abcdefghijklmnopqrst"), 21, "12345678901234567890", 19, S("can't happen")); |
| 365 | test(S("abcdefghijklmnopqrst"), 21, "12345678901234567890", 20, S("can't happen")); |
Howard Hinnant | 9dcdcde | 2013-06-28 16:59:19 +0000 | [diff] [blame] | 366 | } |
Dan Albert | 1d4a1ed | 2016-05-25 22:36:09 -0700 | [diff] [blame^] | 367 | #if __cplusplus >= 201103L |
Howard Hinnant | 9dcdcde | 2013-06-28 16:59:19 +0000 | [diff] [blame] | 368 | { |
| 369 | typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; |
| 370 | test(S(""), 0, "", 0, S("")); |
| 371 | test(S(""), 0, "12345", 0, S("")); |
| 372 | test(S(""), 0, "12345", 1, S("1")); |
| 373 | test(S(""), 0, "12345", 2, S("12")); |
| 374 | test(S(""), 0, "12345", 4, S("1234")); |
| 375 | test(S(""), 0, "12345", 5, S("12345")); |
| 376 | test(S(""), 0, "1234567890", 0, S("")); |
| 377 | test(S(""), 0, "1234567890", 1, S("1")); |
| 378 | test(S(""), 0, "1234567890", 5, S("12345")); |
| 379 | test(S(""), 0, "1234567890", 9, S("123456789")); |
| 380 | test(S(""), 0, "1234567890", 10, S("1234567890")); |
| 381 | test(S(""), 0, "12345678901234567890", 0, S("")); |
| 382 | test(S(""), 0, "12345678901234567890", 1, S("1")); |
| 383 | test(S(""), 0, "12345678901234567890", 10, S("1234567890")); |
| 384 | test(S(""), 0, "12345678901234567890", 19, S("1234567890123456789")); |
| 385 | test(S(""), 0, "12345678901234567890", 20, S("12345678901234567890")); |
| 386 | test(S(""), 1, "", 0, S("can't happen")); |
| 387 | test(S(""), 1, "12345", 0, S("can't happen")); |
| 388 | test(S(""), 1, "12345", 1, S("can't happen")); |
| 389 | test(S(""), 1, "12345", 2, S("can't happen")); |
| 390 | test(S(""), 1, "12345", 4, S("can't happen")); |
| 391 | test(S(""), 1, "12345", 5, S("can't happen")); |
| 392 | test(S(""), 1, "1234567890", 0, S("can't happen")); |
| 393 | test(S(""), 1, "1234567890", 1, S("can't happen")); |
| 394 | test(S(""), 1, "1234567890", 5, S("can't happen")); |
| 395 | test(S(""), 1, "1234567890", 9, S("can't happen")); |
| 396 | test(S(""), 1, "1234567890", 10, S("can't happen")); |
| 397 | test(S(""), 1, "12345678901234567890", 0, S("can't happen")); |
| 398 | test(S(""), 1, "12345678901234567890", 1, S("can't happen")); |
| 399 | test(S(""), 1, "12345678901234567890", 10, S("can't happen")); |
| 400 | test(S(""), 1, "12345678901234567890", 19, S("can't happen")); |
| 401 | test(S(""), 1, "12345678901234567890", 20, S("can't happen")); |
| 402 | test(S("abcde"), 0, "", 0, S("abcde")); |
| 403 | test(S("abcde"), 0, "12345", 0, S("abcde")); |
| 404 | test(S("abcde"), 0, "12345", 1, S("1abcde")); |
| 405 | test(S("abcde"), 0, "12345", 2, S("12abcde")); |
| 406 | test(S("abcde"), 0, "12345", 4, S("1234abcde")); |
| 407 | test(S("abcde"), 0, "12345", 5, S("12345abcde")); |
| 408 | test(S("abcde"), 0, "1234567890", 0, S("abcde")); |
| 409 | test(S("abcde"), 0, "1234567890", 1, S("1abcde")); |
| 410 | test(S("abcde"), 0, "1234567890", 5, S("12345abcde")); |
| 411 | test(S("abcde"), 0, "1234567890", 9, S("123456789abcde")); |
| 412 | test(S("abcde"), 0, "1234567890", 10, S("1234567890abcde")); |
| 413 | test(S("abcde"), 0, "12345678901234567890", 0, S("abcde")); |
| 414 | test(S("abcde"), 0, "12345678901234567890", 1, S("1abcde")); |
| 415 | test(S("abcde"), 0, "12345678901234567890", 10, S("1234567890abcde")); |
| 416 | test(S("abcde"), 0, "12345678901234567890", 19, S("1234567890123456789abcde")); |
| 417 | test(S("abcde"), 0, "12345678901234567890", 20, S("12345678901234567890abcde")); |
| 418 | test(S("abcde"), 1, "", 0, S("abcde")); |
| 419 | test(S("abcde"), 1, "12345", 0, S("abcde")); |
| 420 | test(S("abcde"), 1, "12345", 1, S("a1bcde")); |
| 421 | test(S("abcde"), 1, "12345", 2, S("a12bcde")); |
| 422 | test(S("abcde"), 1, "12345", 4, S("a1234bcde")); |
| 423 | test(S("abcde"), 1, "12345", 5, S("a12345bcde")); |
| 424 | test(S("abcde"), 1, "1234567890", 0, S("abcde")); |
| 425 | test(S("abcde"), 1, "1234567890", 1, S("a1bcde")); |
| 426 | test(S("abcde"), 1, "1234567890", 5, S("a12345bcde")); |
| 427 | test(S("abcde"), 1, "1234567890", 9, S("a123456789bcde")); |
| 428 | test(S("abcde"), 1, "1234567890", 10, S("a1234567890bcde")); |
| 429 | test(S("abcde"), 1, "12345678901234567890", 0, S("abcde")); |
| 430 | test(S("abcde"), 1, "12345678901234567890", 1, S("a1bcde")); |
| 431 | test(S("abcde"), 1, "12345678901234567890", 10, S("a1234567890bcde")); |
| 432 | test(S("abcde"), 1, "12345678901234567890", 19, S("a1234567890123456789bcde")); |
| 433 | test(S("abcde"), 1, "12345678901234567890", 20, S("a12345678901234567890bcde")); |
| 434 | test(S("abcde"), 2, "", 0, S("abcde")); |
| 435 | test(S("abcde"), 2, "12345", 0, S("abcde")); |
| 436 | test(S("abcde"), 2, "12345", 1, S("ab1cde")); |
| 437 | test(S("abcde"), 2, "12345", 2, S("ab12cde")); |
| 438 | test(S("abcde"), 2, "12345", 4, S("ab1234cde")); |
| 439 | test(S("abcde"), 2, "12345", 5, S("ab12345cde")); |
| 440 | test(S("abcde"), 2, "1234567890", 0, S("abcde")); |
| 441 | test(S("abcde"), 2, "1234567890", 1, S("ab1cde")); |
| 442 | test(S("abcde"), 2, "1234567890", 5, S("ab12345cde")); |
| 443 | test(S("abcde"), 2, "1234567890", 9, S("ab123456789cde")); |
| 444 | test(S("abcde"), 2, "1234567890", 10, S("ab1234567890cde")); |
| 445 | test(S("abcde"), 2, "12345678901234567890", 0, S("abcde")); |
| 446 | test(S("abcde"), 2, "12345678901234567890", 1, S("ab1cde")); |
| 447 | test(S("abcde"), 2, "12345678901234567890", 10, S("ab1234567890cde")); |
| 448 | test(S("abcde"), 2, "12345678901234567890", 19, S("ab1234567890123456789cde")); |
| 449 | test(S("abcde"), 2, "12345678901234567890", 20, S("ab12345678901234567890cde")); |
| 450 | test(S("abcde"), 4, "", 0, S("abcde")); |
| 451 | test(S("abcde"), 4, "12345", 0, S("abcde")); |
| 452 | test(S("abcde"), 4, "12345", 1, S("abcd1e")); |
| 453 | test(S("abcde"), 4, "12345", 2, S("abcd12e")); |
| 454 | test(S("abcde"), 4, "12345", 4, S("abcd1234e")); |
| 455 | test(S("abcde"), 4, "12345", 5, S("abcd12345e")); |
| 456 | test(S("abcde"), 4, "1234567890", 0, S("abcde")); |
| 457 | test(S("abcde"), 4, "1234567890", 1, S("abcd1e")); |
| 458 | test(S("abcde"), 4, "1234567890", 5, S("abcd12345e")); |
| 459 | test(S("abcde"), 4, "1234567890", 9, S("abcd123456789e")); |
| 460 | test(S("abcde"), 4, "1234567890", 10, S("abcd1234567890e")); |
| 461 | test(S("abcde"), 4, "12345678901234567890", 0, S("abcde")); |
| 462 | test(S("abcde"), 4, "12345678901234567890", 1, S("abcd1e")); |
| 463 | test(S("abcde"), 4, "12345678901234567890", 10, S("abcd1234567890e")); |
| 464 | test(S("abcde"), 4, "12345678901234567890", 19, S("abcd1234567890123456789e")); |
| 465 | test(S("abcde"), 4, "12345678901234567890", 20, S("abcd12345678901234567890e")); |
| 466 | test(S("abcde"), 5, "", 0, S("abcde")); |
| 467 | test(S("abcde"), 5, "12345", 0, S("abcde")); |
| 468 | test(S("abcde"), 5, "12345", 1, S("abcde1")); |
| 469 | test(S("abcde"), 5, "12345", 2, S("abcde12")); |
| 470 | test(S("abcde"), 5, "12345", 4, S("abcde1234")); |
| 471 | test(S("abcde"), 5, "12345", 5, S("abcde12345")); |
| 472 | test(S("abcde"), 5, "1234567890", 0, S("abcde")); |
| 473 | test(S("abcde"), 5, "1234567890", 1, S("abcde1")); |
| 474 | test(S("abcde"), 5, "1234567890", 5, S("abcde12345")); |
| 475 | test(S("abcde"), 5, "1234567890", 9, S("abcde123456789")); |
| 476 | test(S("abcde"), 5, "1234567890", 10, S("abcde1234567890")); |
| 477 | test(S("abcde"), 5, "12345678901234567890", 0, S("abcde")); |
| 478 | test(S("abcde"), 5, "12345678901234567890", 1, S("abcde1")); |
| 479 | test(S("abcde"), 5, "12345678901234567890", 10, S("abcde1234567890")); |
| 480 | test(S("abcde"), 5, "12345678901234567890", 19, S("abcde1234567890123456789")); |
| 481 | test(S("abcde"), 5, "12345678901234567890", 20, S("abcde12345678901234567890")); |
| 482 | test(S("abcde"), 6, "", 0, S("can't happen")); |
| 483 | test(S("abcde"), 6, "12345", 0, S("can't happen")); |
| 484 | test(S("abcde"), 6, "12345", 1, S("can't happen")); |
| 485 | test(S("abcde"), 6, "12345", 2, S("can't happen")); |
| 486 | test(S("abcde"), 6, "12345", 4, S("can't happen")); |
| 487 | test(S("abcde"), 6, "12345", 5, S("can't happen")); |
| 488 | test(S("abcde"), 6, "1234567890", 0, S("can't happen")); |
| 489 | test(S("abcde"), 6, "1234567890", 1, S("can't happen")); |
| 490 | test(S("abcde"), 6, "1234567890", 5, S("can't happen")); |
| 491 | test(S("abcde"), 6, "1234567890", 9, S("can't happen")); |
| 492 | test(S("abcde"), 6, "1234567890", 10, S("can't happen")); |
| 493 | test(S("abcde"), 6, "12345678901234567890", 0, S("can't happen")); |
| 494 | test(S("abcde"), 6, "12345678901234567890", 1, S("can't happen")); |
| 495 | test(S("abcde"), 6, "12345678901234567890", 10, S("can't happen")); |
| 496 | test(S("abcde"), 6, "12345678901234567890", 19, S("can't happen")); |
| 497 | test(S("abcde"), 6, "12345678901234567890", 20, S("can't happen")); |
| 498 | test(S("abcdefghij"), 0, "", 0, S("abcdefghij")); |
| 499 | test(S("abcdefghij"), 0, "12345", 0, S("abcdefghij")); |
| 500 | test(S("abcdefghij"), 0, "12345", 1, S("1abcdefghij")); |
| 501 | test(S("abcdefghij"), 0, "12345", 2, S("12abcdefghij")); |
| 502 | test(S("abcdefghij"), 0, "12345", 4, S("1234abcdefghij")); |
| 503 | test(S("abcdefghij"), 0, "12345", 5, S("12345abcdefghij")); |
| 504 | test(S("abcdefghij"), 0, "1234567890", 0, S("abcdefghij")); |
| 505 | test(S("abcdefghij"), 0, "1234567890", 1, S("1abcdefghij")); |
| 506 | test(S("abcdefghij"), 0, "1234567890", 5, S("12345abcdefghij")); |
| 507 | test(S("abcdefghij"), 0, "1234567890", 9, S("123456789abcdefghij")); |
| 508 | test(S("abcdefghij"), 0, "1234567890", 10, S("1234567890abcdefghij")); |
| 509 | test(S("abcdefghij"), 0, "12345678901234567890", 0, S("abcdefghij")); |
| 510 | test(S("abcdefghij"), 0, "12345678901234567890", 1, S("1abcdefghij")); |
| 511 | test(S("abcdefghij"), 0, "12345678901234567890", 10, S("1234567890abcdefghij")); |
| 512 | test(S("abcdefghij"), 0, "12345678901234567890", 19, S("1234567890123456789abcdefghij")); |
| 513 | test(S("abcdefghij"), 0, "12345678901234567890", 20, S("12345678901234567890abcdefghij")); |
| 514 | test(S("abcdefghij"), 1, "", 0, S("abcdefghij")); |
| 515 | test(S("abcdefghij"), 1, "12345", 0, S("abcdefghij")); |
| 516 | test(S("abcdefghij"), 1, "12345", 1, S("a1bcdefghij")); |
| 517 | test(S("abcdefghij"), 1, "12345", 2, S("a12bcdefghij")); |
| 518 | test(S("abcdefghij"), 1, "12345", 4, S("a1234bcdefghij")); |
| 519 | test(S("abcdefghij"), 1, "12345", 5, S("a12345bcdefghij")); |
| 520 | test(S("abcdefghij"), 1, "1234567890", 0, S("abcdefghij")); |
| 521 | test(S("abcdefghij"), 1, "1234567890", 1, S("a1bcdefghij")); |
| 522 | test(S("abcdefghij"), 1, "1234567890", 5, S("a12345bcdefghij")); |
| 523 | test(S("abcdefghij"), 1, "1234567890", 9, S("a123456789bcdefghij")); |
| 524 | test(S("abcdefghij"), 1, "1234567890", 10, S("a1234567890bcdefghij")); |
| 525 | test(S("abcdefghij"), 1, "12345678901234567890", 0, S("abcdefghij")); |
| 526 | test(S("abcdefghij"), 1, "12345678901234567890", 1, S("a1bcdefghij")); |
| 527 | test(S("abcdefghij"), 1, "12345678901234567890", 10, S("a1234567890bcdefghij")); |
| 528 | test(S("abcdefghij"), 1, "12345678901234567890", 19, S("a1234567890123456789bcdefghij")); |
| 529 | test(S("abcdefghij"), 1, "12345678901234567890", 20, S("a12345678901234567890bcdefghij")); |
| 530 | test(S("abcdefghij"), 5, "", 0, S("abcdefghij")); |
| 531 | test(S("abcdefghij"), 5, "12345", 0, S("abcdefghij")); |
| 532 | test(S("abcdefghij"), 5, "12345", 1, S("abcde1fghij")); |
| 533 | test(S("abcdefghij"), 5, "12345", 2, S("abcde12fghij")); |
| 534 | test(S("abcdefghij"), 5, "12345", 4, S("abcde1234fghij")); |
| 535 | test(S("abcdefghij"), 5, "12345", 5, S("abcde12345fghij")); |
| 536 | test(S("abcdefghij"), 5, "1234567890", 0, S("abcdefghij")); |
| 537 | test(S("abcdefghij"), 5, "1234567890", 1, S("abcde1fghij")); |
| 538 | test(S("abcdefghij"), 5, "1234567890", 5, S("abcde12345fghij")); |
| 539 | test(S("abcdefghij"), 5, "1234567890", 9, S("abcde123456789fghij")); |
| 540 | test(S("abcdefghij"), 5, "1234567890", 10, S("abcde1234567890fghij")); |
| 541 | test(S("abcdefghij"), 5, "12345678901234567890", 0, S("abcdefghij")); |
| 542 | test(S("abcdefghij"), 5, "12345678901234567890", 1, S("abcde1fghij")); |
| 543 | test(S("abcdefghij"), 5, "12345678901234567890", 10, S("abcde1234567890fghij")); |
| 544 | test(S("abcdefghij"), 5, "12345678901234567890", 19, S("abcde1234567890123456789fghij")); |
| 545 | test(S("abcdefghij"), 5, "12345678901234567890", 20, S("abcde12345678901234567890fghij")); |
| 546 | test(S("abcdefghij"), 9, "", 0, S("abcdefghij")); |
| 547 | test(S("abcdefghij"), 9, "12345", 0, S("abcdefghij")); |
| 548 | test(S("abcdefghij"), 9, "12345", 1, S("abcdefghi1j")); |
| 549 | test(S("abcdefghij"), 9, "12345", 2, S("abcdefghi12j")); |
| 550 | test(S("abcdefghij"), 9, "12345", 4, S("abcdefghi1234j")); |
| 551 | test(S("abcdefghij"), 9, "12345", 5, S("abcdefghi12345j")); |
| 552 | test(S("abcdefghij"), 9, "1234567890", 0, S("abcdefghij")); |
| 553 | test(S("abcdefghij"), 9, "1234567890", 1, S("abcdefghi1j")); |
| 554 | test(S("abcdefghij"), 9, "1234567890", 5, S("abcdefghi12345j")); |
| 555 | test(S("abcdefghij"), 9, "1234567890", 9, S("abcdefghi123456789j")); |
| 556 | test(S("abcdefghij"), 9, "1234567890", 10, S("abcdefghi1234567890j")); |
| 557 | test(S("abcdefghij"), 9, "12345678901234567890", 0, S("abcdefghij")); |
| 558 | test(S("abcdefghij"), 9, "12345678901234567890", 1, S("abcdefghi1j")); |
| 559 | test(S("abcdefghij"), 9, "12345678901234567890", 10, S("abcdefghi1234567890j")); |
| 560 | test(S("abcdefghij"), 9, "12345678901234567890", 19, S("abcdefghi1234567890123456789j")); |
| 561 | test(S("abcdefghij"), 9, "12345678901234567890", 20, S("abcdefghi12345678901234567890j")); |
| 562 | test(S("abcdefghij"), 10, "", 0, S("abcdefghij")); |
| 563 | test(S("abcdefghij"), 10, "12345", 0, S("abcdefghij")); |
| 564 | test(S("abcdefghij"), 10, "12345", 1, S("abcdefghij1")); |
| 565 | test(S("abcdefghij"), 10, "12345", 2, S("abcdefghij12")); |
| 566 | test(S("abcdefghij"), 10, "12345", 4, S("abcdefghij1234")); |
| 567 | test(S("abcdefghij"), 10, "12345", 5, S("abcdefghij12345")); |
| 568 | test(S("abcdefghij"), 10, "1234567890", 0, S("abcdefghij")); |
| 569 | test(S("abcdefghij"), 10, "1234567890", 1, S("abcdefghij1")); |
| 570 | test(S("abcdefghij"), 10, "1234567890", 5, S("abcdefghij12345")); |
| 571 | test(S("abcdefghij"), 10, "1234567890", 9, S("abcdefghij123456789")); |
| 572 | test(S("abcdefghij"), 10, "1234567890", 10, S("abcdefghij1234567890")); |
| 573 | test(S("abcdefghij"), 10, "12345678901234567890", 0, S("abcdefghij")); |
| 574 | test(S("abcdefghij"), 10, "12345678901234567890", 1, S("abcdefghij1")); |
| 575 | test(S("abcdefghij"), 10, "12345678901234567890", 10, S("abcdefghij1234567890")); |
| 576 | test(S("abcdefghij"), 10, "12345678901234567890", 19, S("abcdefghij1234567890123456789")); |
| 577 | test(S("abcdefghij"), 10, "12345678901234567890", 20, S("abcdefghij12345678901234567890")); |
| 578 | test(S("abcdefghij"), 11, "", 0, S("can't happen")); |
| 579 | test(S("abcdefghij"), 11, "12345", 0, S("can't happen")); |
| 580 | test(S("abcdefghij"), 11, "12345", 1, S("can't happen")); |
| 581 | test(S("abcdefghij"), 11, "12345", 2, S("can't happen")); |
| 582 | test(S("abcdefghij"), 11, "12345", 4, S("can't happen")); |
| 583 | test(S("abcdefghij"), 11, "12345", 5, S("can't happen")); |
| 584 | test(S("abcdefghij"), 11, "1234567890", 0, S("can't happen")); |
| 585 | test(S("abcdefghij"), 11, "1234567890", 1, S("can't happen")); |
| 586 | test(S("abcdefghij"), 11, "1234567890", 5, S("can't happen")); |
| 587 | test(S("abcdefghij"), 11, "1234567890", 9, S("can't happen")); |
| 588 | test(S("abcdefghij"), 11, "1234567890", 10, S("can't happen")); |
| 589 | test(S("abcdefghij"), 11, "12345678901234567890", 0, S("can't happen")); |
| 590 | test(S("abcdefghij"), 11, "12345678901234567890", 1, S("can't happen")); |
| 591 | test(S("abcdefghij"), 11, "12345678901234567890", 10, S("can't happen")); |
| 592 | test(S("abcdefghij"), 11, "12345678901234567890", 19, S("can't happen")); |
| 593 | test(S("abcdefghij"), 11, "12345678901234567890", 20, S("can't happen")); |
| 594 | test(S("abcdefghijklmnopqrst"), 0, "", 0, S("abcdefghijklmnopqrst")); |
| 595 | test(S("abcdefghijklmnopqrst"), 0, "12345", 0, S("abcdefghijklmnopqrst")); |
| 596 | test(S("abcdefghijklmnopqrst"), 0, "12345", 1, S("1abcdefghijklmnopqrst")); |
| 597 | test(S("abcdefghijklmnopqrst"), 0, "12345", 2, S("12abcdefghijklmnopqrst")); |
| 598 | test(S("abcdefghijklmnopqrst"), 0, "12345", 4, S("1234abcdefghijklmnopqrst")); |
| 599 | test(S("abcdefghijklmnopqrst"), 0, "12345", 5, S("12345abcdefghijklmnopqrst")); |
| 600 | test(S("abcdefghijklmnopqrst"), 0, "1234567890", 0, S("abcdefghijklmnopqrst")); |
| 601 | test(S("abcdefghijklmnopqrst"), 0, "1234567890", 1, S("1abcdefghijklmnopqrst")); |
| 602 | test(S("abcdefghijklmnopqrst"), 0, "1234567890", 5, S("12345abcdefghijklmnopqrst")); |
| 603 | test(S("abcdefghijklmnopqrst"), 0, "1234567890", 9, S("123456789abcdefghijklmnopqrst")); |
| 604 | test(S("abcdefghijklmnopqrst"), 0, "1234567890", 10, S("1234567890abcdefghijklmnopqrst")); |
| 605 | test(S("abcdefghijklmnopqrst"), 0, "12345678901234567890", 0, S("abcdefghijklmnopqrst")); |
| 606 | test(S("abcdefghijklmnopqrst"), 0, "12345678901234567890", 1, S("1abcdefghijklmnopqrst")); |
| 607 | test(S("abcdefghijklmnopqrst"), 0, "12345678901234567890", 10, S("1234567890abcdefghijklmnopqrst")); |
| 608 | test(S("abcdefghijklmnopqrst"), 0, "12345678901234567890", 19, S("1234567890123456789abcdefghijklmnopqrst")); |
| 609 | test(S("abcdefghijklmnopqrst"), 0, "12345678901234567890", 20, S("12345678901234567890abcdefghijklmnopqrst")); |
| 610 | test(S("abcdefghijklmnopqrst"), 1, "", 0, S("abcdefghijklmnopqrst")); |
| 611 | test(S("abcdefghijklmnopqrst"), 1, "12345", 0, S("abcdefghijklmnopqrst")); |
| 612 | test(S("abcdefghijklmnopqrst"), 1, "12345", 1, S("a1bcdefghijklmnopqrst")); |
| 613 | test(S("abcdefghijklmnopqrst"), 1, "12345", 2, S("a12bcdefghijklmnopqrst")); |
| 614 | test(S("abcdefghijklmnopqrst"), 1, "12345", 4, S("a1234bcdefghijklmnopqrst")); |
| 615 | test(S("abcdefghijklmnopqrst"), 1, "12345", 5, S("a12345bcdefghijklmnopqrst")); |
| 616 | test(S("abcdefghijklmnopqrst"), 1, "1234567890", 0, S("abcdefghijklmnopqrst")); |
| 617 | test(S("abcdefghijklmnopqrst"), 1, "1234567890", 1, S("a1bcdefghijklmnopqrst")); |
| 618 | test(S("abcdefghijklmnopqrst"), 1, "1234567890", 5, S("a12345bcdefghijklmnopqrst")); |
| 619 | test(S("abcdefghijklmnopqrst"), 1, "1234567890", 9, S("a123456789bcdefghijklmnopqrst")); |
| 620 | test(S("abcdefghijklmnopqrst"), 1, "1234567890", 10, S("a1234567890bcdefghijklmnopqrst")); |
| 621 | test(S("abcdefghijklmnopqrst"), 1, "12345678901234567890", 0, S("abcdefghijklmnopqrst")); |
| 622 | test(S("abcdefghijklmnopqrst"), 1, "12345678901234567890", 1, S("a1bcdefghijklmnopqrst")); |
| 623 | test(S("abcdefghijklmnopqrst"), 1, "12345678901234567890", 10, S("a1234567890bcdefghijklmnopqrst")); |
| 624 | test(S("abcdefghijklmnopqrst"), 1, "12345678901234567890", 19, S("a1234567890123456789bcdefghijklmnopqrst")); |
| 625 | test(S("abcdefghijklmnopqrst"), 1, "12345678901234567890", 20, S("a12345678901234567890bcdefghijklmnopqrst")); |
| 626 | test(S("abcdefghijklmnopqrst"), 10, "", 0, S("abcdefghijklmnopqrst")); |
| 627 | test(S("abcdefghijklmnopqrst"), 10, "12345", 0, S("abcdefghijklmnopqrst")); |
| 628 | test(S("abcdefghijklmnopqrst"), 10, "12345", 1, S("abcdefghij1klmnopqrst")); |
| 629 | test(S("abcdefghijklmnopqrst"), 10, "12345", 2, S("abcdefghij12klmnopqrst")); |
| 630 | test(S("abcdefghijklmnopqrst"), 10, "12345", 4, S("abcdefghij1234klmnopqrst")); |
| 631 | test(S("abcdefghijklmnopqrst"), 10, "12345", 5, S("abcdefghij12345klmnopqrst")); |
| 632 | test(S("abcdefghijklmnopqrst"), 10, "1234567890", 0, S("abcdefghijklmnopqrst")); |
| 633 | test(S("abcdefghijklmnopqrst"), 10, "1234567890", 1, S("abcdefghij1klmnopqrst")); |
| 634 | test(S("abcdefghijklmnopqrst"), 10, "1234567890", 5, S("abcdefghij12345klmnopqrst")); |
| 635 | test(S("abcdefghijklmnopqrst"), 10, "1234567890", 9, S("abcdefghij123456789klmnopqrst")); |
| 636 | test(S("abcdefghijklmnopqrst"), 10, "1234567890", 10, S("abcdefghij1234567890klmnopqrst")); |
| 637 | test(S("abcdefghijklmnopqrst"), 10, "12345678901234567890", 0, S("abcdefghijklmnopqrst")); |
| 638 | test(S("abcdefghijklmnopqrst"), 10, "12345678901234567890", 1, S("abcdefghij1klmnopqrst")); |
| 639 | test(S("abcdefghijklmnopqrst"), 10, "12345678901234567890", 10, S("abcdefghij1234567890klmnopqrst")); |
| 640 | test(S("abcdefghijklmnopqrst"), 10, "12345678901234567890", 19, S("abcdefghij1234567890123456789klmnopqrst")); |
| 641 | test(S("abcdefghijklmnopqrst"), 10, "12345678901234567890", 20, S("abcdefghij12345678901234567890klmnopqrst")); |
| 642 | test(S("abcdefghijklmnopqrst"), 19, "", 0, S("abcdefghijklmnopqrst")); |
| 643 | test(S("abcdefghijklmnopqrst"), 19, "12345", 0, S("abcdefghijklmnopqrst")); |
| 644 | test(S("abcdefghijklmnopqrst"), 19, "12345", 1, S("abcdefghijklmnopqrs1t")); |
| 645 | test(S("abcdefghijklmnopqrst"), 19, "12345", 2, S("abcdefghijklmnopqrs12t")); |
| 646 | test(S("abcdefghijklmnopqrst"), 19, "12345", 4, S("abcdefghijklmnopqrs1234t")); |
| 647 | test(S("abcdefghijklmnopqrst"), 19, "12345", 5, S("abcdefghijklmnopqrs12345t")); |
| 648 | test(S("abcdefghijklmnopqrst"), 19, "1234567890", 0, S("abcdefghijklmnopqrst")); |
| 649 | test(S("abcdefghijklmnopqrst"), 19, "1234567890", 1, S("abcdefghijklmnopqrs1t")); |
| 650 | test(S("abcdefghijklmnopqrst"), 19, "1234567890", 5, S("abcdefghijklmnopqrs12345t")); |
| 651 | test(S("abcdefghijklmnopqrst"), 19, "1234567890", 9, S("abcdefghijklmnopqrs123456789t")); |
| 652 | test(S("abcdefghijklmnopqrst"), 19, "1234567890", 10, S("abcdefghijklmnopqrs1234567890t")); |
| 653 | test(S("abcdefghijklmnopqrst"), 19, "12345678901234567890", 0, S("abcdefghijklmnopqrst")); |
| 654 | test(S("abcdefghijklmnopqrst"), 19, "12345678901234567890", 1, S("abcdefghijklmnopqrs1t")); |
| 655 | test(S("abcdefghijklmnopqrst"), 19, "12345678901234567890", 10, S("abcdefghijklmnopqrs1234567890t")); |
| 656 | test(S("abcdefghijklmnopqrst"), 19, "12345678901234567890", 19, S("abcdefghijklmnopqrs1234567890123456789t")); |
| 657 | test(S("abcdefghijklmnopqrst"), 19, "12345678901234567890", 20, S("abcdefghijklmnopqrs12345678901234567890t")); |
| 658 | test(S("abcdefghijklmnopqrst"), 20, "", 0, S("abcdefghijklmnopqrst")); |
| 659 | test(S("abcdefghijklmnopqrst"), 20, "12345", 0, S("abcdefghijklmnopqrst")); |
| 660 | test(S("abcdefghijklmnopqrst"), 20, "12345", 1, S("abcdefghijklmnopqrst1")); |
| 661 | test(S("abcdefghijklmnopqrst"), 20, "12345", 2, S("abcdefghijklmnopqrst12")); |
| 662 | test(S("abcdefghijklmnopqrst"), 20, "12345", 4, S("abcdefghijklmnopqrst1234")); |
| 663 | test(S("abcdefghijklmnopqrst"), 20, "12345", 5, S("abcdefghijklmnopqrst12345")); |
| 664 | test(S("abcdefghijklmnopqrst"), 20, "1234567890", 0, S("abcdefghijklmnopqrst")); |
| 665 | test(S("abcdefghijklmnopqrst"), 20, "1234567890", 1, S("abcdefghijklmnopqrst1")); |
| 666 | test(S("abcdefghijklmnopqrst"), 20, "1234567890", 5, S("abcdefghijklmnopqrst12345")); |
| 667 | test(S("abcdefghijklmnopqrst"), 20, "1234567890", 9, S("abcdefghijklmnopqrst123456789")); |
| 668 | test(S("abcdefghijklmnopqrst"), 20, "1234567890", 10, S("abcdefghijklmnopqrst1234567890")); |
| 669 | test(S("abcdefghijklmnopqrst"), 20, "12345678901234567890", 0, S("abcdefghijklmnopqrst")); |
| 670 | test(S("abcdefghijklmnopqrst"), 20, "12345678901234567890", 1, S("abcdefghijklmnopqrst1")); |
| 671 | test(S("abcdefghijklmnopqrst"), 20, "12345678901234567890", 10, S("abcdefghijklmnopqrst1234567890")); |
| 672 | test(S("abcdefghijklmnopqrst"), 20, "12345678901234567890", 19, S("abcdefghijklmnopqrst1234567890123456789")); |
| 673 | test(S("abcdefghijklmnopqrst"), 20, "12345678901234567890", 20, S("abcdefghijklmnopqrst12345678901234567890")); |
| 674 | test(S("abcdefghijklmnopqrst"), 21, "", 0, S("can't happen")); |
| 675 | test(S("abcdefghijklmnopqrst"), 21, "12345", 0, S("can't happen")); |
| 676 | test(S("abcdefghijklmnopqrst"), 21, "12345", 1, S("can't happen")); |
| 677 | test(S("abcdefghijklmnopqrst"), 21, "12345", 2, S("can't happen")); |
| 678 | test(S("abcdefghijklmnopqrst"), 21, "12345", 4, S("can't happen")); |
| 679 | test(S("abcdefghijklmnopqrst"), 21, "12345", 5, S("can't happen")); |
| 680 | test(S("abcdefghijklmnopqrst"), 21, "1234567890", 0, S("can't happen")); |
| 681 | test(S("abcdefghijklmnopqrst"), 21, "1234567890", 1, S("can't happen")); |
| 682 | test(S("abcdefghijklmnopqrst"), 21, "1234567890", 5, S("can't happen")); |
| 683 | test(S("abcdefghijklmnopqrst"), 21, "1234567890", 9, S("can't happen")); |
| 684 | test(S("abcdefghijklmnopqrst"), 21, "1234567890", 10, S("can't happen")); |
| 685 | test(S("abcdefghijklmnopqrst"), 21, "12345678901234567890", 0, S("can't happen")); |
| 686 | test(S("abcdefghijklmnopqrst"), 21, "12345678901234567890", 1, S("can't happen")); |
| 687 | test(S("abcdefghijklmnopqrst"), 21, "12345678901234567890", 10, S("can't happen")); |
| 688 | test(S("abcdefghijklmnopqrst"), 21, "12345678901234567890", 19, S("can't happen")); |
| 689 | test(S("abcdefghijklmnopqrst"), 21, "12345678901234567890", 20, S("can't happen")); |
| 690 | } |
| 691 | #endif |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 692 | } |