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