diff options
Diffstat (limited to 'libcxx/test/std/experimental/filesystem/class.path')
2 files changed, 57 insertions, 11 deletions
diff --git a/libcxx/test/std/experimental/filesystem/class.path/path.itr/iterator.pass.cpp b/libcxx/test/std/experimental/filesystem/class.path/path.itr/iterator.pass.cpp index 4aa8ebc25d5..c5c46f68ac1 100644 --- a/libcxx/test/std/experimental/filesystem/class.path/path.itr/iterator.pass.cpp +++ b/libcxx/test/std/experimental/filesystem/class.path/path.itr/iterator.pass.cpp @@ -24,6 +24,8 @@ #include <type_traits> #include <cassert> +#include <iostream> + #include "test_macros.h" #include "filesystem_test_helper.hpp" @@ -36,6 +38,29 @@ std::reverse_iterator<It> mkRev(It it) { } +template <class Iter1, class Iter2> +bool checkCollectionsEqualVerbose( + Iter1 start1, Iter1 const end1 + , Iter2 start2, Iter2 const end2 + ) +{ + while (start1 != end1 && start2 != end2) { + std::cout << "Got start1 = " << *start1 << "\n" + << "Got start2 = " << *start2 << "\n"; + if (*start1 != *start2) { + return false; + } + ++start1; ++start2; + } + if (start1 != end1) { + std::cout << "Got start1 = " << *start1 << " but expected end1\n"; + } + if (start2 != end2) { + std::cout << "Got start2 = " << *start2 << " but expected end2\n"; + } + return (start1 == end1 && start2 == end2); +} + void checkIteratorConcepts() { using namespace fs; using It = path::iterator; @@ -87,14 +112,18 @@ void checkBeginEndBasic() { path p("//root_name//first_dir////second_dir"); const path expect[] = {"//root_name", "/", "first_dir", "second_dir"}; assert(checkCollectionsEqual(p.begin(), p.end(), std::begin(expect), std::end(expect))); - assert(checkCollectionsEqual(mkRev(p.end()), mkRev(p.begin()), mkRev(std::end(expect)), mkRev(std::begin(expect)))); + assert(checkCollectionsEqualVerbose(mkRev(p.end()), mkRev(p.begin()), + mkRev(std::end(expect)), + mkRev(std::begin(expect)))); } { path p("////foo/bar/baz///"); const path expect[] = {"/", "foo", "bar", "baz", "."}; assert(checkCollectionsEqual(p.begin(), p.end(), std::begin(expect), std::end(expect))); - assert(checkCollectionsEqual(mkRev(p.end()), mkRev(p.begin()), mkRev(std::end(expect)), mkRev(std::begin(expect)))); + assert(checkCollectionsEqual(mkRev(p.end()), mkRev(p.begin()), + mkRev(std::end(expect)), mkRev(std::begin(expect)))); } + } int main() { diff --git a/libcxx/test/std/experimental/filesystem/class.path/path.member/path.native.obs/string_alloc.pass.cpp b/libcxx/test/std/experimental/filesystem/class.path/path.member/path.native.obs/string_alloc.pass.cpp index 4f90d64b8cd..a4039219d8c 100644 --- a/libcxx/test/std/experimental/filesystem/class.path/path.member/path.native.obs/string_alloc.pass.cpp +++ b/libcxx/test/std/experimental/filesystem/class.path/path.member/path.native.obs/string_alloc.pass.cpp @@ -27,7 +27,6 @@ #include "count_new.hpp" #include "min_allocator.h" #include "filesystem_test_helper.hpp" -#include "assert_checkpoint.h" namespace fs = std::experimental::filesystem; @@ -43,14 +42,37 @@ void doShortStringTest(MultiStringType const& MS) { Ptr value = MS; const path p((const char*)MS); { - DisableAllocationGuard g; // should not allocate - CHECKPOINT("short string default constructed allocator"); + DisableAllocationGuard g; + if (!std::is_same<CharT, char>::value) + g.release(); Str s = p.string<CharT>(); assert(s == value); - CHECKPOINT("short string provided allocator"); Str s2 = p.string<CharT>(Alloc{}); assert(s2 == value); } + using MAlloc = malloc_allocator<CharT>; + MAlloc::reset(); + { + using Traits = std::char_traits<CharT>; + using AStr = std::basic_string<CharT, Traits, MAlloc>; + AStr s = p.string<CharT, Traits, MAlloc>(); + assert(s == value); + assert(MAlloc::alloc_count == 0); + assert(MAlloc::outstanding_alloc() == 0); + } + MAlloc::reset(); + { // Other allocator - provided copy + using Traits = std::char_traits<CharT>; + using AStr = std::basic_string<CharT, Traits, MAlloc>; + MAlloc a; + // don't allow another allocator to be default constructed. + MAlloc::disable_default_constructor = true; + AStr s = p.string<CharT, Traits, MAlloc>(a); + assert(s == value); + assert(MAlloc::alloc_count == 0); + assert(MAlloc::outstanding_alloc() == 0); + } + MAlloc::reset(); } template <class CharT> @@ -62,7 +84,6 @@ void doLongStringTest(MultiStringType const& MS) { const path p((const char*)MS); { // Default allocator using Alloc = std::allocator<CharT>; - RequireAllocationGuard g; Str s = p.string<CharT>(); assert(s == value); Str s2 = p.string<CharT>(Alloc{}); @@ -70,22 +91,18 @@ void doLongStringTest(MultiStringType const& MS) { } using MAlloc = malloc_allocator<CharT>; MAlloc::reset(); - CHECKPOINT("Malloc allocator test - default construct"); { // Other allocator - default construct using Traits = std::char_traits<CharT>; using AStr = std::basic_string<CharT, Traits, MAlloc>; - DisableAllocationGuard g; AStr s = p.string<CharT, Traits, MAlloc>(); assert(s == value); assert(MAlloc::alloc_count > 0); assert(MAlloc::outstanding_alloc() == 1); } MAlloc::reset(); - CHECKPOINT("Malloc allocator test - provided copy"); { // Other allocator - provided copy using Traits = std::char_traits<CharT>; using AStr = std::basic_string<CharT, Traits, MAlloc>; - DisableAllocationGuard g; MAlloc a; // don't allow another allocator to be default constructed. MAlloc::disable_default_constructor = true; |