MCPcopy Create free account
hub / github.com/boostorg/filesystem / non_member_tests

Function non_member_tests

test/path_test.cpp:655–1015  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

653// non_member_tests ----------------------------------------------------------------//
654
655void 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

Callers 1

cpp_mainFunction · 0.85

Calls 9

swapFunction · 0.85
stringFunction · 0.85
swapMethod · 0.80
stringMethod · 0.80
filenameMethod · 0.80
generic_stringMethod · 0.80
pathFunction · 0.70
relativeFunction · 0.50
c_strMethod · 0.45

Tested by

no test coverage detected