| 610 | |
| 611 | template <class StringType> |
| 612 | void TestDrawTable() { |
| 613 | struct TestCase { |
| 614 | std::string name; |
| 615 | |
| 616 | std::vector<std::vector<StringType>> table; |
| 617 | bool with_header; |
| 618 | |
| 619 | std::string want_result; |
| 620 | }; |
| 621 | std::vector<TestCase> test_cases; |
| 622 | |
| 623 | test_cases.emplace_back( |
| 624 | TestCase{ |
| 625 | .name = "case 1", |
| 626 | .table = {}, |
| 627 | .with_header = true, |
| 628 | .want_result = "\n<empty table>"}); |
| 629 | test_cases.emplace_back( |
| 630 | TestCase{ |
| 631 | .name = "case 2", |
| 632 | .table = {{"111", "222", "333"}, |
| 633 | {"4444", "5555", "6666"}, |
| 634 | {"77777", "88888", "99999"}}, |
| 635 | .with_header = true, |
| 636 | .want_result = R"str( |
| 637 | +-------+-------+-------+ |
| 638 | | 111 | 222 | 333 | |
| 639 | +-------+-------+-------+ |
| 640 | | 4444 | 5555 | 6666 | |
| 641 | | 77777 | 88888 | 99999 | |
| 642 | +-------+-------+-------+ |
| 643 | )str"}); |
| 644 | test_cases.emplace_back( |
| 645 | TestCase{ |
| 646 | .name = "case 3", |
| 647 | .table = {{"111"}, |
| 648 | {"4444", "5555", "6666"}, |
| 649 | {"77777", "88888"}}, |
| 650 | .with_header = false, |
| 651 | .want_result = R"str( |
| 652 | +-------+-------+------+ |
| 653 | | 111 | | | |
| 654 | | 4444 | 5555 | 6666 | |
| 655 | | 77777 | 88888 | | |
| 656 | +-------+-------+------+ |
| 657 | )str"}); |
| 658 | |
| 659 | test_cases.emplace_back( |
| 660 | TestCase{ |
| 661 | .name = "case 4", |
| 662 | .table = {{"111", "222", "333"}, |
| 663 | {"4444", "5\n55\n5", "6666"}, |
| 664 | {"77777", "88888", "99999"}}, |
| 665 | .with_header = true, |
| 666 | .want_result = R"str( |
| 667 | +-------+-------+-------+ |
| 668 | | 111 | 222 | 333 | |
| 669 | +-------+-------+-------+ |
nothing calls this directly
no outgoing calls
no test coverage detected