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