1 //===----------------------------------------------------------------------===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is dual licensed under the MIT and the University of Illinois Open 6 // Source Licenses. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 10 // <locale> 11 12 // class money_get<charT, InputIterator> 13 14 // iter_type get(iter_type b, iter_type e, bool intl, ios_base& iob, 15 // ios_base::iostate& err, long double& v) const; 16 17 #include <locale> 18 #include <ios> 19 #include <streambuf> 20 #include <cassert> 21 #include "test_iterators.h" 22 23 #include "platform_support.h" // locale name macros 24 25 typedef std::money_get<char, input_iterator<const char*> > Fn; 26 27 class my_facet 28 : public Fn 29 { 30 public: 31 explicit my_facet(std::size_t refs = 0) 32 : Fn(refs) {} 33 }; 34 35 typedef std::money_get<wchar_t, input_iterator<const wchar_t*> > Fw; 36 37 class my_facetw 38 : public Fw 39 { 40 public: 41 explicit my_facetw(std::size_t refs = 0) 42 : Fw(refs) {} 43 }; 44 45 int main() 46 { 47 std::ios ios(0); 48 std::string loc_name(LOCALE_ru_RU_UTF_8); 49 ios.imbue(std::locale(ios.getloc(), 50 new std::moneypunct_byname<char, false>(loc_name))); 51 ios.imbue(std::locale(ios.getloc(), 52 new std::moneypunct_byname<char, true>(loc_name))); 53 ios.imbue(std::locale(ios.getloc(), 54 new std::moneypunct_byname<wchar_t, false>(loc_name))); 55 ios.imbue(std::locale(ios.getloc(), 56 new std::moneypunct_byname<wchar_t, true>(loc_name))); 57 { 58 const my_facet f(1); 59 // char, national 60 { // zero 61 std::string v = "0,00 "; 62 typedef input_iterator<const char*> I; 63 long double ex; 64 std::ios_base::iostate err = std::ios_base::goodbit; 65 I iter = f.get(I(v.data()), I(v.data() + v.size()), 66 false, ios, err, ex); 67 assert(iter.base() == v.data() + v.size()); 68 assert(err == std::ios_base::eofbit); 69 assert(ex == 0); 70 } 71 { // negative one 72 std::string v = "-0,01 "; 73 typedef input_iterator<const char*> I; 74 long double ex; 75 std::ios_base::iostate err = std::ios_base::goodbit; 76 I iter = f.get(I(v.data()), I(v.data() + v.size()), 77 false, ios, err, ex); 78 assert(iter.base() == v.data() + v.size()); 79 assert(err == std::ios_base::eofbit); 80 assert(ex == -1); 81 } 82 { // positive 83 std::string v = "1 234 567,89 "; 84 typedef input_iterator<const char*> I; 85 long double ex; 86 std::ios_base::iostate err = std::ios_base::goodbit; 87 I iter = f.get(I(v.data()), I(v.data() + v.size()), 88 false, ios, err, ex); 89 assert(iter.base() == v.data() + v.size()); 90 assert(err == std::ios_base::eofbit); 91 assert(ex == 123456789); 92 } 93 { // negative 94 std::string v = "-1 234 567,89 "; 95 typedef input_iterator<const char*> I; 96 long double ex; 97 std::ios_base::iostate err = std::ios_base::goodbit; 98 I iter = f.get(I(v.data()), I(v.data() + v.size()), 99 false, ios, err, ex); 100 assert(iter.base() == v.data() + v.size()); 101 assert(err == std::ios_base::eofbit); 102 assert(ex == -123456789); 103 } 104 { // negative 105 std::string v = "-1234567,89 "; 106 typedef input_iterator<const char*> I; 107 long double ex; 108 std::ios_base::iostate err = std::ios_base::goodbit; 109 I iter = f.get(I(v.data()), I(v.data() + v.size()), 110 false, ios, err, ex); 111 assert(iter.base() == v.data() + v.size()); 112 assert(err == std::ios_base::eofbit); 113 assert(ex == -123456789); 114 } 115 { // zero, showbase 116 std::string v = "0,00 \xD1\x80\xD1\x83\xD0\xB1""."; 117 typedef input_iterator<const char*> I; 118 long double ex; 119 std::ios_base::iostate err = std::ios_base::goodbit; 120 I iter = f.get(I(v.data()), I(v.data() + v.size()), 121 false, ios, err, ex); 122 assert(iter.base() == v.data() + 5); 123 assert(err == std::ios_base::goodbit); 124 assert(ex == 0); 125 } 126 { // zero, showbase 127 std::string v = "0,00 \xD1\x80\xD1\x83\xD0\xB1""."; 128 showbase(ios); 129 typedef input_iterator<const char*> I; 130 long double ex; 131 std::ios_base::iostate err = std::ios_base::goodbit; 132 I iter = f.get(I(v.data()), I(v.data() + v.size()), 133 false, ios, err, ex); 134 assert(iter.base() == v.data() + v.size()); 135 assert(err == std::ios_base::eofbit); 136 assert(ex == 0); 137 noshowbase(ios); 138 } 139 { // negative one, showbase 140 std::string v = "-0,01 \xD1\x80\xD1\x83\xD0\xB1""."; 141 typedef input_iterator<const char*> I; 142 long double ex; 143 std::ios_base::iostate err = std::ios_base::goodbit; 144 I iter = f.get(I(v.data()), I(v.data() + v.size()), 145 false, ios, err, ex); 146 assert(iter.base() == v.data() + 6); 147 assert(err == std::ios_base::goodbit); 148 assert(ex == -1); 149 } 150 { // negative one, showbase 151 std::string v = "-0,01 \xD1\x80\xD1\x83\xD0\xB1""."; 152 showbase(ios); 153 typedef input_iterator<const char*> I; 154 long double ex; 155 std::ios_base::iostate err = std::ios_base::goodbit; 156 I iter = f.get(I(v.data()), I(v.data() + v.size()), 157 false, ios, err, ex); 158 assert(iter.base() == v.data() + v.size()); 159 assert(err == std::ios_base::eofbit); 160 assert(ex == -1); 161 noshowbase(ios); 162 } 163 { // positive, showbase 164 std::string v = "1 234 567,89 \xD1\x80\xD1\x83\xD0\xB1""."; 165 typedef input_iterator<const char*> I; 166 long double ex; 167 std::ios_base::iostate err = std::ios_base::goodbit; 168 I iter = f.get(I(v.data()), I(v.data() + v.size()), 169 false, ios, err, ex); 170 assert(iter.base() == v.data() + 13); 171 assert(err == std::ios_base::goodbit); 172 assert(ex == 123456789); 173 } 174 { // positive, showbase 175 std::string v = "1 234 567,89 \xD1\x80\xD1\x83\xD0\xB1""."; 176 showbase(ios); 177 typedef input_iterator<const char*> I; 178 long double ex; 179 std::ios_base::iostate err = std::ios_base::goodbit; 180 I iter = f.get(I(v.data()), I(v.data() + v.size()), 181 false, ios, err, ex); 182 assert(iter.base() == v.data() + v.size()); 183 assert(err == std::ios_base::eofbit); 184 assert(ex == 123456789); 185 noshowbase(ios); 186 } 187 { // negative, showbase 188 std::string v = "-1 234 567,89 \xD1\x80\xD1\x83\xD0\xB1""."; 189 showbase(ios); 190 typedef input_iterator<const char*> I; 191 long double ex; 192 std::ios_base::iostate err = std::ios_base::goodbit; 193 I iter = f.get(I(v.data()), I(v.data() + v.size()), 194 false, ios, err, ex); 195 assert(iter.base() == v.data() + v.size()); 196 assert(err == std::ios_base::eofbit); 197 assert(ex == -123456789); 198 noshowbase(ios); 199 } 200 { // negative, showbase 201 std::string v = "-1 234 567,89 RUB "; 202 showbase(ios); 203 typedef input_iterator<const char*> I; 204 long double ex; 205 std::ios_base::iostate err = std::ios_base::goodbit; 206 I iter = f.get(I(v.data()), I(v.data() + v.size()), 207 false, ios, err, ex); 208 assert(iter.base() == v.data() + 14); 209 assert(err == std::ios_base::failbit); 210 noshowbase(ios); 211 } 212 { // negative, showbase 213 std::string v = "-1 234 567,89 RUB "; 214 typedef input_iterator<const char*> I; 215 long double ex; 216 std::ios_base::iostate err = std::ios_base::goodbit; 217 I iter = f.get(I(v.data()), I(v.data() + v.size()), 218 false, ios, err, ex); 219 assert(iter.base() == v.data() + 14); 220 assert(err == std::ios_base::goodbit); 221 assert(ex == -123456789); 222 } 223 } 224 { 225 const my_facet f(1); 226 // char, international 227 { // zero 228 std::string v = "0,00"; 229 typedef input_iterator<const char*> I; 230 long double ex; 231 std::ios_base::iostate err = std::ios_base::goodbit; 232 I iter = f.get(I(v.data()), I(v.data() + v.size()), 233 true, ios, err, ex); 234 assert(iter.base() == v.data() + v.size()); 235 assert(err == std::ios_base::eofbit); 236 assert(ex == 0); 237 } 238 { // negative one 239 std::string v = "-0,01 "; 240 typedef input_iterator<const char*> I; 241 long double ex; 242 std::ios_base::iostate err = std::ios_base::goodbit; 243 I iter = f.get(I(v.data()), I(v.data() + v.size()), 244 true, ios, err, ex); 245 assert(iter.base() == v.data() + v.size()); 246 assert(err == std::ios_base::eofbit); 247 assert(ex == -1); 248 } 249 { // positive 250 std::string v = "1 234 567,89 "; 251 typedef input_iterator<const char*> I; 252 long double ex; 253 std::ios_base::iostate err = std::ios_base::goodbit; 254 I iter = f.get(I(v.data()), I(v.data() + v.size()), 255 true, ios, err, ex); 256 assert(iter.base() == v.data() + v.size()); 257 assert(err == std::ios_base::eofbit); 258 assert(ex == 123456789); 259 } 260 { // negative 261 std::string v = "-1 234 567,89 "; 262 typedef input_iterator<const char*> I; 263 long double ex; 264 std::ios_base::iostate err = std::ios_base::goodbit; 265 I iter = f.get(I(v.data()), I(v.data() + v.size()), 266 true, ios, err, ex); 267 assert(iter.base() == v.data() + v.size()); 268 assert(err == std::ios_base::eofbit); 269 assert(ex == -123456789); 270 } 271 { // negative 272 std::string v = "-1234567,89 "; 273 typedef input_iterator<const char*> I; 274 long double ex; 275 std::ios_base::iostate err = std::ios_base::goodbit; 276 I iter = f.get(I(v.data()), I(v.data() + v.size()), 277 true, ios, err, ex); 278 assert(iter.base() == v.data() + v.size()); 279 assert(err == std::ios_base::eofbit); 280 assert(ex == -123456789); 281 } 282 { // zero, showbase 283 std::string v = "0,00 RUB "; 284 typedef input_iterator<const char*> I; 285 long double ex; 286 std::ios_base::iostate err = std::ios_base::goodbit; 287 I iter = f.get(I(v.data()), I(v.data() + v.size()), 288 true, ios, err, ex); 289 assert(iter.base() == v.data() + 5); 290 assert(err == std::ios_base::goodbit); 291 assert(ex == 0); 292 } 293 { // zero, showbase 294 std::string v = "0,00 RUB "; 295 showbase(ios); 296 typedef input_iterator<const char*> I; 297 long double ex; 298 std::ios_base::iostate err = std::ios_base::goodbit; 299 I iter = f.get(I(v.data()), I(v.data() + v.size()), 300 true, ios, err, ex); 301 assert(iter.base() == v.data() + v.size()); 302 assert(err == std::ios_base::eofbit); 303 assert(ex == 0); 304 noshowbase(ios); 305 } 306 { // negative one, showbase 307 std::string v = "-0,01 RUB "; 308 typedef input_iterator<const char*> I; 309 long double ex; 310 std::ios_base::iostate err = std::ios_base::goodbit; 311 I iter = f.get(I(v.data()), I(v.data() + v.size()), 312 true, ios, err, ex); 313 assert(iter.base() == v.data() + 6); 314 assert(err == std::ios_base::goodbit); 315 assert(ex == -1); 316 } 317 { // negative one, showbase 318 std::string v = "-0,01 RUB "; 319 showbase(ios); 320 typedef input_iterator<const char*> I; 321 long double ex; 322 std::ios_base::iostate err = std::ios_base::goodbit; 323 I iter = f.get(I(v.data()), I(v.data() + v.size()), 324 true, ios, err, ex); 325 assert(iter.base() == v.data() + v.size()); 326 assert(err == std::ios_base::eofbit); 327 assert(ex == -1); 328 noshowbase(ios); 329 } 330 { // positive, showbase 331 std::string v = "1 234 567,89 RUB "; 332 typedef input_iterator<const char*> I; 333 long double ex; 334 std::ios_base::iostate err = std::ios_base::goodbit; 335 I iter = f.get(I(v.data()), I(v.data() + v.size()), 336 true, ios, err, ex); 337 assert(iter.base() == v.data() + 13); 338 assert(err == std::ios_base::goodbit); 339 assert(ex == 123456789); 340 } 341 { // positive, showbase 342 std::string v = "1 234 567,89 RUB "; 343 showbase(ios); 344 typedef input_iterator<const char*> I; 345 long double ex; 346 std::ios_base::iostate err = std::ios_base::goodbit; 347 I iter = f.get(I(v.data()), I(v.data() + v.size()), 348 true, ios, err, ex); 349 assert(iter.base() == v.data() + v.size()); 350 assert(err == std::ios_base::eofbit); 351 assert(ex == 123456789); 352 noshowbase(ios); 353 } 354 { // negative, showbase 355 std::string v = "-1 234 567,89 RUB "; 356 showbase(ios); 357 typedef input_iterator<const char*> I; 358 long double ex; 359 std::ios_base::iostate err = std::ios_base::goodbit; 360 I iter = f.get(I(v.data()), I(v.data() + v.size()), 361 true, ios, err, ex); 362 assert(iter.base() == v.data() + v.size()); 363 assert(err == std::ios_base::eofbit); 364 assert(ex == -123456789); 365 noshowbase(ios); 366 } 367 { // negative, showbase 368 std::string v = "-1 234 567,89 \xD1\x80\xD1\x83\xD0\xB1""."; 369 showbase(ios); 370 typedef input_iterator<const char*> I; 371 long double ex; 372 std::ios_base::iostate err = std::ios_base::goodbit; 373 I iter = f.get(I(v.data()), I(v.data() + v.size()), 374 true, ios, err, ex); 375 assert(iter.base() == v.data() + 14); 376 assert(err == std::ios_base::failbit); 377 noshowbase(ios); 378 } 379 { // negative, showbase 380 std::string v = "-1 234 567,89 \xD1\x80\xD1\x83\xD0\xB1""."; 381 typedef input_iterator<const char*> I; 382 long double ex; 383 std::ios_base::iostate err = std::ios_base::goodbit; 384 I iter = f.get(I(v.data()), I(v.data() + v.size()), 385 true, ios, err, ex); 386 assert(iter.base() == v.data() + 14); 387 assert(err == std::ios_base::goodbit); 388 assert(ex == -123456789); 389 } 390 } 391 { 392 const my_facetw f(1); 393 // wchar_t, national 394 { // zero 395 std::wstring v = L"0,00"; 396 typedef input_iterator<const wchar_t*> I; 397 long double ex; 398 std::ios_base::iostate err = std::ios_base::goodbit; 399 I iter = f.get(I(v.data()), I(v.data() + v.size()), 400 false, ios, err, ex); 401 assert(iter.base() == v.data() + v.size()); 402 assert(err == std::ios_base::eofbit); 403 assert(ex == 0); 404 } 405 { // negative one 406 std::wstring v = L"-0,01 "; 407 typedef input_iterator<const wchar_t*> I; 408 long double ex; 409 std::ios_base::iostate err = std::ios_base::goodbit; 410 I iter = f.get(I(v.data()), I(v.data() + v.size()), 411 false, ios, err, ex); 412 assert(iter.base() == v.data() + v.size()); 413 assert(err == std::ios_base::eofbit); 414 assert(ex == -1); 415 } 416 { // positive 417 std::wstring v = L"1 234 567,89 "; 418 typedef input_iterator<const wchar_t*> I; 419 long double ex; 420 std::ios_base::iostate err = std::ios_base::goodbit; 421 I iter = f.get(I(v.data()), I(v.data() + v.size()), 422 false, ios, err, ex); 423 assert(iter.base() == v.data() + v.size()); 424 assert(err == std::ios_base::eofbit); 425 assert(ex == 123456789); 426 } 427 { // negative 428 std::wstring v = L"-1 234 567,89 "; 429 typedef input_iterator<const wchar_t*> I; 430 long double ex; 431 std::ios_base::iostate err = std::ios_base::goodbit; 432 I iter = f.get(I(v.data()), I(v.data() + v.size()), 433 false, ios, err, ex); 434 assert(iter.base() == v.data() + v.size()); 435 assert(err == std::ios_base::eofbit); 436 assert(ex == -123456789); 437 } 438 { // negative 439 std::wstring v = L"-1234567,89 "; 440 typedef input_iterator<const wchar_t*> I; 441 long double ex; 442 std::ios_base::iostate err = std::ios_base::goodbit; 443 I iter = f.get(I(v.data()), I(v.data() + v.size()), 444 false, ios, err, ex); 445 assert(iter.base() == v.data() + v.size()); 446 assert(err == std::ios_base::eofbit); 447 assert(ex == -123456789); 448 } 449 { // zero, showbase 450 std::wstring v = L"0,00 \x440\x443\x431""."; 451 typedef input_iterator<const wchar_t*> I; 452 long double ex; 453 std::ios_base::iostate err = std::ios_base::goodbit; 454 I iter = f.get(I(v.data()), I(v.data() + v.size()), 455 false, ios, err, ex); 456 assert(iter.base() == v.data() + 5); 457 assert(err == std::ios_base::goodbit); 458 assert(ex == 0); 459 } 460 { // zero, showbase 461 std::wstring v = L"0,00 \x440\x443\x431""."; 462 showbase(ios); 463 typedef input_iterator<const wchar_t*> I; 464 long double ex; 465 std::ios_base::iostate err = std::ios_base::goodbit; 466 I iter = f.get(I(v.data()), I(v.data() + v.size()), 467 false, ios, err, ex); 468 assert(iter.base() == v.data() + v.size()); 469 assert(err == std::ios_base::eofbit); 470 assert(ex == 0); 471 noshowbase(ios); 472 } 473 { // negative one, showbase 474 std::wstring v = L"-0,01 \x440\x443\x431""."; 475 typedef input_iterator<const wchar_t*> I; 476 long double ex; 477 std::ios_base::iostate err = std::ios_base::goodbit; 478 I iter = f.get(I(v.data()), I(v.data() + v.size()), 479 false, ios, err, ex); 480 assert(iter.base() == v.data() + 6); 481 assert(err == std::ios_base::goodbit); 482 assert(ex == -1); 483 } 484 { // negative one, showbase 485 std::wstring v = L"-0,01 \x440\x443\x431""."; 486 showbase(ios); 487 typedef input_iterator<const wchar_t*> I; 488 long double ex; 489 std::ios_base::iostate err = std::ios_base::goodbit; 490 I iter = f.get(I(v.data()), I(v.data() + v.size()), 491 false, ios, err, ex); 492 assert(iter.base() == v.data() + v.size()); 493 assert(err == std::ios_base::eofbit); 494 assert(ex == -1); 495 noshowbase(ios); 496 } 497 { // positive, showbase 498 std::wstring v = L"1 234 567,89 \x440\x443\x431""."; 499 typedef input_iterator<const wchar_t*> I; 500 long double ex; 501 std::ios_base::iostate err = std::ios_base::goodbit; 502 I iter = f.get(I(v.data()), I(v.data() + v.size()), 503 false, ios, err, ex); 504 assert(iter.base() == v.data() + 13); 505 assert(err == std::ios_base::goodbit); 506 assert(ex == 123456789); 507 } 508 { // positive, showbase 509 std::wstring v = L"1 234 567,89 \x440\x443\x431""."; 510 showbase(ios); 511 typedef input_iterator<const wchar_t*> I; 512 long double ex; 513 std::ios_base::iostate err = std::ios_base::goodbit; 514 I iter = f.get(I(v.data()), I(v.data() + v.size()), 515 false, ios, err, ex); 516 assert(iter.base() == v.data() + v.size()); 517 assert(err == std::ios_base::eofbit); 518 assert(ex == 123456789); 519 noshowbase(ios); 520 } 521 { // negative, showbase 522 std::wstring v = L"-1 234 567,89 \x440\x443\x431""."; 523 showbase(ios); 524 typedef input_iterator<const wchar_t*> I; 525 long double ex; 526 std::ios_base::iostate err = std::ios_base::goodbit; 527 I iter = f.get(I(v.data()), I(v.data() + v.size()), 528 false, ios, err, ex); 529 assert(iter.base() == v.data() + v.size()); 530 assert(err == std::ios_base::eofbit); 531 assert(ex == -123456789); 532 noshowbase(ios); 533 } 534 { // negative, showbase 535 std::wstring v = L"-1 234 567,89 RUB "; 536 showbase(ios); 537 typedef input_iterator<const wchar_t*> I; 538 long double ex; 539 std::ios_base::iostate err = std::ios_base::goodbit; 540 I iter = f.get(I(v.data()), I(v.data() + v.size()), 541 false, ios, err, ex); 542 assert(iter.base() == v.data() + 14); 543 assert(err == std::ios_base::failbit); 544 noshowbase(ios); 545 } 546 { // negative, showbase 547 std::wstring v = L"-1 234 567,89 RUB "; 548 typedef input_iterator<const wchar_t*> I; 549 long double ex; 550 std::ios_base::iostate err = std::ios_base::goodbit; 551 I iter = f.get(I(v.data()), I(v.data() + v.size()), 552 false, ios, err, ex); 553 assert(iter.base() == v.data() + 14); 554 assert(err == std::ios_base::goodbit); 555 assert(ex == -123456789); 556 } 557 } 558 { 559 const my_facetw f(1); 560 // wchar_t, international 561 { // zero 562 std::wstring v = L"0,00"; 563 typedef input_iterator<const wchar_t*> I; 564 long double ex; 565 std::ios_base::iostate err = std::ios_base::goodbit; 566 I iter = f.get(I(v.data()), I(v.data() + v.size()), 567 true, ios, err, ex); 568 assert(iter.base() == v.data() + v.size()); 569 assert(err == std::ios_base::eofbit); 570 assert(ex == 0); 571 } 572 { // negative one 573 std::wstring v = L"-0,01 "; 574 typedef input_iterator<const wchar_t*> I; 575 long double ex; 576 std::ios_base::iostate err = std::ios_base::goodbit; 577 I iter = f.get(I(v.data()), I(v.data() + v.size()), 578 true, ios, err, ex); 579 assert(iter.base() == v.data() + v.size()); 580 assert(err == std::ios_base::eofbit); 581 assert(ex == -1); 582 } 583 { // positive 584 std::wstring v = L"1 234 567,89 "; 585 typedef input_iterator<const wchar_t*> I; 586 long double ex; 587 std::ios_base::iostate err = std::ios_base::goodbit; 588 I iter = f.get(I(v.data()), I(v.data() + v.size()), 589 true, ios, err, ex); 590 assert(iter.base() == v.data() + v.size()); 591 assert(err == std::ios_base::eofbit); 592 assert(ex == 123456789); 593 } 594 { // negative 595 std::wstring v = L"-1 234 567,89 "; 596 typedef input_iterator<const wchar_t*> I; 597 long double ex; 598 std::ios_base::iostate err = std::ios_base::goodbit; 599 I iter = f.get(I(v.data()), I(v.data() + v.size()), 600 true, ios, err, ex); 601 assert(iter.base() == v.data() + v.size()); 602 assert(err == std::ios_base::eofbit); 603 assert(ex == -123456789); 604 } 605 { // negative 606 std::wstring v = L"-1234567,89 "; 607 typedef input_iterator<const wchar_t*> I; 608 long double ex; 609 std::ios_base::iostate err = std::ios_base::goodbit; 610 I iter = f.get(I(v.data()), I(v.data() + v.size()), 611 true, ios, err, ex); 612 assert(iter.base() == v.data() + v.size()); 613 assert(err == std::ios_base::eofbit); 614 assert(ex == -123456789); 615 } 616 { // zero, showbase 617 std::wstring v = L"0,00 RUB "; 618 typedef input_iterator<const wchar_t*> I; 619 long double ex; 620 std::ios_base::iostate err = std::ios_base::goodbit; 621 I iter = f.get(I(v.data()), I(v.data() + v.size()), 622 true, ios, err, ex); 623 assert(iter.base() == v.data() + 5); 624 assert(err == std::ios_base::goodbit); 625 assert(ex == 0); 626 } 627 { // zero, showbase 628 std::wstring v = L"0,00 RUB "; 629 showbase(ios); 630 typedef input_iterator<const wchar_t*> I; 631 long double ex; 632 std::ios_base::iostate err = std::ios_base::goodbit; 633 I iter = f.get(I(v.data()), I(v.data() + v.size()), 634 true, ios, err, ex); 635 assert(iter.base() == v.data() + v.size()); 636 assert(err == std::ios_base::eofbit); 637 assert(ex == 0); 638 noshowbase(ios); 639 } 640 { // negative one, showbase 641 std::wstring v = L"-0,01 RUB "; 642 typedef input_iterator<const wchar_t*> I; 643 long double ex; 644 std::ios_base::iostate err = std::ios_base::goodbit; 645 I iter = f.get(I(v.data()), I(v.data() + v.size()), 646 true, ios, err, ex); 647 assert(iter.base() == v.data() + 6); 648 assert(err == std::ios_base::goodbit); 649 assert(ex == -1); 650 } 651 { // negative one, showbase 652 std::wstring v = L"-0,01 RUB "; 653 showbase(ios); 654 typedef input_iterator<const wchar_t*> I; 655 long double ex; 656 std::ios_base::iostate err = std::ios_base::goodbit; 657 I iter = f.get(I(v.data()), I(v.data() + v.size()), 658 true, ios, err, ex); 659 assert(iter.base() == v.data() + v.size()); 660 assert(err == std::ios_base::eofbit); 661 assert(ex == -1); 662 noshowbase(ios); 663 } 664 { // positive, showbase 665 std::wstring v = L"1 234 567,89 RUB "; 666 typedef input_iterator<const wchar_t*> I; 667 long double ex; 668 std::ios_base::iostate err = std::ios_base::goodbit; 669 I iter = f.get(I(v.data()), I(v.data() + v.size()), 670 true, ios, err, ex); 671 assert(iter.base() == v.data() + 13); 672 assert(err == std::ios_base::goodbit); 673 assert(ex == 123456789); 674 } 675 { // positive, showbase 676 std::wstring v = L"1 234 567,89 RUB "; 677 showbase(ios); 678 typedef input_iterator<const wchar_t*> I; 679 long double ex; 680 std::ios_base::iostate err = std::ios_base::goodbit; 681 I iter = f.get(I(v.data()), I(v.data() + v.size()), 682 true, ios, err, ex); 683 assert(iter.base() == v.data() + v.size()); 684 assert(err == std::ios_base::eofbit); 685 assert(ex == 123456789); 686 noshowbase(ios); 687 } 688 { // negative, showbase 689 std::wstring v = L"-1 234 567,89 RUB "; 690 showbase(ios); 691 typedef input_iterator<const wchar_t*> I; 692 long double ex; 693 std::ios_base::iostate err = std::ios_base::goodbit; 694 I iter = f.get(I(v.data()), I(v.data() + v.size()), 695 true, ios, err, ex); 696 assert(iter.base() == v.data() + v.size()); 697 assert(err == std::ios_base::eofbit); 698 assert(ex == -123456789); 699 noshowbase(ios); 700 } 701 { // negative, showbase 702 std::wstring v = L"-1 234 567,89 \x440\x443\x431""."; 703 showbase(ios); 704 typedef input_iterator<const wchar_t*> I; 705 long double ex; 706 std::ios_base::iostate err = std::ios_base::goodbit; 707 I iter = f.get(I(v.data()), I(v.data() + v.size()), 708 true, ios, err, ex); 709 assert(iter.base() == v.data() + 14); 710 assert(err == std::ios_base::failbit); 711 noshowbase(ios); 712 } 713 { // negative, showbase 714 std::wstring v = L"-1 234 567,89 \x440\x443\x431""."; 715 typedef input_iterator<const wchar_t*> I; 716 long double ex; 717 std::ios_base::iostate err = std::ios_base::goodbit; 718 I iter = f.get(I(v.data()), I(v.data() + v.size()), 719 true, ios, err, ex); 720 assert(iter.base() == v.data() + 14); 721 assert(err == std::ios_base::goodbit); 722 assert(ex == -123456789); 723 } 724 } 725 } 726