diff options
author | Eric Fiselier <eric@efcs.ca> | 2017-03-02 23:18:40 +0000 |
---|---|---|
committer | Eric Fiselier <eric@efcs.ca> | 2017-03-02 23:18:40 +0000 |
commit | ae85a922d5159966af7ac53cc5c8b712749a4a86 (patch) | |
tree | d85c4fcd8015a10027bbd04c0a79ff3d52ea590b /libcxx/test/std/strings/basic.string/string.modifiers/string_replace | |
parent | 3baa72af7d65c3d5199b3d57bfa2b6c1268306b2 (diff) | |
download | bcm5719-llvm-ae85a922d5159966af7ac53cc5c8b712749a4a86.tar.gz bcm5719-llvm-ae85a922d5159966af7ac53cc5c8b712749a4a86.zip |
Work around test failure on 32 bit OS X
llvm-svn: 296840
Diffstat (limited to 'libcxx/test/std/strings/basic.string/string.modifiers/string_replace')
-rw-r--r-- | libcxx/test/std/strings/basic.string/string.modifiers/string_replace/size_size_T_size_size.pass.cpp | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/libcxx/test/std/strings/basic.string/string.modifiers/string_replace/size_size_T_size_size.pass.cpp b/libcxx/test/std/strings/basic.string/string.modifiers/string_replace/size_size_T_size_size.pass.cpp index 840b7614f48..dbf5f5b6444 100644 --- a/libcxx/test/std/strings/basic.string/string.modifiers/string_replace/size_size_T_size_size.pass.cpp +++ b/libcxx/test/std/strings/basic.string/string.modifiers/string_replace/size_size_T_size_size.pass.cpp @@ -29,16 +29,22 @@ test(S s, typename S::size_type pos1, typename S::size_type n1, SV sv, typename S::size_type pos2, typename S::size_type n2, S expected) { + typedef typename S::size_type SizeT; static_assert((!std::is_same<S, SV>::value), ""); - const typename S::size_type old_size = s.size(); + + // String and string_view may not always share the same size type, + // but both types should have the same size (ex. int vs long) + static_assert(sizeof(SizeT) == sizeof(typename SV::size_type), ""); + + const SizeT old_size = s.size(); S s0 = s; if (pos1 <= old_size && pos2 <= sv.size()) { s.replace(pos1, n1, sv, pos2, n2); LIBCPP_ASSERT(s.__invariants()); assert(s == expected); - typename S::size_type xlen = std::min(n1, old_size - pos1); - typename S::size_type rlen = std::min(n2, sv.size() - pos2); + SizeT xlen = std::min<SizeT>(n1, old_size - pos1); + SizeT rlen = std::min<SizeT>(n2, sv.size() - pos2); assert(s.size() == old_size - xlen + rlen); } #ifndef TEST_HAS_NO_EXCEPTIONS @@ -64,16 +70,17 @@ test_npos(S s, typename S::size_type pos1, typename S::size_type n1, SV sv, typename S::size_type pos2, S expected) { + typedef typename S::size_type SizeT; static_assert((!std::is_same<S, SV>::value), ""); - const typename S::size_type old_size = s.size(); + const SizeT old_size = s.size(); S s0 = s; if (pos1 <= old_size && pos2 <= sv.size()) { s.replace(pos1, n1, sv, pos2); LIBCPP_ASSERT(s.__invariants()); assert(s == expected); - typename S::size_type xlen = std::min(n1, old_size - pos1); - typename S::size_type rlen = std::min(S::npos, sv.size() - pos2); + SizeT xlen = std::min<SizeT>(n1, old_size - pos1); + SizeT rlen = std::min<SizeT>(S::npos, sv.size() - pos2); assert(s.size() == old_size - xlen + rlen); } #ifndef TEST_HAS_NO_EXCEPTIONS |