diff options
author | Eric Fiselier <eric@efcs.ca> | 2016-06-18 04:10:23 +0000 |
---|---|---|
committer | Eric Fiselier <eric@efcs.ca> | 2016-06-18 04:10:23 +0000 |
commit | dc62be191503c932a2025b2489c2da0c55d46ec3 (patch) | |
tree | 2f27bf31ff1394a195868a82ac392df75b8eb59d /libcxx/test/std/experimental/filesystem/class.path/path.member | |
parent | f4b2af1b9fca5181b63af10d9d630c287ff0acca (diff) | |
download | bcm5719-llvm-dc62be191503c932a2025b2489c2da0c55d46ec3.tar.gz bcm5719-llvm-dc62be191503c932a2025b2489c2da0c55d46ec3.zip |
Fix 3 bugs in filesystem tests and implementation.
This patch fixes the following bugs, all of which were discovered while
testing a 32 bit build on a 64 bit machine.
* path.itr/iterator.pass.cpp has undefined behavior.
'path::iterator' stashes the value of the element inside the iterator.
This violates the BiDirIterator requirements but is allowed for path::iterator.
However this means that using reverse_iterator<path::iterator> has undefined
behavior because it assumes that 'Iter tmp = it; return *tmp' will not create
a dangling reference. However it does, and this caused this particular test
to fail.
* path.native.obs/string_alloc.pass.cpp tested the SSO with a long string.
On 32 bit builds std::wstring only has the SSO for strings of size 2. The
test was using a string of size 4.
* fs.op.space/space.pass.cpp had overflows while calculating the expected values.
The fix here is to convert the statvfs data members to std::uintmax_t before
multiplying them. The internal implementation already does this but the tests
needed to do it as well.
llvm-svn: 273078
Diffstat (limited to 'libcxx/test/std/experimental/filesystem/class.path/path.member')
-rw-r--r-- | libcxx/test/std/experimental/filesystem/class.path/path.member/path.native.obs/string_alloc.pass.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
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 a4039219d8c..e9832973500 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 @@ -30,7 +30,8 @@ namespace fs = std::experimental::filesystem; -MultiStringType shortString = MKSTR("abc"); +// the SSO is always triggered for strings of size 2. +MultiStringType shortString = MKSTR("a"); MultiStringType longString = MKSTR("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ/123456789/abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"); template <class CharT> @@ -43,8 +44,6 @@ void doShortStringTest(MultiStringType const& MS) { const path p((const char*)MS); { DisableAllocationGuard g; - if (!std::is_same<CharT, char>::value) - g.release(); Str s = p.string<CharT>(); assert(s == value); Str s2 = p.string<CharT>(Alloc{}); @@ -55,6 +54,7 @@ void doShortStringTest(MultiStringType const& MS) { { 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); @@ -64,6 +64,7 @@ void doShortStringTest(MultiStringType const& MS) { { // 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; @@ -94,6 +95,7 @@ void doLongStringTest(MultiStringType const& MS) { { // 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); @@ -103,6 +105,7 @@ void doLongStringTest(MultiStringType const& MS) { { // 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; |