Changeset 6c089a9 in mainline
- Timestamp:
- 2018-07-05T21:41:18Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- a6ca1bc
- Parents:
- d3bca35
- git-author:
- Jaroslav Jindrak <dzejrou@…> (2017-11-02 17:38:25)
- git-committer:
- Dzejrou <dzejrou@…> (2018-07-05 21:41:18)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/cpp/src/internal/test/string.cpp
rd3bca35 r6c089a9 410 410 idx = str1.rfind(target, miss); 411 411 test_eq( 412 "rfind from start(success)",412 "rfind from end (success)", 413 413 idx, 2ul 414 414 ); … … 418 418 "rfind from start (fail, late start)", 419 419 idx, miss 420 ); 421 422 idx = str1.find('B', 2); 423 test_eq( 424 "find char from middle (success)", 425 idx, 3ul 426 ); 427 428 idx = str1.rfind('B', 2); 429 test_eq( 430 "rfind char from middle (success)", 431 idx, 3ul 420 432 ); 421 433 … … 427 439 idx, 2ul 428 440 ); 441 442 idx = str2.find(target, 5); 443 test_eq( 444 "find from middle (success, multiple)", 445 idx, 7ul 446 ); 447 448 idx = str2.rfind(target, miss); 449 test_eq( 450 "rfind from end (success, multiple)", 451 idx, 7ul 452 ); 453 454 idx = str2.rfind(target, 6); 455 test_eq( 456 "rfind from mid (success, multiple)", 457 idx, 2ul 458 ); 459 460 std::string str3{"xxBxxAxxCxx"}; 461 462 idx = str3.find_first_of(target); 463 test_eq( 464 "find first of from start (success)", 465 idx, 2ul 466 ); 467 468 idx = str3.find_first_of(target, 6); 469 test_eq( 470 "find first of from middle (success)", 471 idx, 8ul 472 ); 473 474 idx = str3.find_first_of("DEF", 3); 475 test_eq( 476 "find first of from middle (fail, not in string)", 477 idx, miss 478 ); 479 480 idx = str3.find_first_of(target, 9); 481 test_eq( 482 "find first of from middle (fail, late start)", 483 idx, miss 484 ); 485 486 idx = str3.find_first_of(""); 487 test_eq( 488 "find first of from start (fail, no target)", 489 idx, miss 490 ); 491 492 idx = str3.find_first_of('A', 1); 493 test_eq( 494 "find first of char (success)", 495 idx, 5ul 496 ); 497 498 idx = str3.find_first_of('A', 6); 499 test_eq( 500 "find first of char (fail)", 501 idx, miss 502 ); 503 504 idx = str3.find_last_of(target); 505 test_eq( 506 "find last of from start (success)", 507 idx, 8ul 508 ); 509 510 idx = str3.find_last_of(target, 6); 511 test_eq( 512 "find last of from middle (success)", 513 idx, 5ul 514 ); 515 516 idx = str3.find_last_of("DEF", 3); 517 test_eq( 518 "find last of from middle (fail, not in string)", 519 idx, miss 520 ); 521 522 idx = str3.find_last_of(target, 1); 523 test_eq( 524 "find last of from middle (fail, late start)", 525 idx, miss 526 ); 527 528 idx = str3.find_last_of(""); 529 test_eq( 530 "find last of from start (fail, no target)", 531 idx, miss 532 ); 533 534 idx = str3.find_last_of('A', str3.size() - 1); 535 test_eq( 536 "find last of char (success)", 537 idx, 5ul 538 ); 539 540 idx = str3.find_last_of('A', 3); 541 test_eq( 542 "find last of char (fail)", 543 idx, miss 544 ); 545 546 std::string not_target{"xB"}; 547 548 idx = str3.find_first_not_of(not_target); 549 test_eq( 550 "find first not of from start (success)", 551 idx, 5ul 552 ); 553 554 idx = str3.find_first_not_of(not_target, 6); 555 test_eq( 556 "find first not of from middle (success)", 557 idx, 8ul 558 ); 559 560 idx = str3.find_first_not_of("xABC", 3); 561 test_eq( 562 "find first not of from middle (fail, not in string)", 563 idx, miss 564 ); 565 566 idx = str3.find_first_not_of(not_target, 9); 567 test_eq( 568 "find first not of from middle (fail, late start)", 569 idx, miss 570 ); 571 572 idx = str3.find_first_not_of(""); 573 test_eq( 574 "find first not of from start (success, no target)", 575 idx, 0ul 576 ); 577 578 idx = str3.find_first_not_of('x', 3); 579 test_eq( 580 "find first not of char (success)", 581 idx, 5ul 582 ); 583 584 idx = str3.find_first_of('a', 9); 585 test_eq( 586 "find first not of char (fail)", 587 idx, miss 588 ); 589 590 std::string not_last_target{"xC"}; 591 592 idx = str3.find_last_not_of(not_last_target); 593 test_eq( 594 "find last not of from start (success)", 595 idx, 5ul 596 ); 597 598 idx = str3.find_last_not_of(not_last_target, 4); 599 test_eq( 600 "find last not of from middle (success)", 601 idx, 2ul 602 ); 603 604 idx = str3.find_last_not_of("xABC"); 605 test_eq( 606 "find last not of from middle (fail, not in string)", 607 idx, miss 608 ); 609 610 idx = str3.find_last_not_of(not_last_target, 1); 611 test_eq( 612 "find last not of from middle (fail, late start)", 613 idx, miss 614 ); 615 616 idx = str3.find_last_not_of(""); 617 test_eq( 618 "find last not of from start (success, no target)", 619 idx, str3.size() - 1 620 ); 621 622 idx = str3.find_last_not_of('x', str3.size() - 1); 623 test_eq( 624 "find last not of char (success)", 625 idx, 8ul 626 ); 627 628 idx = str3.find_last_not_of('x', 1); 629 test_eq( 630 "find last not of char (fail)", 631 idx, miss 632 ); 429 633 } 430 634 }
Note:
See TracChangeset
for help on using the changeset viewer.