aboutsummaryrefslogtreecommitdiff
path: root/test/std/experimental/string.view/string.view.ops/compare.pointer_size.pass.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'test/std/experimental/string.view/string.view.ops/compare.pointer_size.pass.cpp')
-rw-r--r--test/std/experimental/string.view/string.view.ops/compare.pointer_size.pass.cpp24
1 files changed, 16 insertions, 8 deletions
diff --git a/test/std/experimental/string.view/string.view.ops/compare.pointer_size.pass.cpp b/test/std/experimental/string.view/string.view.ops/compare.pointer_size.pass.cpp
index 7ccbd528c7fc..cfe35fcb4719 100644
--- a/test/std/experimental/string.view/string.view.ops/compare.pointer_size.pass.cpp
+++ b/test/std/experimental/string.view/string.view.ops/compare.pointer_size.pass.cpp
@@ -7,7 +7,6 @@
//
//===----------------------------------------------------------------------===//
-// XFAIL: libcpp-no-exceptions
// <string_view>
// constexpr int compare(size_type pos1, size_type n1, const charT* s) const;
@@ -15,18 +14,27 @@
#include <experimental/string_view>
#include <cassert>
+#include "test_macros.h"
#include "constexpr_char_traits.hpp"
int sign ( int x ) { return x > 0 ? 1 : ( x < 0 ? -1 : 0 ); }
template<typename CharT>
-void test1 ( std::experimental::basic_string_view<CharT> sv1,
+void test1 ( std::experimental::basic_string_view<CharT> sv1,
size_t pos1, size_t n1, const CharT *s, int expected ) {
- try {
+ if (pos1 > sv1.size()) {
+#ifndef TEST_HAS_NO_EXCEPTIONS
+ try {
+ sv1.compare(pos1, n1, s);
+ assert(false);
+ } catch (const std::out_of_range&) {
+ } catch (...) {
+ assert(false);
+ }
+#endif
+ } else {
assert(sign(sv1.compare(pos1, n1, s)) == sign(expected));
- assert(pos1 <= sv1.size());
}
- catch (const std::out_of_range&) { assert(pos1 > sv1.size()); }
}
template<typename CharT>
@@ -391,7 +399,7 @@ int main()
test(L"abcdefghijklmnopqrst", 0, -1, L"abcdefghijklmnopqrst", 0);
}
-#if __cplusplus >= 201103L
+#if TEST_STD_VER >= 11
{
test(U"", 0, 0, U"", 0);
test(U"", 0, 0, U"abcde", -5);
@@ -410,7 +418,7 @@ int main()
test(U"abcdefghijklmnopqrst", 0, 12, U"abcdefghij", 10);
test(U"abcdefghijklmnopqrst", 0, -1, U"abcdefghijklmnopqrst", 0);
}
-
+
{
test(u"", 0, 0, u"", 0);
test(u"", 0, 0, u"abcde", -5);
@@ -431,7 +439,7 @@ int main()
}
#endif
-#if _LIBCPP_STD_VER > 11
+#if TEST_STD_VER > 11
{
typedef std::experimental::basic_string_view<char, constexpr_char_traits<char>> SV;
constexpr SV sv1;