Implement P0430R2 - File system library on non-POSIX systems.

This patch implements P0430R2, who's largest change is adding the path::format
enumeration for supporting path format conversions in path constructors.

However, since libc++'s filesystem only really supports POSIX like systems,
there are no real changes needed. This patch simply adds the format enum
and then ignores it when it's passed to constructors.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@329031 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Eric Fiselier
2018-04-02 23:35:24 +00:00
parent 1e34c76d33
commit e96d6a1fb7
4 changed files with 69 additions and 14 deletions

View File

@@ -29,8 +29,8 @@
#include "filesystem_test_helper.hpp"
template <class CharT>
void RunTestCase(MultiStringType const& MS) {
template <class CharT, class ...Args>
void RunTestCaseImpl(MultiStringType const& MS, Args... args) {
using namespace fs;
const char* Expect = MS;
const CharT* TestPath = MS;
@@ -41,44 +41,52 @@ void RunTestCase(MultiStringType const& MS) {
// StringTypes
{
const std::basic_string<CharT> S(TestPath);
path p(S);
path p(S, args...);
assert(p.native() == Expect);
assert(p.string<CharT>() == TestPath);
assert(p.string<CharT>() == S);
}
{
const std::basic_string_view<CharT> S(TestPath);
path p(S);
path p(S, args...);
assert(p.native() == Expect);
assert(p.string<CharT>() == TestPath);
assert(p.string<CharT>() == S);
}
// Char* pointers
{
path p(TestPath);
path p(TestPath, args...);
assert(p.native() == Expect);
assert(p.string<CharT>() == TestPath);
}
{
path p(TestPath, TestPathEnd);
path p(TestPath, TestPathEnd, args...);
assert(p.native() == Expect);
assert(p.string<CharT>() == TestPath);
}
// Iterators
{
using It = input_iterator<const CharT*>;
path p(It{TestPath});
path p(It{TestPath}, args...);
assert(p.native() == Expect);
assert(p.string<CharT>() == TestPath);
}
{
using It = input_iterator<const CharT*>;
path p(It{TestPath}, It{TestPathEnd});
path p(It{TestPath}, It{TestPathEnd}, args...);
assert(p.native() == Expect);
assert(p.string<CharT>() == TestPath);
}
}
template <class CharT, class ...Args>
void RunTestCase(MultiStringType const& MS) {
RunTestCaseImpl<CharT>(MS);
RunTestCaseImpl<CharT>(MS, fs::path::format::auto_format);
RunTestCaseImpl<CharT>(MS, fs::path::format::native_format);
RunTestCaseImpl<CharT>(MS, fs::path::format::generic_format);
}
void test_sfinae() {
using namespace fs;
{