| 1 | // Copyright 2021 Peter Dimov |
| 2 | // Distributed under the Boost Software License, Version 1.0. |
| 3 | // https://www.boost.org/LICENSE_1_0.txt |
| 4 | |
| 5 | #include <boost/core/detail/string_view.hpp> |
| 6 | #include <boost/core/lightweight_test.hpp> |
| 7 | #include <algorithm> |
| 8 | #include <cstddef> |
| 9 | |
| 10 | int main() |
| 11 | { |
| 12 | std::size_t const npos = boost::core::string_view::npos; |
| 13 | |
| 14 | { |
| 15 | boost::core::string_view sv( "" ); |
| 16 | |
| 17 | BOOST_TEST_EQ( sv.find_last_of( boost::core::string_view() ), npos ); |
| 18 | BOOST_TEST_EQ( sv.find_last_of( boost::core::string_view(), 1 ), npos ); |
| 19 | |
| 20 | BOOST_TEST_EQ( sv.find_last_of( boost::core::string_view( "" ) ), npos ); |
| 21 | BOOST_TEST_EQ( sv.find_last_of( boost::core::string_view( "" ), 1 ), npos ); |
| 22 | |
| 23 | BOOST_TEST_EQ( sv.find_last_of( boost::core::string_view( "1" ) ), npos ); |
| 24 | BOOST_TEST_EQ( sv.find_last_of( boost::core::string_view( "1" ), 1 ), npos ); |
| 25 | |
| 26 | BOOST_TEST_EQ( sv.find_last_of( '1' ), npos ); |
| 27 | BOOST_TEST_EQ( sv.find_last_of( '1', 1 ), npos ); |
| 28 | |
| 29 | BOOST_TEST_EQ( sv.find_last_of( "" ), npos ); |
| 30 | BOOST_TEST_EQ( sv.find_last_of( "" , 1 ), npos ); |
| 31 | |
| 32 | BOOST_TEST_EQ( sv.find_last_of( "1" ), npos ); |
| 33 | BOOST_TEST_EQ( sv.find_last_of( "1" , 1 ), npos ); |
| 34 | |
| 35 | BOOST_TEST_EQ( sv.find_last_of( "12" , 0, 0 ), npos ); |
| 36 | BOOST_TEST_EQ( sv.find_last_of( "12" , 1, 0 ), npos ); |
| 37 | |
| 38 | BOOST_TEST_EQ( sv.find_last_of( "12" , 0, 1 ), npos ); |
| 39 | BOOST_TEST_EQ( sv.find_last_of( "12" , 1, 1 ), npos ); |
| 40 | |
| 41 | BOOST_TEST_EQ( sv.find_last_of( "12" , 0, 2 ), npos ); |
| 42 | BOOST_TEST_EQ( sv.find_last_of( "12" , 1, 2 ), npos ); |
| 43 | } |
| 44 | |
| 45 | { |
| 46 | boost::core::wstring_view sv( L"" ); |
| 47 | |
| 48 | BOOST_TEST_EQ( sv.find_last_of( boost::core::wstring_view() ), npos ); |
| 49 | BOOST_TEST_EQ( sv.find_last_of( boost::core::wstring_view(), 1 ), npos ); |
| 50 | |
| 51 | BOOST_TEST_EQ( sv.find_last_of( boost::core::wstring_view( L"" ) ), npos ); |
| 52 | BOOST_TEST_EQ( sv.find_last_of( boost::core::wstring_view( L"" ), 1 ), npos ); |
| 53 | |
| 54 | BOOST_TEST_EQ( sv.find_last_of( boost::core::wstring_view( L"1" ) ), npos ); |
| 55 | BOOST_TEST_EQ( sv.find_last_of( boost::core::wstring_view( L"1" ), 1 ), npos ); |
| 56 | |
| 57 | BOOST_TEST_EQ( sv.find_last_of( L'1' ), npos ); |
| 58 | BOOST_TEST_EQ( sv.find_last_of( L'1', 1 ), npos ); |
| 59 | |
| 60 | BOOST_TEST_EQ( sv.find_last_of( L"" ), npos ); |
| 61 | BOOST_TEST_EQ( sv.find_last_of( L"" , 1 ), npos ); |
| 62 | |
| 63 | BOOST_TEST_EQ( sv.find_last_of( L"1" ), npos ); |
| 64 | BOOST_TEST_EQ( sv.find_last_of( L"1" , 1 ), npos ); |
| 65 | |
| 66 | BOOST_TEST_EQ( sv.find_last_of( L"12" , 0, 0 ), npos ); |
| 67 | BOOST_TEST_EQ( sv.find_last_of( L"12" , 1, 0 ), npos ); |
| 68 | |
| 69 | BOOST_TEST_EQ( sv.find_last_of( L"12" , 0, 1 ), npos ); |
| 70 | BOOST_TEST_EQ( sv.find_last_of( L"12" , 1, 1 ), npos ); |
| 71 | |
| 72 | BOOST_TEST_EQ( sv.find_last_of( L"12" , 0, 2 ), npos ); |
| 73 | BOOST_TEST_EQ( sv.find_last_of( L"12" , 1, 2 ), npos ); |
| 74 | } |
| 75 | |
| 76 | { |
| 77 | boost::core::string_view sv( "123123" ); |
| 78 | |
| 79 | BOOST_TEST_EQ( sv.find_last_of( boost::core::string_view(), 0 ), npos ); |
| 80 | BOOST_TEST_EQ( sv.find_last_of( boost::core::string_view(), 1 ), npos ); |
| 81 | BOOST_TEST_EQ( sv.find_last_of( boost::core::string_view(), 6 ), npos ); |
| 82 | BOOST_TEST_EQ( sv.find_last_of( boost::core::string_view(), 7 ), npos ); |
| 83 | BOOST_TEST_EQ( sv.find_last_of( boost::core::string_view() ), npos ); |
| 84 | |
| 85 | BOOST_TEST_EQ( sv.find_last_of( boost::core::string_view( "" ) ), npos ); |
| 86 | BOOST_TEST_EQ( sv.find_last_of( boost::core::string_view( "" ), 1 ), npos ); |
| 87 | BOOST_TEST_EQ( sv.find_last_of( boost::core::string_view( "" ), 6 ), npos ); |
| 88 | BOOST_TEST_EQ( sv.find_last_of( boost::core::string_view( "" ), 7 ), npos ); |
| 89 | |
| 90 | BOOST_TEST_EQ( sv.find_last_of( boost::core::string_view( "1" ), 0 ), 0 ); |
| 91 | BOOST_TEST_EQ( sv.find_last_of( boost::core::string_view( "1" ), 1 ), 0 ); |
| 92 | BOOST_TEST_EQ( sv.find_last_of( boost::core::string_view( "1" ), 2 ), 0 ); |
| 93 | BOOST_TEST_EQ( sv.find_last_of( boost::core::string_view( "1" ), 3 ), 3 ); |
| 94 | BOOST_TEST_EQ( sv.find_last_of( boost::core::string_view( "1" ), 4 ), 3 ); |
| 95 | BOOST_TEST_EQ( sv.find_last_of( boost::core::string_view( "1" ), 5 ), 3 ); |
| 96 | BOOST_TEST_EQ( sv.find_last_of( boost::core::string_view( "1" ), 6 ), 3 ); |
| 97 | BOOST_TEST_EQ( sv.find_last_of( boost::core::string_view( "1" ), 7 ), 3 ); |
| 98 | BOOST_TEST_EQ( sv.find_last_of( boost::core::string_view( "1" ) ), 3 ); |
| 99 | |
| 100 | BOOST_TEST_EQ( sv.find_last_of( boost::core::string_view( "4" ), 0 ), npos ); |
| 101 | BOOST_TEST_EQ( sv.find_last_of( boost::core::string_view( "4" ), 1 ), npos ); |
| 102 | BOOST_TEST_EQ( sv.find_last_of( boost::core::string_view( "4" ), 6 ), npos ); |
| 103 | BOOST_TEST_EQ( sv.find_last_of( boost::core::string_view( "4" ), 7 ), npos ); |
| 104 | BOOST_TEST_EQ( sv.find_last_of( boost::core::string_view( "4" ) ), npos ); |
| 105 | |
| 106 | BOOST_TEST_EQ( sv.find_last_of( boost::core::string_view( "23" ), 0 ), npos ); |
| 107 | BOOST_TEST_EQ( sv.find_last_of( boost::core::string_view( "23" ), 1 ), 1 ); |
| 108 | BOOST_TEST_EQ( sv.find_last_of( boost::core::string_view( "23" ), 2 ), 2 ); |
| 109 | BOOST_TEST_EQ( sv.find_last_of( boost::core::string_view( "23" ), 3 ), 2 ); |
| 110 | BOOST_TEST_EQ( sv.find_last_of( boost::core::string_view( "23" ), 4 ), 4 ); |
| 111 | BOOST_TEST_EQ( sv.find_last_of( boost::core::string_view( "23" ), 5 ), 5 ); |
| 112 | BOOST_TEST_EQ( sv.find_last_of( boost::core::string_view( "23" ), 6 ), 5 ); |
| 113 | BOOST_TEST_EQ( sv.find_last_of( boost::core::string_view( "23" ), 7 ), 5 ); |
| 114 | BOOST_TEST_EQ( sv.find_last_of( boost::core::string_view( "23" ) ), 5 ); |
| 115 | |
| 116 | BOOST_TEST_EQ( sv.find_last_of( '1', 0 ), 0 ); |
| 117 | BOOST_TEST_EQ( sv.find_last_of( '1', 1 ), 0 ); |
| 118 | BOOST_TEST_EQ( sv.find_last_of( '1', 2 ), 0 ); |
| 119 | BOOST_TEST_EQ( sv.find_last_of( '1', 3 ), 3 ); |
| 120 | BOOST_TEST_EQ( sv.find_last_of( '1', 4 ), 3 ); |
| 121 | BOOST_TEST_EQ( sv.find_last_of( '1', 5 ), 3 ); |
| 122 | BOOST_TEST_EQ( sv.find_last_of( '1', 6 ), 3 ); |
| 123 | BOOST_TEST_EQ( sv.find_last_of( '1', 7 ), 3 ); |
| 124 | BOOST_TEST_EQ( sv.find_last_of( '1' ), 3 ); |
| 125 | |
| 126 | BOOST_TEST_EQ( sv.find_last_of( '3', 0 ), npos ); |
| 127 | BOOST_TEST_EQ( sv.find_last_of( '3', 1 ), npos ); |
| 128 | BOOST_TEST_EQ( sv.find_last_of( '3', 2 ), 2 ); |
| 129 | BOOST_TEST_EQ( sv.find_last_of( '3', 3 ), 2 ); |
| 130 | BOOST_TEST_EQ( sv.find_last_of( '3', 4 ), 2 ); |
| 131 | BOOST_TEST_EQ( sv.find_last_of( '3', 5 ), 5 ); |
| 132 | BOOST_TEST_EQ( sv.find_last_of( '3', 6 ), 5 ); |
| 133 | BOOST_TEST_EQ( sv.find_last_of( '3', 7 ), 5 ); |
| 134 | BOOST_TEST_EQ( sv.find_last_of( '3' ), 5 ); |
| 135 | |
| 136 | BOOST_TEST_EQ( sv.find_last_of( '9' ), npos ); |
| 137 | |
| 138 | BOOST_TEST_EQ( sv.find_last_of( "" , 0 ), npos ); |
| 139 | BOOST_TEST_EQ( sv.find_last_of( "" , 1 ), npos ); |
| 140 | BOOST_TEST_EQ( sv.find_last_of( "" , 6 ), npos ); |
| 141 | BOOST_TEST_EQ( sv.find_last_of( "" , 7 ), npos ); |
| 142 | BOOST_TEST_EQ( sv.find_last_of( "" ), npos ); |
| 143 | |
| 144 | BOOST_TEST_EQ( sv.find_last_of( "1" , 0 ), 0 ); |
| 145 | BOOST_TEST_EQ( sv.find_last_of( "1" , 1 ), 0 ); |
| 146 | BOOST_TEST_EQ( sv.find_last_of( "1" , 2 ), 0 ); |
| 147 | BOOST_TEST_EQ( sv.find_last_of( "1" , 3 ), 3 ); |
| 148 | BOOST_TEST_EQ( sv.find_last_of( "1" , 4 ), 3 ); |
| 149 | BOOST_TEST_EQ( sv.find_last_of( "1" , 5 ), 3 ); |
| 150 | BOOST_TEST_EQ( sv.find_last_of( "1" , 6 ), 3 ); |
| 151 | BOOST_TEST_EQ( sv.find_last_of( "1" , 7 ), 3 ); |
| 152 | BOOST_TEST_EQ( sv.find_last_of( "1" ), 3 ); |
| 153 | |
| 154 | BOOST_TEST_EQ( sv.find_last_of( "23" , 0 ), npos ); |
| 155 | BOOST_TEST_EQ( sv.find_last_of( "23" , 1 ), 1 ); |
| 156 | BOOST_TEST_EQ( sv.find_last_of( "23" , 2 ), 2 ); |
| 157 | BOOST_TEST_EQ( sv.find_last_of( "23" , 3 ), 2 ); |
| 158 | BOOST_TEST_EQ( sv.find_last_of( "23" , 4 ), 4 ); |
| 159 | BOOST_TEST_EQ( sv.find_last_of( "23" , 5 ), 5 ); |
| 160 | BOOST_TEST_EQ( sv.find_last_of( "23" , 6 ), 5 ); |
| 161 | BOOST_TEST_EQ( sv.find_last_of( "23" , 7 ), 5 ); |
| 162 | BOOST_TEST_EQ( sv.find_last_of( "23" ), 5 ); |
| 163 | |
| 164 | BOOST_TEST_EQ( sv.find_last_of( "123" , 0, 0 ), npos ); |
| 165 | BOOST_TEST_EQ( sv.find_last_of( "123" , 1, 0 ), npos ); |
| 166 | BOOST_TEST_EQ( sv.find_last_of( "123" , 2, 0 ), npos ); |
| 167 | BOOST_TEST_EQ( sv.find_last_of( "123" , 3, 0 ), npos ); |
| 168 | BOOST_TEST_EQ( sv.find_last_of( "123" , 4, 0 ), npos ); |
| 169 | BOOST_TEST_EQ( sv.find_last_of( "123" , 5, 0 ), npos ); |
| 170 | BOOST_TEST_EQ( sv.find_last_of( "123" , 6, 0 ), npos ); |
| 171 | BOOST_TEST_EQ( sv.find_last_of( "123" , 7, 0 ), npos ); |
| 172 | |
| 173 | BOOST_TEST_EQ( sv.find_last_of( "123" , 0, 1 ), 0 ); |
| 174 | BOOST_TEST_EQ( sv.find_last_of( "123" , 1, 1 ), 0 ); |
| 175 | BOOST_TEST_EQ( sv.find_last_of( "123" , 2, 1 ), 0 ); |
| 176 | BOOST_TEST_EQ( sv.find_last_of( "123" , 3, 1 ), 3 ); |
| 177 | BOOST_TEST_EQ( sv.find_last_of( "123" , 4, 1 ), 3 ); |
| 178 | BOOST_TEST_EQ( sv.find_last_of( "123" , 5, 1 ), 3 ); |
| 179 | BOOST_TEST_EQ( sv.find_last_of( "123" , 6, 1 ), 3 ); |
| 180 | BOOST_TEST_EQ( sv.find_last_of( "123" , 7, 1 ), 3 ); |
| 181 | |
| 182 | BOOST_TEST_EQ( sv.find_last_of( "123" , 0, 2 ), 0 ); |
| 183 | BOOST_TEST_EQ( sv.find_last_of( "123" , 1, 2 ), 1 ); |
| 184 | BOOST_TEST_EQ( sv.find_last_of( "123" , 2, 2 ), 1 ); |
| 185 | BOOST_TEST_EQ( sv.find_last_of( "123" , 3, 2 ), 3 ); |
| 186 | BOOST_TEST_EQ( sv.find_last_of( "123" , 4, 2 ), 4 ); |
| 187 | BOOST_TEST_EQ( sv.find_last_of( "123" , 5, 2 ), 4 ); |
| 188 | BOOST_TEST_EQ( sv.find_last_of( "123" , 6, 2 ), 4 ); |
| 189 | BOOST_TEST_EQ( sv.find_last_of( "123" , 7, 2 ), 4 ); |
| 190 | |
| 191 | BOOST_TEST_EQ( sv.find_last_of( "123" , 0, 3 ), 0 ); |
| 192 | BOOST_TEST_EQ( sv.find_last_of( "123" , 1, 3 ), 1 ); |
| 193 | BOOST_TEST_EQ( sv.find_last_of( "123" , 2, 3 ), 2 ); |
| 194 | BOOST_TEST_EQ( sv.find_last_of( "123" , 3, 3 ), 3 ); |
| 195 | BOOST_TEST_EQ( sv.find_last_of( "123" , 4, 3 ), 4 ); |
| 196 | BOOST_TEST_EQ( sv.find_last_of( "123" , 5, 3 ), 5 ); |
| 197 | BOOST_TEST_EQ( sv.find_last_of( "123" , 6, 3 ), 5 ); |
| 198 | BOOST_TEST_EQ( sv.find_last_of( "123" , 7, 3 ), 5 ); |
| 199 | } |
| 200 | |
| 201 | { |
| 202 | boost::core::wstring_view sv( L"123123" ); |
| 203 | |
| 204 | BOOST_TEST_EQ( sv.find_last_of( boost::core::wstring_view(), 0 ), npos ); |
| 205 | BOOST_TEST_EQ( sv.find_last_of( boost::core::wstring_view(), 1 ), npos ); |
| 206 | BOOST_TEST_EQ( sv.find_last_of( boost::core::wstring_view(), 6 ), npos ); |
| 207 | BOOST_TEST_EQ( sv.find_last_of( boost::core::wstring_view(), 7 ), npos ); |
| 208 | BOOST_TEST_EQ( sv.find_last_of( boost::core::wstring_view() ), npos ); |
| 209 | |
| 210 | BOOST_TEST_EQ( sv.find_last_of( boost::core::wstring_view( L"" ) ), npos ); |
| 211 | BOOST_TEST_EQ( sv.find_last_of( boost::core::wstring_view( L"" ), 1 ), npos ); |
| 212 | BOOST_TEST_EQ( sv.find_last_of( boost::core::wstring_view( L"" ), 6 ), npos ); |
| 213 | BOOST_TEST_EQ( sv.find_last_of( boost::core::wstring_view( L"" ), 7 ), npos ); |
| 214 | |
| 215 | BOOST_TEST_EQ( sv.find_last_of( boost::core::wstring_view( L"1" ), 0 ), 0 ); |
| 216 | BOOST_TEST_EQ( sv.find_last_of( boost::core::wstring_view( L"1" ), 1 ), 0 ); |
| 217 | BOOST_TEST_EQ( sv.find_last_of( boost::core::wstring_view( L"1" ), 2 ), 0 ); |
| 218 | BOOST_TEST_EQ( sv.find_last_of( boost::core::wstring_view( L"1" ), 3 ), 3 ); |
| 219 | BOOST_TEST_EQ( sv.find_last_of( boost::core::wstring_view( L"1" ), 4 ), 3 ); |
| 220 | BOOST_TEST_EQ( sv.find_last_of( boost::core::wstring_view( L"1" ), 5 ), 3 ); |
| 221 | BOOST_TEST_EQ( sv.find_last_of( boost::core::wstring_view( L"1" ), 6 ), 3 ); |
| 222 | BOOST_TEST_EQ( sv.find_last_of( boost::core::wstring_view( L"1" ), 7 ), 3 ); |
| 223 | BOOST_TEST_EQ( sv.find_last_of( boost::core::wstring_view( L"1" ) ), 3 ); |
| 224 | |
| 225 | BOOST_TEST_EQ( sv.find_last_of( boost::core::wstring_view( L"4" ), 0 ), npos ); |
| 226 | BOOST_TEST_EQ( sv.find_last_of( boost::core::wstring_view( L"4" ), 1 ), npos ); |
| 227 | BOOST_TEST_EQ( sv.find_last_of( boost::core::wstring_view( L"4" ), 6 ), npos ); |
| 228 | BOOST_TEST_EQ( sv.find_last_of( boost::core::wstring_view( L"4" ), 7 ), npos ); |
| 229 | BOOST_TEST_EQ( sv.find_last_of( boost::core::wstring_view( L"4" ) ), npos ); |
| 230 | |
| 231 | BOOST_TEST_EQ( sv.find_last_of( boost::core::wstring_view( L"23" ), 0 ), npos ); |
| 232 | BOOST_TEST_EQ( sv.find_last_of( boost::core::wstring_view( L"23" ), 1 ), 1 ); |
| 233 | BOOST_TEST_EQ( sv.find_last_of( boost::core::wstring_view( L"23" ), 2 ), 2 ); |
| 234 | BOOST_TEST_EQ( sv.find_last_of( boost::core::wstring_view( L"23" ), 3 ), 2 ); |
| 235 | BOOST_TEST_EQ( sv.find_last_of( boost::core::wstring_view( L"23" ), 4 ), 4 ); |
| 236 | BOOST_TEST_EQ( sv.find_last_of( boost::core::wstring_view( L"23" ), 5 ), 5 ); |
| 237 | BOOST_TEST_EQ( sv.find_last_of( boost::core::wstring_view( L"23" ), 6 ), 5 ); |
| 238 | BOOST_TEST_EQ( sv.find_last_of( boost::core::wstring_view( L"23" ), 7 ), 5 ); |
| 239 | BOOST_TEST_EQ( sv.find_last_of( boost::core::wstring_view( L"23" ) ), 5 ); |
| 240 | |
| 241 | BOOST_TEST_EQ( sv.find_last_of( L'1', 0 ), 0 ); |
| 242 | BOOST_TEST_EQ( sv.find_last_of( L'1', 1 ), 0 ); |
| 243 | BOOST_TEST_EQ( sv.find_last_of( L'1', 2 ), 0 ); |
| 244 | BOOST_TEST_EQ( sv.find_last_of( L'1', 3 ), 3 ); |
| 245 | BOOST_TEST_EQ( sv.find_last_of( L'1', 4 ), 3 ); |
| 246 | BOOST_TEST_EQ( sv.find_last_of( L'1', 5 ), 3 ); |
| 247 | BOOST_TEST_EQ( sv.find_last_of( L'1', 6 ), 3 ); |
| 248 | BOOST_TEST_EQ( sv.find_last_of( L'1', 7 ), 3 ); |
| 249 | BOOST_TEST_EQ( sv.find_last_of( L'1' ), 3 ); |
| 250 | |
| 251 | BOOST_TEST_EQ( sv.find_last_of( L'3', 0 ), npos ); |
| 252 | BOOST_TEST_EQ( sv.find_last_of( L'3', 1 ), npos ); |
| 253 | BOOST_TEST_EQ( sv.find_last_of( L'3', 2 ), 2 ); |
| 254 | BOOST_TEST_EQ( sv.find_last_of( L'3', 3 ), 2 ); |
| 255 | BOOST_TEST_EQ( sv.find_last_of( L'3', 4 ), 2 ); |
| 256 | BOOST_TEST_EQ( sv.find_last_of( L'3', 5 ), 5 ); |
| 257 | BOOST_TEST_EQ( sv.find_last_of( L'3', 6 ), 5 ); |
| 258 | BOOST_TEST_EQ( sv.find_last_of( L'3', 7 ), 5 ); |
| 259 | BOOST_TEST_EQ( sv.find_last_of( L'3' ), 5 ); |
| 260 | |
| 261 | BOOST_TEST_EQ( sv.find_last_of( L'9' ), npos ); |
| 262 | |
| 263 | BOOST_TEST_EQ( sv.find_last_of( L"" , 0 ), npos ); |
| 264 | BOOST_TEST_EQ( sv.find_last_of( L"" , 1 ), npos ); |
| 265 | BOOST_TEST_EQ( sv.find_last_of( L"" , 6 ), npos ); |
| 266 | BOOST_TEST_EQ( sv.find_last_of( L"" , 7 ), npos ); |
| 267 | BOOST_TEST_EQ( sv.find_last_of( L"" ), npos ); |
| 268 | |
| 269 | BOOST_TEST_EQ( sv.find_last_of( L"1" , 0 ), 0 ); |
| 270 | BOOST_TEST_EQ( sv.find_last_of( L"1" , 1 ), 0 ); |
| 271 | BOOST_TEST_EQ( sv.find_last_of( L"1" , 2 ), 0 ); |
| 272 | BOOST_TEST_EQ( sv.find_last_of( L"1" , 3 ), 3 ); |
| 273 | BOOST_TEST_EQ( sv.find_last_of( L"1" , 4 ), 3 ); |
| 274 | BOOST_TEST_EQ( sv.find_last_of( L"1" , 5 ), 3 ); |
| 275 | BOOST_TEST_EQ( sv.find_last_of( L"1" , 6 ), 3 ); |
| 276 | BOOST_TEST_EQ( sv.find_last_of( L"1" , 7 ), 3 ); |
| 277 | BOOST_TEST_EQ( sv.find_last_of( L"1" ), 3 ); |
| 278 | |
| 279 | BOOST_TEST_EQ( sv.find_last_of( L"23" , 0 ), npos ); |
| 280 | BOOST_TEST_EQ( sv.find_last_of( L"23" , 1 ), 1 ); |
| 281 | BOOST_TEST_EQ( sv.find_last_of( L"23" , 2 ), 2 ); |
| 282 | BOOST_TEST_EQ( sv.find_last_of( L"23" , 3 ), 2 ); |
| 283 | BOOST_TEST_EQ( sv.find_last_of( L"23" , 4 ), 4 ); |
| 284 | BOOST_TEST_EQ( sv.find_last_of( L"23" , 5 ), 5 ); |
| 285 | BOOST_TEST_EQ( sv.find_last_of( L"23" , 6 ), 5 ); |
| 286 | BOOST_TEST_EQ( sv.find_last_of( L"23" , 7 ), 5 ); |
| 287 | BOOST_TEST_EQ( sv.find_last_of( L"23" ), 5 ); |
| 288 | |
| 289 | BOOST_TEST_EQ( sv.find_last_of( L"123" , 0, 0 ), npos ); |
| 290 | BOOST_TEST_EQ( sv.find_last_of( L"123" , 1, 0 ), npos ); |
| 291 | BOOST_TEST_EQ( sv.find_last_of( L"123" , 2, 0 ), npos ); |
| 292 | BOOST_TEST_EQ( sv.find_last_of( L"123" , 3, 0 ), npos ); |
| 293 | BOOST_TEST_EQ( sv.find_last_of( L"123" , 4, 0 ), npos ); |
| 294 | BOOST_TEST_EQ( sv.find_last_of( L"123" , 5, 0 ), npos ); |
| 295 | BOOST_TEST_EQ( sv.find_last_of( L"123" , 6, 0 ), npos ); |
| 296 | BOOST_TEST_EQ( sv.find_last_of( L"123" , 7, 0 ), npos ); |
| 297 | |
| 298 | BOOST_TEST_EQ( sv.find_last_of( L"123" , 0, 1 ), 0 ); |
| 299 | BOOST_TEST_EQ( sv.find_last_of( L"123" , 1, 1 ), 0 ); |
| 300 | BOOST_TEST_EQ( sv.find_last_of( L"123" , 2, 1 ), 0 ); |
| 301 | BOOST_TEST_EQ( sv.find_last_of( L"123" , 3, 1 ), 3 ); |
| 302 | BOOST_TEST_EQ( sv.find_last_of( L"123" , 4, 1 ), 3 ); |
| 303 | BOOST_TEST_EQ( sv.find_last_of( L"123" , 5, 1 ), 3 ); |
| 304 | BOOST_TEST_EQ( sv.find_last_of( L"123" , 6, 1 ), 3 ); |
| 305 | BOOST_TEST_EQ( sv.find_last_of( L"123" , 7, 1 ), 3 ); |
| 306 | |
| 307 | BOOST_TEST_EQ( sv.find_last_of( L"123" , 0, 2 ), 0 ); |
| 308 | BOOST_TEST_EQ( sv.find_last_of( L"123" , 1, 2 ), 1 ); |
| 309 | BOOST_TEST_EQ( sv.find_last_of( L"123" , 2, 2 ), 1 ); |
| 310 | BOOST_TEST_EQ( sv.find_last_of( L"123" , 3, 2 ), 3 ); |
| 311 | BOOST_TEST_EQ( sv.find_last_of( L"123" , 4, 2 ), 4 ); |
| 312 | BOOST_TEST_EQ( sv.find_last_of( L"123" , 5, 2 ), 4 ); |
| 313 | BOOST_TEST_EQ( sv.find_last_of( L"123" , 6, 2 ), 4 ); |
| 314 | BOOST_TEST_EQ( sv.find_last_of( L"123" , 7, 2 ), 4 ); |
| 315 | |
| 316 | BOOST_TEST_EQ( sv.find_last_of( L"123" , 0, 3 ), 0 ); |
| 317 | BOOST_TEST_EQ( sv.find_last_of( L"123" , 1, 3 ), 1 ); |
| 318 | BOOST_TEST_EQ( sv.find_last_of( L"123" , 2, 3 ), 2 ); |
| 319 | BOOST_TEST_EQ( sv.find_last_of( L"123" , 3, 3 ), 3 ); |
| 320 | BOOST_TEST_EQ( sv.find_last_of( L"123" , 4, 3 ), 4 ); |
| 321 | BOOST_TEST_EQ( sv.find_last_of( L"123" , 5, 3 ), 5 ); |
| 322 | BOOST_TEST_EQ( sv.find_last_of( L"123" , 6, 3 ), 5 ); |
| 323 | BOOST_TEST_EQ( sv.find_last_of( L"123" , 7, 3 ), 5 ); |
| 324 | } |
| 325 | |
| 326 | { |
| 327 | boost::core::wstring_view sv( L"\x101\x102\x103\x101\x102\x103" ); |
| 328 | |
| 329 | BOOST_TEST_EQ( sv.find_last_of( L"\x101\x102\x103" , 0, 0 ), npos ); |
| 330 | BOOST_TEST_EQ( sv.find_last_of( L"\x101\x102\x103" , 1, 0 ), npos ); |
| 331 | BOOST_TEST_EQ( sv.find_last_of( L"\x101\x102\x103" , 2, 0 ), npos ); |
| 332 | BOOST_TEST_EQ( sv.find_last_of( L"\x101\x102\x103" , 3, 0 ), npos ); |
| 333 | BOOST_TEST_EQ( sv.find_last_of( L"\x101\x102\x103" , 4, 0 ), npos ); |
| 334 | BOOST_TEST_EQ( sv.find_last_of( L"\x101\x102\x103" , 5, 0 ), npos ); |
| 335 | BOOST_TEST_EQ( sv.find_last_of( L"\x101\x102\x103" , 6, 0 ), npos ); |
| 336 | BOOST_TEST_EQ( sv.find_last_of( L"\x101\x102\x103" , 7, 0 ), npos ); |
| 337 | |
| 338 | BOOST_TEST_EQ( sv.find_last_of( L"\x101\x102\x103" , 0, 1 ), 0 ); |
| 339 | BOOST_TEST_EQ( sv.find_last_of( L"\x101\x102\x103" , 1, 1 ), 0 ); |
| 340 | BOOST_TEST_EQ( sv.find_last_of( L"\x101\x102\x103" , 2, 1 ), 0 ); |
| 341 | BOOST_TEST_EQ( sv.find_last_of( L"\x101\x102\x103" , 3, 1 ), 3 ); |
| 342 | BOOST_TEST_EQ( sv.find_last_of( L"\x101\x102\x103" , 4, 1 ), 3 ); |
| 343 | BOOST_TEST_EQ( sv.find_last_of( L"\x101\x102\x103" , 5, 1 ), 3 ); |
| 344 | BOOST_TEST_EQ( sv.find_last_of( L"\x101\x102\x103" , 6, 1 ), 3 ); |
| 345 | BOOST_TEST_EQ( sv.find_last_of( L"\x101\x102\x103" , 7, 1 ), 3 ); |
| 346 | |
| 347 | BOOST_TEST_EQ( sv.find_last_of( L"\x101\x102\x103" , 0, 2 ), 0 ); |
| 348 | BOOST_TEST_EQ( sv.find_last_of( L"\x101\x102\x103" , 1, 2 ), 1 ); |
| 349 | BOOST_TEST_EQ( sv.find_last_of( L"\x101\x102\x103" , 2, 2 ), 1 ); |
| 350 | BOOST_TEST_EQ( sv.find_last_of( L"\x101\x102\x103" , 3, 2 ), 3 ); |
| 351 | BOOST_TEST_EQ( sv.find_last_of( L"\x101\x102\x103" , 4, 2 ), 4 ); |
| 352 | BOOST_TEST_EQ( sv.find_last_of( L"\x101\x102\x103" , 5, 2 ), 4 ); |
| 353 | BOOST_TEST_EQ( sv.find_last_of( L"\x101\x102\x103" , 6, 2 ), 4 ); |
| 354 | BOOST_TEST_EQ( sv.find_last_of( L"\x101\x102\x103" , 7, 2 ), 4 ); |
| 355 | |
| 356 | BOOST_TEST_EQ( sv.find_last_of( L"\x101\x102\x103" , 0, 3 ), 0 ); |
| 357 | BOOST_TEST_EQ( sv.find_last_of( L"\x101\x102\x103" , 1, 3 ), 1 ); |
| 358 | BOOST_TEST_EQ( sv.find_last_of( L"\x101\x102\x103" , 2, 3 ), 2 ); |
| 359 | BOOST_TEST_EQ( sv.find_last_of( L"\x101\x102\x103" , 3, 3 ), 3 ); |
| 360 | BOOST_TEST_EQ( sv.find_last_of( L"\x101\x102\x103" , 4, 3 ), 4 ); |
| 361 | BOOST_TEST_EQ( sv.find_last_of( L"\x101\x102\x103" , 5, 3 ), 5 ); |
| 362 | BOOST_TEST_EQ( sv.find_last_of( L"\x101\x102\x103" , 6, 3 ), 5 ); |
| 363 | BOOST_TEST_EQ( sv.find_last_of( L"\x101\x102\x103" , 7, 3 ), 5 ); |
| 364 | } |
| 365 | |
| 366 | { |
| 367 | boost::core::string_view sv( "abc1abc2abc3" ); |
| 368 | |
| 369 | BOOST_TEST_EQ( sv.find_last_of( "0123456789" , 0 ), npos ); |
| 370 | BOOST_TEST_EQ( sv.find_last_of( "0123456789" , 1 ), npos ); |
| 371 | BOOST_TEST_EQ( sv.find_last_of( "0123456789" , 2 ), npos ); |
| 372 | BOOST_TEST_EQ( sv.find_last_of( "0123456789" , 3 ), 3 ); |
| 373 | BOOST_TEST_EQ( sv.find_last_of( "0123456789" , 4 ), 3 ); |
| 374 | BOOST_TEST_EQ( sv.find_last_of( "0123456789" , 5 ), 3 ); |
| 375 | BOOST_TEST_EQ( sv.find_last_of( "0123456789" , 6 ), 3 ); |
| 376 | BOOST_TEST_EQ( sv.find_last_of( "0123456789" , 7 ), 7 ); |
| 377 | BOOST_TEST_EQ( sv.find_last_of( "0123456789" , 8 ), 7 ); |
| 378 | BOOST_TEST_EQ( sv.find_last_of( "0123456789" , 9 ), 7 ); |
| 379 | BOOST_TEST_EQ( sv.find_last_of( "0123456789" , 10 ), 7 ); |
| 380 | BOOST_TEST_EQ( sv.find_last_of( "0123456789" , 11 ), 11 ); |
| 381 | BOOST_TEST_EQ( sv.find_last_of( "0123456789" , 12 ), 11 ); |
| 382 | BOOST_TEST_EQ( sv.find_last_of( "0123456789" ), 11 ); |
| 383 | } |
| 384 | |
| 385 | { |
| 386 | boost::core::wstring_view sv( L"abc1abc2abc3" ); |
| 387 | |
| 388 | BOOST_TEST_EQ( sv.find_last_of( L"0123456789" , 0 ), npos ); |
| 389 | BOOST_TEST_EQ( sv.find_last_of( L"0123456789" , 1 ), npos ); |
| 390 | BOOST_TEST_EQ( sv.find_last_of( L"0123456789" , 2 ), npos ); |
| 391 | BOOST_TEST_EQ( sv.find_last_of( L"0123456789" , 3 ), 3 ); |
| 392 | BOOST_TEST_EQ( sv.find_last_of( L"0123456789" , 4 ), 3 ); |
| 393 | BOOST_TEST_EQ( sv.find_last_of( L"0123456789" , 5 ), 3 ); |
| 394 | BOOST_TEST_EQ( sv.find_last_of( L"0123456789" , 6 ), 3 ); |
| 395 | BOOST_TEST_EQ( sv.find_last_of( L"0123456789" , 7 ), 7 ); |
| 396 | BOOST_TEST_EQ( sv.find_last_of( L"0123456789" , 8 ), 7 ); |
| 397 | BOOST_TEST_EQ( sv.find_last_of( L"0123456789" , 9 ), 7 ); |
| 398 | BOOST_TEST_EQ( sv.find_last_of( L"0123456789" , 10 ), 7 ); |
| 399 | BOOST_TEST_EQ( sv.find_last_of( L"0123456789" , 11 ), 11 ); |
| 400 | BOOST_TEST_EQ( sv.find_last_of( L"0123456789" , 12 ), 11 ); |
| 401 | BOOST_TEST_EQ( sv.find_last_of( L"0123456789" ), 11 ); |
| 402 | } |
| 403 | |
| 404 | { |
| 405 | boost::core::string_view sv( "123a123B123c" ); |
| 406 | |
| 407 | BOOST_TEST_EQ( sv.find_last_of( "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" , 0 ), npos ); |
| 408 | BOOST_TEST_EQ( sv.find_last_of( "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" , 1 ), npos ); |
| 409 | BOOST_TEST_EQ( sv.find_last_of( "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" , 2 ), npos ); |
| 410 | BOOST_TEST_EQ( sv.find_last_of( "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" , 3 ), 3 ); |
| 411 | BOOST_TEST_EQ( sv.find_last_of( "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" , 4 ), 3 ); |
| 412 | BOOST_TEST_EQ( sv.find_last_of( "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" , 5 ), 3 ); |
| 413 | BOOST_TEST_EQ( sv.find_last_of( "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" , 6 ), 3 ); |
| 414 | BOOST_TEST_EQ( sv.find_last_of( "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" , 7 ), 7 ); |
| 415 | BOOST_TEST_EQ( sv.find_last_of( "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" , 8 ), 7 ); |
| 416 | BOOST_TEST_EQ( sv.find_last_of( "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" , 9 ), 7 ); |
| 417 | BOOST_TEST_EQ( sv.find_last_of( "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" , 10 ), 7 ); |
| 418 | BOOST_TEST_EQ( sv.find_last_of( "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" , 11 ), 11 ); |
| 419 | BOOST_TEST_EQ( sv.find_last_of( "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" , 12 ), 11 ); |
| 420 | BOOST_TEST_EQ( sv.find_last_of( "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" ), 11 ); |
| 421 | } |
| 422 | |
| 423 | { |
| 424 | boost::core::wstring_view sv( L"123a123B123c" ); |
| 425 | |
| 426 | BOOST_TEST_EQ( sv.find_last_of( L"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" , 0 ), npos ); |
| 427 | BOOST_TEST_EQ( sv.find_last_of( L"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" , 1 ), npos ); |
| 428 | BOOST_TEST_EQ( sv.find_last_of( L"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" , 2 ), npos ); |
| 429 | BOOST_TEST_EQ( sv.find_last_of( L"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" , 3 ), 3 ); |
| 430 | BOOST_TEST_EQ( sv.find_last_of( L"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" , 4 ), 3 ); |
| 431 | BOOST_TEST_EQ( sv.find_last_of( L"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" , 5 ), 3 ); |
| 432 | BOOST_TEST_EQ( sv.find_last_of( L"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" , 6 ), 3 ); |
| 433 | BOOST_TEST_EQ( sv.find_last_of( L"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" , 7 ), 7 ); |
| 434 | BOOST_TEST_EQ( sv.find_last_of( L"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" , 8 ), 7 ); |
| 435 | BOOST_TEST_EQ( sv.find_last_of( L"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" , 9 ), 7 ); |
| 436 | BOOST_TEST_EQ( sv.find_last_of( L"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" , 10 ), 7 ); |
| 437 | BOOST_TEST_EQ( sv.find_last_of( L"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" , 11 ), 11 ); |
| 438 | BOOST_TEST_EQ( sv.find_last_of( L"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" , 12 ), 11 ); |
| 439 | BOOST_TEST_EQ( sv.find_last_of( L"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" ), 11 ); |
| 440 | } |
| 441 | |
| 442 | { |
| 443 | char str[ 256 ]; |
| 444 | |
| 445 | for( int i = 0; i < 256; ++i ) |
| 446 | { |
| 447 | str[ i ] = static_cast< unsigned char >( i ); |
| 448 | } |
| 449 | |
| 450 | boost::core::string_view sv( str, 256 ); |
| 451 | |
| 452 | for( int i = 0; i < 256; ++i ) |
| 453 | { |
| 454 | std::string needle( 12, static_cast< unsigned char >( i ) ); |
| 455 | BOOST_TEST_EQ( sv.find_last_of( needle ), i ); |
| 456 | } |
| 457 | |
| 458 | std::reverse( first: str, last: str + 256 ); |
| 459 | |
| 460 | for( int i = 0; i < 256; ++i ) |
| 461 | { |
| 462 | std::string needle( 12, static_cast< unsigned char >( i ) ); |
| 463 | BOOST_TEST_EQ( sv.find_last_of( needle ), 255 - i ); |
| 464 | } |
| 465 | } |
| 466 | |
| 467 | { |
| 468 | wchar_t str[ 256 ]; |
| 469 | |
| 470 | for( int i = 0; i < 256; ++i ) |
| 471 | { |
| 472 | str[ i ] = static_cast< wchar_t >( 0x100 + i ); |
| 473 | } |
| 474 | |
| 475 | boost::core::wstring_view sv( str, 256 ); |
| 476 | |
| 477 | for( int i = 0; i < 256; ++i ) |
| 478 | { |
| 479 | std::wstring needle( 12, static_cast< wchar_t >( 0x100 + i ) ); |
| 480 | BOOST_TEST_EQ( sv.find_first_of( needle ), i ); |
| 481 | } |
| 482 | |
| 483 | std::reverse( first: str, last: str + 256 ); |
| 484 | |
| 485 | for( int i = 0; i < 256; ++i ) |
| 486 | { |
| 487 | std::wstring needle( 12, static_cast< wchar_t >( 0x100 + i ) ); |
| 488 | BOOST_TEST_EQ( sv.find_first_of( needle ), 255 - i ); |
| 489 | } |
| 490 | } |
| 491 | |
| 492 | #if defined(__cpp_char8_t) && __cpp_char8_t >= 201811L |
| 493 | |
| 494 | { |
| 495 | boost::core::u8string_view sv( u8"123123" ); |
| 496 | |
| 497 | BOOST_TEST_EQ( sv.find_last_of( u8"" , 0 ), npos ); |
| 498 | BOOST_TEST_EQ( sv.find_last_of( u8"" , 1 ), npos ); |
| 499 | BOOST_TEST_EQ( sv.find_last_of( u8"" , 6 ), npos ); |
| 500 | BOOST_TEST_EQ( sv.find_last_of( u8"" , 7 ), npos ); |
| 501 | BOOST_TEST_EQ( sv.find_last_of( u8"" ), npos ); |
| 502 | |
| 503 | BOOST_TEST_EQ( sv.find_last_of( u8"1" , 0 ), 0 ); |
| 504 | BOOST_TEST_EQ( sv.find_last_of( u8"1" , 1 ), 0 ); |
| 505 | BOOST_TEST_EQ( sv.find_last_of( u8"1" , 2 ), 0 ); |
| 506 | BOOST_TEST_EQ( sv.find_last_of( u8"1" , 3 ), 3 ); |
| 507 | BOOST_TEST_EQ( sv.find_last_of( u8"1" , 4 ), 3 ); |
| 508 | BOOST_TEST_EQ( sv.find_last_of( u8"1" , 5 ), 3 ); |
| 509 | BOOST_TEST_EQ( sv.find_last_of( u8"1" , 6 ), 3 ); |
| 510 | BOOST_TEST_EQ( sv.find_last_of( u8"1" , 7 ), 3 ); |
| 511 | BOOST_TEST_EQ( sv.find_last_of( u8"1" ), 3 ); |
| 512 | |
| 513 | BOOST_TEST_EQ( sv.find_last_of( u8"23" , 0 ), npos ); |
| 514 | BOOST_TEST_EQ( sv.find_last_of( u8"23" , 1 ), 1 ); |
| 515 | BOOST_TEST_EQ( sv.find_last_of( u8"23" , 2 ), 2 ); |
| 516 | BOOST_TEST_EQ( sv.find_last_of( u8"23" , 3 ), 2 ); |
| 517 | BOOST_TEST_EQ( sv.find_last_of( u8"23" , 4 ), 4 ); |
| 518 | BOOST_TEST_EQ( sv.find_last_of( u8"23" , 5 ), 5 ); |
| 519 | BOOST_TEST_EQ( sv.find_last_of( u8"23" , 6 ), 5 ); |
| 520 | BOOST_TEST_EQ( sv.find_last_of( u8"23" , 7 ), 5 ); |
| 521 | BOOST_TEST_EQ( sv.find_last_of( u8"23" ), 5 ); |
| 522 | |
| 523 | BOOST_TEST_EQ( sv.find_last_of( u8"123" , 0 ), 0 ); |
| 524 | BOOST_TEST_EQ( sv.find_last_of( u8"123" , 1 ), 1 ); |
| 525 | BOOST_TEST_EQ( sv.find_last_of( u8"123" , 2 ), 2 ); |
| 526 | BOOST_TEST_EQ( sv.find_last_of( u8"123" , 3 ), 3 ); |
| 527 | BOOST_TEST_EQ( sv.find_last_of( u8"123" , 4 ), 4 ); |
| 528 | BOOST_TEST_EQ( sv.find_last_of( u8"123" , 5 ), 5 ); |
| 529 | BOOST_TEST_EQ( sv.find_last_of( u8"123" , 6 ), 5 ); |
| 530 | BOOST_TEST_EQ( sv.find_last_of( u8"123" , 7 ), 5 ); |
| 531 | BOOST_TEST_EQ( sv.find_last_of( u8"123" ), 5 ); |
| 532 | } |
| 533 | |
| 534 | { |
| 535 | boost::core::u8string_view sv( u8"abc1abc2abc3" ); |
| 536 | |
| 537 | BOOST_TEST_EQ( sv.find_last_of( u8"0123456789" , 0 ), npos ); |
| 538 | BOOST_TEST_EQ( sv.find_last_of( u8"0123456789" , 1 ), npos ); |
| 539 | BOOST_TEST_EQ( sv.find_last_of( u8"0123456789" , 2 ), npos ); |
| 540 | BOOST_TEST_EQ( sv.find_last_of( u8"0123456789" , 3 ), 3 ); |
| 541 | BOOST_TEST_EQ( sv.find_last_of( u8"0123456789" , 4 ), 3 ); |
| 542 | BOOST_TEST_EQ( sv.find_last_of( u8"0123456789" , 5 ), 3 ); |
| 543 | BOOST_TEST_EQ( sv.find_last_of( u8"0123456789" , 6 ), 3 ); |
| 544 | BOOST_TEST_EQ( sv.find_last_of( u8"0123456789" , 7 ), 7 ); |
| 545 | BOOST_TEST_EQ( sv.find_last_of( u8"0123456789" , 8 ), 7 ); |
| 546 | BOOST_TEST_EQ( sv.find_last_of( u8"0123456789" , 9 ), 7 ); |
| 547 | BOOST_TEST_EQ( sv.find_last_of( u8"0123456789" , 10 ), 7 ); |
| 548 | BOOST_TEST_EQ( sv.find_last_of( u8"0123456789" , 11 ), 11 ); |
| 549 | BOOST_TEST_EQ( sv.find_last_of( u8"0123456789" , 12 ), 11 ); |
| 550 | BOOST_TEST_EQ( sv.find_last_of( u8"0123456789" ), 11 ); |
| 551 | } |
| 552 | |
| 553 | { |
| 554 | boost::core::u8string_view sv( u8"123a123B123c" ); |
| 555 | |
| 556 | BOOST_TEST_EQ( sv.find_last_of( u8"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" , 0 ), npos ); |
| 557 | BOOST_TEST_EQ( sv.find_last_of( u8"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" , 1 ), npos ); |
| 558 | BOOST_TEST_EQ( sv.find_last_of( u8"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" , 2 ), npos ); |
| 559 | BOOST_TEST_EQ( sv.find_last_of( u8"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" , 3 ), 3 ); |
| 560 | BOOST_TEST_EQ( sv.find_last_of( u8"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" , 4 ), 3 ); |
| 561 | BOOST_TEST_EQ( sv.find_last_of( u8"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" , 5 ), 3 ); |
| 562 | BOOST_TEST_EQ( sv.find_last_of( u8"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" , 6 ), 3 ); |
| 563 | BOOST_TEST_EQ( sv.find_last_of( u8"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" , 7 ), 7 ); |
| 564 | BOOST_TEST_EQ( sv.find_last_of( u8"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" , 8 ), 7 ); |
| 565 | BOOST_TEST_EQ( sv.find_last_of( u8"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" , 9 ), 7 ); |
| 566 | BOOST_TEST_EQ( sv.find_last_of( u8"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" , 10 ), 7 ); |
| 567 | BOOST_TEST_EQ( sv.find_last_of( u8"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" , 11 ), 11 ); |
| 568 | BOOST_TEST_EQ( sv.find_last_of( u8"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" , 12 ), 11 ); |
| 569 | BOOST_TEST_EQ( sv.find_last_of( u8"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" ), 11 ); |
| 570 | } |
| 571 | |
| 572 | #endif |
| 573 | |
| 574 | return boost::report_errors(); |
| 575 | } |
| 576 | |