mirror of
https://github.com/llvm-mirror/libcxx.git
synced 2025-10-24 20:29:39 +08:00
Implement P0392r0. Integrate filesystem::path and string_view.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@276511 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -14,8 +14,9 @@
|
||||
// class path
|
||||
|
||||
// path& operator+=(const path& x);
|
||||
// path& operator+=(const string_type& x); // Implemented as Source template
|
||||
// path& operator+=(const value_type* x); // Implemented as Source template
|
||||
// path& operator+=(const string_type& x);
|
||||
// path& operator+=(string_view x);
|
||||
// path& operator+=(const value_type* x);
|
||||
// path& operator+=(value_type x);
|
||||
// template <class Source>
|
||||
// path& operator+=(const Source& x);
|
||||
@@ -29,6 +30,8 @@
|
||||
|
||||
#include <experimental/filesystem>
|
||||
#include <type_traits>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <cassert>
|
||||
|
||||
#include "test_macros.h"
|
||||
@@ -82,6 +85,7 @@ void doConcatSourceAllocTest(ConcatOperatorTestcase const& TC)
|
||||
using namespace fs;
|
||||
using Ptr = CharT const*;
|
||||
using Str = std::basic_string<CharT>;
|
||||
using StrView = std::basic_string_view<CharT>;
|
||||
using InputIter = input_iterator<Ptr>;
|
||||
|
||||
const Ptr L = TC.lhs;
|
||||
@@ -98,6 +102,16 @@ void doConcatSourceAllocTest(ConcatOperatorTestcase const& TC)
|
||||
}
|
||||
assert(LHS == E);
|
||||
}
|
||||
// basic_string_view
|
||||
{
|
||||
path LHS(L); PathReserve(LHS, ReserveSize);
|
||||
StrView RHS(R);
|
||||
{
|
||||
DisableAllocationGuard g;
|
||||
LHS += RHS;
|
||||
}
|
||||
assert(LHS == E);
|
||||
}
|
||||
// CharT*
|
||||
{
|
||||
path LHS(L); PathReserve(LHS, ReserveSize);
|
||||
@@ -152,6 +166,7 @@ void doConcatSourceTest(ConcatOperatorTestcase const& TC)
|
||||
using namespace fs;
|
||||
using Ptr = CharT const*;
|
||||
using Str = std::basic_string<CharT>;
|
||||
using StrView = std::basic_string_view<CharT>;
|
||||
using InputIter = input_iterator<Ptr>;
|
||||
const Ptr L = TC.lhs;
|
||||
const Ptr R = TC.rhs;
|
||||
@@ -171,6 +186,21 @@ void doConcatSourceTest(ConcatOperatorTestcase const& TC)
|
||||
assert(LHS == E);
|
||||
assert(&Ref == &LHS);
|
||||
}
|
||||
// basic_string_view
|
||||
{
|
||||
path LHS(L);
|
||||
StrView RHS(R);
|
||||
path& Ref = (LHS += RHS);
|
||||
assert(LHS == E);
|
||||
assert(&Ref == &LHS);
|
||||
}
|
||||
{
|
||||
path LHS(L);
|
||||
StrView RHS(R);
|
||||
path& Ref = LHS.concat(RHS);
|
||||
assert(LHS == E);
|
||||
assert(&Ref == &LHS);
|
||||
}
|
||||
// Char*
|
||||
{
|
||||
path LHS(L);
|
||||
@@ -246,6 +276,13 @@ int main()
|
||||
assert(LHS == (const char*)TC.expect);
|
||||
assert(&Ref == &LHS);
|
||||
}
|
||||
{
|
||||
path LHS((const char*)TC.lhs);
|
||||
std::string_view RHS((const char*)TC.rhs);
|
||||
path& Ref = (LHS += RHS);
|
||||
assert(LHS == (const char*)TC.expect);
|
||||
assert(&Ref == &LHS);
|
||||
}
|
||||
doConcatSourceTest<char> (TC);
|
||||
doConcatSourceTest<wchar_t> (TC);
|
||||
doConcatSourceTest<char16_t>(TC);
|
||||
@@ -265,6 +302,18 @@ int main()
|
||||
}
|
||||
assert(LHS == E);
|
||||
}
|
||||
{
|
||||
path LHS((const char*)TC.lhs);
|
||||
std::string_view RHS((const char*)TC.rhs);
|
||||
const char* E = TC.expect;
|
||||
PathReserve(LHS, StrLen(E) + 5);
|
||||
{
|
||||
DisableAllocationGuard g;
|
||||
path& Ref = (LHS += RHS);
|
||||
assert(&Ref == &LHS);
|
||||
}
|
||||
assert(LHS == E);
|
||||
}
|
||||
doConcatSourceAllocTest<char>(TC);
|
||||
doConcatSourceAllocTest<wchar_t>(TC);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user