| 1670 | // absolute_tests -----------------------------------------------------------------// |
| 1671 | |
| 1672 | void absolute_tests() |
| 1673 | { |
| 1674 | cout << "absolute_tests..." << endl; |
| 1675 | |
| 1676 | #if BOOST_FILESYSTEM_VERSION == 3 |
| 1677 | BOOST_TEST_EQ(fs::absolute(""), fs::current_path()); |
| 1678 | BOOST_TEST_EQ(fs::absolute("", ""), fs::current_path()); |
| 1679 | #else |
| 1680 | BOOST_TEST_EQ(fs::absolute(""), fs::current_path() / fs::path()); |
| 1681 | BOOST_TEST_EQ(fs::absolute("", ""), fs::current_path() / fs::path()); |
| 1682 | #endif |
| 1683 | BOOST_TEST_EQ(fs::absolute(fs::current_path() / "foo/bar"), fs::current_path() / "foo/bar"); |
| 1684 | BOOST_TEST_EQ(fs::absolute("foo"), fs::current_path() / "foo"); |
| 1685 | BOOST_TEST_EQ(fs::absolute("foo", fs::current_path()), fs::current_path() / "foo"); |
| 1686 | BOOST_TEST_EQ(fs::absolute("bar", "foo"), fs::current_path() / "foo" / "bar"); |
| 1687 | BOOST_TEST_EQ(fs::absolute("/foo"), fs::current_path().root_path().string() + "foo"); |
| 1688 | |
| 1689 | #ifdef BOOST_FILESYSTEM_WINDOWS_API |
| 1690 | BOOST_TEST_EQ(fs::absolute("a:foo", "b:/bar"), fs::path(L"a:/bar/foo")); |
| 1691 | #endif |
| 1692 | |
| 1693 | // these tests were moved from elsewhere, so may duplicate some of the above tests |
| 1694 | |
| 1695 | // p.empty() |
| 1696 | #if BOOST_FILESYSTEM_VERSION == 3 |
| 1697 | BOOST_TEST_EQ(fs::absolute(fs::path(), "//foo/bar"), fs::path("//foo/bar")); |
| 1698 | if (platform == "Windows") |
| 1699 | { |
| 1700 | BOOST_TEST_EQ(fs::absolute(fs::path(), "a:/bar"), fs::path("a:/bar")); |
| 1701 | } |
| 1702 | #else |
| 1703 | BOOST_TEST_EQ(fs::absolute(fs::path(), "//foo/bar"), fs::path("//foo/bar/")); |
| 1704 | if (platform == "Windows") |
| 1705 | { |
| 1706 | BOOST_TEST_EQ(fs::absolute(fs::path(), "a:/bar"), fs::path("a:/bar/")); |
| 1707 | } |
| 1708 | #endif |
| 1709 | |
| 1710 | // p.has_root_name() |
| 1711 | // p.has_root_directory() |
| 1712 | BOOST_TEST_EQ(fs::absolute(fs::path("//foo/bar"), "//uvw/xyz"), fs::path("//foo/bar")); |
| 1713 | if (platform == "Windows") |
| 1714 | { |
| 1715 | BOOST_TEST_EQ(fs::absolute(fs::path("a:/bar"), "b:/xyz"), fs::path("a:/bar")); |
| 1716 | } |
| 1717 | // !p.has_root_directory() |
| 1718 | BOOST_TEST_EQ(fs::absolute(fs::path("//net"), "//xyz/"), fs::path("//net/")); |
| 1719 | #if BOOST_FILESYSTEM_VERSION == 3 |
| 1720 | BOOST_TEST_EQ(fs::absolute(fs::path("//net"), "//xyz/abc"), fs::path("//net/abc")); |
| 1721 | BOOST_TEST_EQ(fs::absolute(fs::path("//net"), "//xyz/abc/def"), fs::path("//net/abc/def")); |
| 1722 | #else |
| 1723 | BOOST_TEST_EQ(fs::absolute(fs::path("//net"), "//xyz/abc"), fs::path("//net/abc/")); |
| 1724 | BOOST_TEST_EQ(fs::absolute(fs::path("//net"), "//xyz/abc/def"), fs::path("//net/abc/def/")); |
| 1725 | #endif |
| 1726 | if (platform == "Windows") |
| 1727 | { |
| 1728 | BOOST_TEST_EQ(fs::absolute(fs::path("a:"), "b:/"), fs::path("a:/")); |
| 1729 | #if BOOST_FILESYSTEM_VERSION == 3 |