| 653 | // non_member_tests ----------------------------------------------------------------// |
| 654 | |
| 655 | void non_member_tests() |
| 656 | { |
| 657 | std::cout << "non_member_tests..." << std::endl; |
| 658 | |
| 659 | // test non-member functions, particularly operator overloads |
| 660 | |
| 661 | path e, e2; |
| 662 | std::string es, es2; |
| 663 | char ecs[] = ""; |
| 664 | char ecs2[] = ""; |
| 665 | |
| 666 | char acs[] = "a"; |
| 667 | std::string as(acs); |
| 668 | path a(as); |
| 669 | |
| 670 | char acs2[] = "a"; |
| 671 | std::string as2(acs2); |
| 672 | path a2(as2); |
| 673 | |
| 674 | char bcs[] = "b"; |
| 675 | std::string bs(bcs); |
| 676 | path b(bs); |
| 677 | |
| 678 | // swap |
| 679 | a.swap(b); |
| 680 | BOOST_TEST(a.string() == "b"); |
| 681 | BOOST_TEST(b.string() == "a"); |
| 682 | fs::swap(a, b); |
| 683 | BOOST_TEST(a.string() == "a"); |
| 684 | BOOST_TEST(b.string() == "b"); |
| 685 | |
| 686 | // probe operator / |
| 687 | PATH_TEST_EQ(path("") / ".", "."); |
| 688 | PATH_TEST_EQ(path("") / "..", ".."); |
| 689 | #if BOOST_FILESYSTEM_VERSION == 3 |
| 690 | PATH_TEST_EQ(path("/") / "/", "//"); |
| 691 | PATH_TEST_EQ(path("/") / "/foo", "//foo"); |
| 692 | PATH_TEST_EQ(path("/foo") / "/bar", "/foo/bar"); |
| 693 | #else |
| 694 | PATH_TEST_EQ(path("/") / "/", "/"); |
| 695 | PATH_TEST_EQ(path("/") / "/foo", "/foo"); |
| 696 | PATH_TEST_EQ(path("/foo") / "/bar", "/bar"); |
| 697 | #endif |
| 698 | |
| 699 | if (platform == "Windows") |
| 700 | { |
| 701 | BOOST_TEST(path("foo\\bar") == "foo/bar"); |
| 702 | BOOST_TEST((b / a).native() == path("b\\a").native()); |
| 703 | BOOST_TEST((bs / a).native() == path("b\\a").native()); |
| 704 | BOOST_TEST((bcs / a).native() == path("b\\a").native()); |
| 705 | BOOST_TEST((b / as).native() == path("b\\a").native()); |
| 706 | BOOST_TEST((b / acs).native() == path("b\\a").native()); |
| 707 | PATH_TEST_EQ(path("a") / "b", "a\\b"); |
| 708 | PATH_TEST_EQ(path("foo") / path("bar"), "foo\\bar"); // path arg |
| 709 | PATH_TEST_EQ(path("foo") / "bar", "foo\\bar"); // const char* arg |
| 710 | PATH_TEST_EQ(path("foo") / path("woo/bar").filename(), "foo\\bar"); // const std::string & arg |
| 711 | PATH_TEST_EQ("foo" / path("bar"), "foo\\bar"); |
| 712 | #if BOOST_FILESYSTEM_VERSION == 3 |