summaryrefslogtreecommitdiffstats
path: root/libcxx/test/std/experimental/filesystem/class.path/path.member/path.concat.pass.cpp
diff options
context:
space:
mode:
authorEric Fiselier <eric@efcs.ca>2016-07-23 03:10:56 +0000
committerEric Fiselier <eric@efcs.ca>2016-07-23 03:10:56 +0000
commit0fdab5eb69ca4b2e9048526b33948af72976c7bc (patch)
treef46bce4590d4f9abf9281f6e0998bc8cbb6e57f8 /libcxx/test/std/experimental/filesystem/class.path/path.member/path.concat.pass.cpp
parent796331c026a6cd33624c0f22e4e289fc89093b43 (diff)
downloadbcm5719-llvm-0fdab5eb69ca4b2e9048526b33948af72976c7bc.tar.gz
bcm5719-llvm-0fdab5eb69ca4b2e9048526b33948af72976c7bc.zip
Implement P0392r0. Integrate filesystem::path and string_view.
llvm-svn: 276511
Diffstat (limited to 'libcxx/test/std/experimental/filesystem/class.path/path.member/path.concat.pass.cpp')
-rw-r--r--libcxx/test/std/experimental/filesystem/class.path/path.member/path.concat.pass.cpp53
1 files changed, 51 insertions, 2 deletions
diff --git a/libcxx/test/std/experimental/filesystem/class.path/path.member/path.concat.pass.cpp b/libcxx/test/std/experimental/filesystem/class.path/path.member/path.concat.pass.cpp
index 6e00afe0b49..cd627b8c842 100644
--- a/libcxx/test/std/experimental/filesystem/class.path/path.member/path.concat.pass.cpp
+++ b/libcxx/test/std/experimental/filesystem/class.path/path.member/path.concat.pass.cpp
@@ -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);
}
OpenPOWER on IntegriCloud