From dc62be191503c932a2025b2489c2da0c55d46ec3 Mon Sep 17 00:00:00 2001 From: Eric Fiselier Date: Sat, 18 Jun 2016 04:10:23 +0000 Subject: 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 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 --- libcxx/test/support/filesystem_test_helper.hpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'libcxx/test/support/filesystem_test_helper.hpp') diff --git a/libcxx/test/support/filesystem_test_helper.hpp b/libcxx/test/support/filesystem_test_helper.hpp index f902af4e57a..8dcf53aee75 100644 --- a/libcxx/test/support/filesystem_test_helper.hpp +++ b/libcxx/test/support/filesystem_test_helper.hpp @@ -361,6 +361,22 @@ bool checkCollectionsEqual( return (start1 == end1 && start2 == end2); } + +template +bool checkCollectionsEqualBackwards( + Iter1 const start1, Iter1 end1 + , Iter2 const start2, Iter2 end2 + ) +{ + while (start1 != end1 && start2 != end2) { + --end1; --end2; + if (*end1 != *end2) { + return false; + } + } + return (start1 == end1 && start2 == end2); +} + // We often need to test that the error_code was cleared if no error occurs // this function returns a error_code which is set to an error that will // never be returned by the filesystem functions. -- cgit v1.2.3