diff options
4 files changed, 84 insertions, 44 deletions
diff --git a/libcxx/test/std/utilities/template.bitset/bitset.members/flip_one.pass.cpp b/libcxx/test/std/utilities/template.bitset/bitset.members/flip_one.pass.cpp index 88ce8e943ca..18a64a214a4 100644 --- a/libcxx/test/std/utilities/template.bitset/bitset.members/flip_one.pass.cpp +++ b/libcxx/test/std/utilities/template.bitset/bitset.members/flip_one.pass.cpp @@ -7,13 +7,14 @@ // //===----------------------------------------------------------------------===// -// XFAIL: libcpp-no-exceptions // test bitset<N>& flip(size_t pos); #include <bitset> #include <cstdlib> #include <cassert> +#include "test_macros.h" + template <std::size_t N> std::bitset<N> make_bitset() @@ -25,11 +26,15 @@ make_bitset() } template <std::size_t N> -void test_flip_one() +void test_flip_one(bool test_throws) { std::bitset<N> v = make_bitset<N>(); +#ifdef TEST_HAS_NO_EXCEPTIONS + if (test_throws) return; +#else try { +#endif v.flip(50); bool b = v[50]; if (50 >= v.size()) @@ -39,21 +44,25 @@ void test_flip_one() assert(v[50] != b); v.flip(50); assert(v[50] == b); + assert(!test_throws); +#ifndef TEST_HAS_NO_EXCEPTIONS } catch (std::out_of_range&) { + assert(test_throws); } +#endif } int main() { - test_flip_one<0>(); - test_flip_one<1>(); - test_flip_one<31>(); - test_flip_one<32>(); - test_flip_one<33>(); - test_flip_one<63>(); - test_flip_one<64>(); - test_flip_one<65>(); - test_flip_one<1000>(); + test_flip_one<0>(true); + test_flip_one<1>(true); + test_flip_one<31>(true); + test_flip_one<32>(true); + test_flip_one<33>(true); + test_flip_one<63>(false); + test_flip_one<64>(false); + test_flip_one<65>(false); + test_flip_one<1000>(false); } diff --git a/libcxx/test/std/utilities/template.bitset/bitset.members/reset_one.pass.cpp b/libcxx/test/std/utilities/template.bitset/bitset.members/reset_one.pass.cpp index f01d35b9a33..6847694e4b7 100644 --- a/libcxx/test/std/utilities/template.bitset/bitset.members/reset_one.pass.cpp +++ b/libcxx/test/std/utilities/template.bitset/bitset.members/reset_one.pass.cpp @@ -7,18 +7,23 @@ // //===----------------------------------------------------------------------===// -// XFAIL: libcpp-no-exceptions // test bitset<N>& reset(size_t pos); #include <bitset> #include <cassert> +#include "test_macros.h" + template <std::size_t N> -void test_reset_one() +void test_reset_one(bool test_throws) { std::bitset<N> v; +#ifdef TEST_HAS_NO_EXCEPTIONS + if (test_throws) return; +#else try { +#endif v.set(); v.reset(50); if (50 >= v.size()) @@ -28,21 +33,25 @@ void test_reset_one() assert(!v[i]); else assert(v[i]); + assert(!test_throws); +#ifndef TEST_HAS_NO_EXCEPTIONS } catch (std::out_of_range&) { + assert(test_throws); } +#endif } int main() { - test_reset_one<0>(); - test_reset_one<1>(); - test_reset_one<31>(); - test_reset_one<32>(); - test_reset_one<33>(); - test_reset_one<63>(); - test_reset_one<64>(); - test_reset_one<65>(); - test_reset_one<1000>(); + test_reset_one<0>(true); + test_reset_one<1>(true); + test_reset_one<31>(true); + test_reset_one<32>(true); + test_reset_one<33>(true); + test_reset_one<63>(false); + test_reset_one<64>(false); + test_reset_one<65>(false); + test_reset_one<1000>(false); } diff --git a/libcxx/test/std/utilities/template.bitset/bitset.members/set_one.pass.cpp b/libcxx/test/std/utilities/template.bitset/bitset.members/set_one.pass.cpp index debe5431d8d..1c8d6a1c32a 100644 --- a/libcxx/test/std/utilities/template.bitset/bitset.members/set_one.pass.cpp +++ b/libcxx/test/std/utilities/template.bitset/bitset.members/set_one.pass.cpp @@ -7,47 +7,60 @@ // //===----------------------------------------------------------------------===// -// XFAIL: libcpp-no-exceptions // test bitset<N>& set(size_t pos, bool val = true); #include <bitset> #include <cassert> +#include "test_macros.h" + template <std::size_t N> -void test_set_one() +void test_set_one(bool test_throws) { std::bitset<N> v; +#ifdef TEST_HAS_NO_EXCEPTIONS + if (test_throws) return; +#else try +#endif { v.set(50); if (50 >= v.size()) assert(false); assert(v[50]); + assert(!test_throws); } +#ifndef TEST_HAS_NO_EXCEPTIONS catch (std::out_of_range&) { + assert(test_throws); } try +#endif { v.set(50, false); if (50 >= v.size()) assert(false); assert(!v[50]); + assert(!test_throws); } +#ifndef TEST_HAS_NO_EXCEPTIONS catch (std::out_of_range&) { + assert(test_throws); } +#endif } int main() { - test_set_one<0>(); - test_set_one<1>(); - test_set_one<31>(); - test_set_one<32>(); - test_set_one<33>(); - test_set_one<63>(); - test_set_one<64>(); - test_set_one<65>(); - test_set_one<1000>(); + test_set_one<0>(true); + test_set_one<1>(true); + test_set_one<31>(true); + test_set_one<32>(true); + test_set_one<33>(true); + test_set_one<63>(false); + test_set_one<64>(false); + test_set_one<65>(false); + test_set_one<1000>(false); } diff --git a/libcxx/test/std/utilities/template.bitset/bitset.members/test.pass.cpp b/libcxx/test/std/utilities/template.bitset/bitset.members/test.pass.cpp index 161afd11c29..1a2d70613e1 100644 --- a/libcxx/test/std/utilities/template.bitset/bitset.members/test.pass.cpp +++ b/libcxx/test/std/utilities/template.bitset/bitset.members/test.pass.cpp @@ -7,13 +7,14 @@ // //===----------------------------------------------------------------------===// -// XFAIL: libcpp-no-exceptions // test constexpr bool test(size_t pos) const; #include <bitset> #include <cstdlib> #include <cassert> +#include "test_macros.h" + template <std::size_t N> std::bitset<N> make_bitset() @@ -25,30 +26,38 @@ make_bitset() } template <std::size_t N> -void test_test() +void test_test(bool test_throws) { const std::bitset<N> v1 = make_bitset<N>(); +#ifdef TEST_HAS_NO_EXCEPTIONS + if (test_throws) return; +#else try { +#endif bool b = v1.test(50); if (50 >= v1.size()) assert(false); assert(b == v1[50]); + assert(!test_throws); +#ifndef TEST_HAS_NO_EXCEPTIONS } catch (std::out_of_range&) { + assert(test_throws); } +#endif } int main() { - test_test<0>(); - test_test<1>(); - test_test<31>(); - test_test<32>(); - test_test<33>(); - test_test<63>(); - test_test<64>(); - test_test<65>(); - test_test<1000>(); + test_test<0>(true); + test_test<1>(true); + test_test<31>(true); + test_test<32>(true); + test_test<33>(true); + test_test<63>(false); + test_test<64>(false); + test_test<65>(false); + test_test<1000>(false); } |