summaryrefslogtreecommitdiffstats
path: root/libcxx/test/utilities/template.bitset/bitset.members
diff options
context:
space:
mode:
authorHoward Hinnant <hhinnant@apple.com>2010-08-22 00:59:46 +0000
committerHoward Hinnant <hhinnant@apple.com>2010-08-22 00:59:46 +0000
commit94b2dd0998230c758abd92c99d3700c971f7a31a (patch)
tree1b9f66ba0b4f8fd99fc02a112d4b7a30c4afe0f6 /libcxx/test/utilities/template.bitset/bitset.members
parentd9c6c0b583ac1f1efeec3db571a1028a3c9b7a99 (diff)
downloadbcm5719-llvm-94b2dd0998230c758abd92c99d3700c971f7a31a.tar.gz
bcm5719-llvm-94b2dd0998230c758abd92c99d3700c971f7a31a.zip
Fixing whitespace problems
llvm-svn: 111767
Diffstat (limited to 'libcxx/test/utilities/template.bitset/bitset.members')
-rw-r--r--libcxx/test/utilities/template.bitset/bitset.members/all.pass.cpp42
-rw-r--r--libcxx/test/utilities/template.bitset/bitset.members/any.pass.cpp45
-rw-r--r--libcxx/test/utilities/template.bitset/bitset.members/count.pass.cpp50
-rw-r--r--libcxx/test/utilities/template.bitset/bitset.members/flip_all.pass.cpp48
-rw-r--r--libcxx/test/utilities/template.bitset/bitset.members/flip_one.pass.cpp59
-rw-r--r--libcxx/test/utilities/template.bitset/bitset.members/index.pass.cpp66
-rw-r--r--libcxx/test/utilities/template.bitset/bitset.members/index_const.pass.cpp48
-rw-r--r--libcxx/test/utilities/template.bitset/bitset.members/left_shift.pass.cpp49
-rw-r--r--libcxx/test/utilities/template.bitset/bitset.members/left_shift_eq.pass.cpp54
-rw-r--r--libcxx/test/utilities/template.bitset/bitset.members/none.pass.cpp45
-rw-r--r--libcxx/test/utilities/template.bitset/bitset.members/not_all.pass.cpp47
-rw-r--r--libcxx/test/utilities/template.bitset/bitset.members/op_and_eq.pass.cpp49
-rw-r--r--libcxx/test/utilities/template.bitset/bitset.members/op_eq_eq.pass.cpp54
-rw-r--r--libcxx/test/utilities/template.bitset/bitset.members/op_or_eq.pass.cpp49
-rw-r--r--libcxx/test/utilities/template.bitset/bitset.members/op_xor_eq.pass.cpp49
-rw-r--r--libcxx/test/utilities/template.bitset/bitset.members/reset_all.pass.cpp37
-rw-r--r--libcxx/test/utilities/template.bitset/bitset.members/reset_one.pass.cpp48
-rw-r--r--libcxx/test/utilities/template.bitset/bitset.members/right_shift.pass.cpp49
-rw-r--r--libcxx/test/utilities/template.bitset/bitset.members/right_shift_eq.pass.cpp54
-rw-r--r--libcxx/test/utilities/template.bitset/bitset.members/set_all.pass.cpp36
-rw-r--r--libcxx/test/utilities/template.bitset/bitset.members/set_one.pass.cpp53
-rw-r--r--libcxx/test/utilities/template.bitset/bitset.members/size.pass.cpp34
-rw-r--r--libcxx/test/utilities/template.bitset/bitset.members/test.pass.cpp54
-rw-r--r--libcxx/test/utilities/template.bitset/bitset.members/to_string.pass.cpp161
-rw-r--r--libcxx/test/utilities/template.bitset/bitset.members/to_ullong.pass.cpp51
-rw-r--r--libcxx/test/utilities/template.bitset/bitset.members/to_ulong.pass.cpp51
26 files changed, 1356 insertions, 26 deletions
diff --git a/libcxx/test/utilities/template.bitset/bitset.members/all.pass.cpp b/libcxx/test/utilities/template.bitset/bitset.members/all.pass.cpp
index fbe6447b075..04ad5cefb5b 100644
--- a/libcxx/test/utilities/template.bitset/bitset.members/all.pass.cpp
+++ b/libcxx/test/utilities/template.bitset/bitset.members/all.pass.cpp
@@ -1 +1,41 @@
-//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // test bool all() const; #include <bitset> #include <cassert> template <std::size_t N> void test_all() { std::bitset<N> v; v.reset(); assert(v.all() == (N == 0)); v.set(); assert(v.all() == true); if (N > 1) { v[N/2] = false; assert(v.all() == false); } } int main() { test_all<0>(); test_all<1>(); test_all<31>(); test_all<32>(); test_all<33>(); test_all<63>(); test_all<64>(); test_all<65>(); test_all<1000>(); } \ No newline at end of file
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test bool all() const;
+
+#include <bitset>
+#include <cassert>
+
+template <std::size_t N>
+void test_all()
+{
+ std::bitset<N> v;
+ v.reset();
+ assert(v.all() == (N == 0));
+ v.set();
+ assert(v.all() == true);
+ if (N > 1)
+ {
+ v[N/2] = false;
+ assert(v.all() == false);
+ }
+}
+
+int main()
+{
+ test_all<0>();
+ test_all<1>();
+ test_all<31>();
+ test_all<32>();
+ test_all<33>();
+ test_all<63>();
+ test_all<64>();
+ test_all<65>();
+ test_all<1000>();
+}
diff --git a/libcxx/test/utilities/template.bitset/bitset.members/any.pass.cpp b/libcxx/test/utilities/template.bitset/bitset.members/any.pass.cpp
index 40cd0067bc6..e685b3735bd 100644
--- a/libcxx/test/utilities/template.bitset/bitset.members/any.pass.cpp
+++ b/libcxx/test/utilities/template.bitset/bitset.members/any.pass.cpp
@@ -1 +1,44 @@
-//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // test bool any() const; #include <bitset> #include <cassert> template <std::size_t N> void test_any() { std::bitset<N> v; v.reset(); assert(v.any() == false); v.set(); assert(v.any() == (N != 0)); if (N > 1) { v[N/2] = false; assert(v.any() == true); v.reset(); v[N/2] = true; assert(v.any() == true); } } int main() { test_any<0>(); test_any<1>(); test_any<31>(); test_any<32>(); test_any<33>(); test_any<63>(); test_any<64>(); test_any<65>(); test_any<1000>(); } \ No newline at end of file
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test bool any() const;
+
+#include <bitset>
+#include <cassert>
+
+template <std::size_t N>
+void test_any()
+{
+ std::bitset<N> v;
+ v.reset();
+ assert(v.any() == false);
+ v.set();
+ assert(v.any() == (N != 0));
+ if (N > 1)
+ {
+ v[N/2] = false;
+ assert(v.any() == true);
+ v.reset();
+ v[N/2] = true;
+ assert(v.any() == true);
+ }
+}
+
+int main()
+{
+ test_any<0>();
+ test_any<1>();
+ test_any<31>();
+ test_any<32>();
+ test_any<33>();
+ test_any<63>();
+ test_any<64>();
+ test_any<65>();
+ test_any<1000>();
+}
diff --git a/libcxx/test/utilities/template.bitset/bitset.members/count.pass.cpp b/libcxx/test/utilities/template.bitset/bitset.members/count.pass.cpp
index 8b5a727361a..82222dfb4de 100644
--- a/libcxx/test/utilities/template.bitset/bitset.members/count.pass.cpp
+++ b/libcxx/test/utilities/template.bitset/bitset.members/count.pass.cpp
@@ -1 +1,49 @@
-//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // test size_t count() const; #include <bitset> #include <cstdlib> #include <cassert> template <std::size_t N> std::bitset<N> make_bitset() { std::bitset<N> v; for (std::size_t i = 0; i < N; ++i) v[i] = static_cast<bool>(std::rand() & 1); return v; } template <std::size_t N> void test_count() { const std::bitset<N> v = make_bitset<N>(); std::size_t c1 = v.count(); std::size_t c2 = 0; for (std::size_t i = 0; i < N; ++i) if (v[i]) ++c2; assert(c1 == c2); } int main() { test_count<0>(); test_count<1>(); test_count<31>(); test_count<32>(); test_count<33>(); test_count<63>(); test_count<64>(); test_count<65>(); test_count<1000>(); } \ No newline at end of file
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test size_t count() const;
+
+#include <bitset>
+#include <cstdlib>
+#include <cassert>
+
+template <std::size_t N>
+std::bitset<N>
+make_bitset()
+{
+ std::bitset<N> v;
+ for (std::size_t i = 0; i < N; ++i)
+ v[i] = static_cast<bool>(std::rand() & 1);
+ return v;
+}
+
+template <std::size_t N>
+void test_count()
+{
+ const std::bitset<N> v = make_bitset<N>();
+ std::size_t c1 = v.count();
+ std::size_t c2 = 0;
+ for (std::size_t i = 0; i < N; ++i)
+ if (v[i])
+ ++c2;
+ assert(c1 == c2);
+}
+
+int main()
+{
+ test_count<0>();
+ test_count<1>();
+ test_count<31>();
+ test_count<32>();
+ test_count<33>();
+ test_count<63>();
+ test_count<64>();
+ test_count<65>();
+ test_count<1000>();
+}
diff --git a/libcxx/test/utilities/template.bitset/bitset.members/flip_all.pass.cpp b/libcxx/test/utilities/template.bitset/bitset.members/flip_all.pass.cpp
index 790d0b22cd9..85b255d443f 100644
--- a/libcxx/test/utilities/template.bitset/bitset.members/flip_all.pass.cpp
+++ b/libcxx/test/utilities/template.bitset/bitset.members/flip_all.pass.cpp
@@ -1 +1,47 @@
-//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // test bitset<N>& flip(); #include <bitset> #include <cstdlib> #include <cassert> template <std::size_t N> std::bitset<N> make_bitset() { std::bitset<N> v; for (std::size_t i = 0; i < N; ++i) v[i] = static_cast<bool>(std::rand() & 1); return v; } template <std::size_t N> void test_flip_all() { std::bitset<N> v1 = make_bitset<N>(); std::bitset<N> v2 = v1; v2.flip(); for (std::size_t i = 0; i < N; ++i) assert(v2[i] == ~v1[i]); } int main() { test_flip_all<0>(); test_flip_all<1>(); test_flip_all<31>(); test_flip_all<32>(); test_flip_all<33>(); test_flip_all<63>(); test_flip_all<64>(); test_flip_all<65>(); test_flip_all<1000>(); } \ No newline at end of file
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test bitset<N>& flip();
+
+#include <bitset>
+#include <cstdlib>
+#include <cassert>
+
+template <std::size_t N>
+std::bitset<N>
+make_bitset()
+{
+ std::bitset<N> v;
+ for (std::size_t i = 0; i < N; ++i)
+ v[i] = static_cast<bool>(std::rand() & 1);
+ return v;
+}
+
+template <std::size_t N>
+void test_flip_all()
+{
+ std::bitset<N> v1 = make_bitset<N>();
+ std::bitset<N> v2 = v1;
+ v2.flip();
+ for (std::size_t i = 0; i < N; ++i)
+ assert(v2[i] == ~v1[i]);
+}
+
+int main()
+{
+ test_flip_all<0>();
+ test_flip_all<1>();
+ test_flip_all<31>();
+ test_flip_all<32>();
+ test_flip_all<33>();
+ test_flip_all<63>();
+ test_flip_all<64>();
+ test_flip_all<65>();
+ test_flip_all<1000>();
+}
diff --git a/libcxx/test/utilities/template.bitset/bitset.members/flip_one.pass.cpp b/libcxx/test/utilities/template.bitset/bitset.members/flip_one.pass.cpp
index 10e1b7dbe4d..1754ee867a7 100644
--- a/libcxx/test/utilities/template.bitset/bitset.members/flip_one.pass.cpp
+++ b/libcxx/test/utilities/template.bitset/bitset.members/flip_one.pass.cpp
@@ -1 +1,58 @@
-//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // test bitset<N>& flip(size_t pos); #include <bitset> #include <cstdlib> #include <cassert> template <std::size_t N> std::bitset<N> make_bitset() { std::bitset<N> v; for (std::size_t i = 0; i < N; ++i) v[i] = static_cast<bool>(std::rand() & 1); return v; } template <std::size_t N> void test_flip_one() { std::bitset<N> v = make_bitset<N>(); try { v.flip(50); bool b = v[50]; if (50 >= v.size()) assert(false); assert(v[50] == b); v.flip(50); assert(v[50] != b); v.flip(50); assert(v[50] == b); } catch (std::out_of_range&) { } } 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>(); } \ No newline at end of file
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test bitset<N>& flip(size_t pos);
+
+#include <bitset>
+#include <cstdlib>
+#include <cassert>
+
+template <std::size_t N>
+std::bitset<N>
+make_bitset()
+{
+ std::bitset<N> v;
+ for (std::size_t i = 0; i < N; ++i)
+ v[i] = static_cast<bool>(std::rand() & 1);
+ return v;
+}
+
+template <std::size_t N>
+void test_flip_one()
+{
+ std::bitset<N> v = make_bitset<N>();
+ try
+ {
+ v.flip(50);
+ bool b = v[50];
+ if (50 >= v.size())
+ assert(false);
+ assert(v[50] == b);
+ v.flip(50);
+ assert(v[50] != b);
+ v.flip(50);
+ assert(v[50] == b);
+ }
+ catch (std::out_of_range&)
+ {
+ }
+}
+
+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>();
+}
diff --git a/libcxx/test/utilities/template.bitset/bitset.members/index.pass.cpp b/libcxx/test/utilities/template.bitset/bitset.members/index.pass.cpp
index b18489037eb..c346a3fb00d 100644
--- a/libcxx/test/utilities/template.bitset/bitset.members/index.pass.cpp
+++ b/libcxx/test/utilities/template.bitset/bitset.members/index.pass.cpp
@@ -1 +1,65 @@
-//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // test bitset<N>::reference operator[](size_t pos); #include <bitset> #include <cstdlib> #include <cassert> template <std::size_t N> std::bitset<N> make_bitset() { std::bitset<N> v; for (std::size_t i = 0; i < N; ++i) v[i] = static_cast<bool>(std::rand() & 1); return v; } template <std::size_t N> void test_index_const() { std::bitset<N> v1 = make_bitset<N>(); if (N > 0) { assert(v1[N/2] == v1.test(N/2)); typename std::bitset<N>::reference r = v1[N/2]; assert(r == v1.test(N/2)); typename std::bitset<N>::reference r2 = v1[N/2]; r = r2; assert(r == v1.test(N/2)); r = false; assert(r == false); assert(v1.test(N/2) == false); r = true; assert(r == true); assert(v1.test(N/2) == true); bool b = ~r; assert(r == true); assert(v1.test(N/2) == true); assert(b == false); r.flip(); assert(r == false); assert(v1.test(N/2) == false); } } int main() { test_index_const<0>(); test_index_const<1>(); test_index_const<31>(); test_index_const<32>(); test_index_const<33>(); test_index_const<63>(); test_index_const<64>(); test_index_const<65>(); test_index_const<1000>(); } \ No newline at end of file
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test bitset<N>::reference operator[](size_t pos);
+
+#include <bitset>
+#include <cstdlib>
+#include <cassert>
+
+template <std::size_t N>
+std::bitset<N>
+make_bitset()
+{
+ std::bitset<N> v;
+ for (std::size_t i = 0; i < N; ++i)
+ v[i] = static_cast<bool>(std::rand() & 1);
+ return v;
+}
+
+template <std::size_t N>
+void test_index_const()
+{
+ std::bitset<N> v1 = make_bitset<N>();
+ if (N > 0)
+ {
+ assert(v1[N/2] == v1.test(N/2));
+ typename std::bitset<N>::reference r = v1[N/2];
+ assert(r == v1.test(N/2));
+ typename std::bitset<N>::reference r2 = v1[N/2];
+ r = r2;
+ assert(r == v1.test(N/2));
+ r = false;
+ assert(r == false);
+ assert(v1.test(N/2) == false);
+ r = true;
+ assert(r == true);
+ assert(v1.test(N/2) == true);
+ bool b = ~r;
+ assert(r == true);
+ assert(v1.test(N/2) == true);
+ assert(b == false);
+ r.flip();
+ assert(r == false);
+ assert(v1.test(N/2) == false);
+ }
+}
+
+int main()
+{
+ test_index_const<0>();
+ test_index_const<1>();
+ test_index_const<31>();
+ test_index_const<32>();
+ test_index_const<33>();
+ test_index_const<63>();
+ test_index_const<64>();
+ test_index_const<65>();
+ test_index_const<1000>();
+}
diff --git a/libcxx/test/utilities/template.bitset/bitset.members/index_const.pass.cpp b/libcxx/test/utilities/template.bitset/bitset.members/index_const.pass.cpp
index 60973a275a8..3d4d1e8223e 100644
--- a/libcxx/test/utilities/template.bitset/bitset.members/index_const.pass.cpp
+++ b/libcxx/test/utilities/template.bitset/bitset.members/index_const.pass.cpp
@@ -1 +1,47 @@
-//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // test constexpr bool operator[](size_t pos) const; #include <bitset> #include <cstdlib> #include <cassert> template <std::size_t N> std::bitset<N> make_bitset() { std::bitset<N> v; for (std::size_t i = 0; i < N; ++i) v[i] = static_cast<bool>(std::rand() & 1); return v; } template <std::size_t N> void test_index_const() { const std::bitset<N> v1 = make_bitset<N>(); if (N > 0) { assert(v1[N/2] == v1.test(N/2)); } } int main() { test_index_const<0>(); test_index_const<1>(); test_index_const<31>(); test_index_const<32>(); test_index_const<33>(); test_index_const<63>(); test_index_const<64>(); test_index_const<65>(); test_index_const<1000>(); } \ No newline at end of file
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test constexpr bool operator[](size_t pos) const;
+
+#include <bitset>
+#include <cstdlib>
+#include <cassert>
+
+template <std::size_t N>
+std::bitset<N>
+make_bitset()
+{
+ std::bitset<N> v;
+ for (std::size_t i = 0; i < N; ++i)
+ v[i] = static_cast<bool>(std::rand() & 1);
+ return v;
+}
+
+template <std::size_t N>
+void test_index_const()
+{
+ const std::bitset<N> v1 = make_bitset<N>();
+ if (N > 0)
+ {
+ assert(v1[N/2] == v1.test(N/2));
+ }
+}
+
+int main()
+{
+ test_index_const<0>();
+ test_index_const<1>();
+ test_index_const<31>();
+ test_index_const<32>();
+ test_index_const<33>();
+ test_index_const<63>();
+ test_index_const<64>();
+ test_index_const<65>();
+ test_index_const<1000>();
+}
diff --git a/libcxx/test/utilities/template.bitset/bitset.members/left_shift.pass.cpp b/libcxx/test/utilities/template.bitset/bitset.members/left_shift.pass.cpp
index b1d373187e4..f19987c018c 100644
--- a/libcxx/test/utilities/template.bitset/bitset.members/left_shift.pass.cpp
+++ b/libcxx/test/utilities/template.bitset/bitset.members/left_shift.pass.cpp
@@ -1 +1,48 @@
-//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // test bitset<N> operator<<(size_t pos) const; #include <bitset> #include <cstdlib> #include <cassert> template <std::size_t N> std::bitset<N> make_bitset() { std::bitset<N> v; for (std::size_t i = 0; i < N; ++i) v[i] = static_cast<bool>(std::rand() & 1); return v; } template <std::size_t N> void test_left_shift() { for (std::size_t s = 0; s <= N+1; ++s) { std::bitset<N> v1 = make_bitset<N>(); std::bitset<N> v2 = v1; assert((v1 <<= s) == (v2 << s)); } } int main() { test_left_shift<0>(); test_left_shift<1>(); test_left_shift<31>(); test_left_shift<32>(); test_left_shift<33>(); test_left_shift<63>(); test_left_shift<64>(); test_left_shift<65>(); test_left_shift<1000>(); } \ No newline at end of file
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test bitset<N> operator<<(size_t pos) const;
+
+#include <bitset>
+#include <cstdlib>
+#include <cassert>
+
+template <std::size_t N>
+std::bitset<N>
+make_bitset()
+{
+ std::bitset<N> v;
+ for (std::size_t i = 0; i < N; ++i)
+ v[i] = static_cast<bool>(std::rand() & 1);
+ return v;
+}
+
+template <std::size_t N>
+void test_left_shift()
+{
+ for (std::size_t s = 0; s <= N+1; ++s)
+ {
+ std::bitset<N> v1 = make_bitset<N>();
+ std::bitset<N> v2 = v1;
+ assert((v1 <<= s) == (v2 << s));
+ }
+}
+
+int main()
+{
+ test_left_shift<0>();
+ test_left_shift<1>();
+ test_left_shift<31>();
+ test_left_shift<32>();
+ test_left_shift<33>();
+ test_left_shift<63>();
+ test_left_shift<64>();
+ test_left_shift<65>();
+ test_left_shift<1000>();
+}
diff --git a/libcxx/test/utilities/template.bitset/bitset.members/left_shift_eq.pass.cpp b/libcxx/test/utilities/template.bitset/bitset.members/left_shift_eq.pass.cpp
index 8ea0981c525..340921db5d0 100644
--- a/libcxx/test/utilities/template.bitset/bitset.members/left_shift_eq.pass.cpp
+++ b/libcxx/test/utilities/template.bitset/bitset.members/left_shift_eq.pass.cpp
@@ -1 +1,53 @@
-//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // test bitset<N>& operator<<=(size_t pos); #include <bitset> #include <cstdlib> #include <cassert> template <std::size_t N> std::bitset<N> make_bitset() { std::bitset<N> v; for (std::size_t i = 0; i < N; ++i) v[i] = static_cast<bool>(std::rand() & 1); return v; } template <std::size_t N> void test_left_shift() { for (std::size_t s = 0; s <= N+1; ++s) { std::bitset<N> v1 = make_bitset<N>(); std::bitset<N> v2 = v1; v1 <<= s; for (std::size_t i = 0; i < N; ++i) if (i < s) assert(v1[i] == 0); else assert(v1[i] == v2[i-s]); } } int main() { test_left_shift<0>(); test_left_shift<1>(); test_left_shift<31>(); test_left_shift<32>(); test_left_shift<33>(); test_left_shift<63>(); test_left_shift<64>(); test_left_shift<65>(); test_left_shift<1000>(); } \ No newline at end of file
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test bitset<N>& operator<<=(size_t pos);
+
+#include <bitset>
+#include <cstdlib>
+#include <cassert>
+
+template <std::size_t N>
+std::bitset<N>
+make_bitset()
+{
+ std::bitset<N> v;
+ for (std::size_t i = 0; i < N; ++i)
+ v[i] = static_cast<bool>(std::rand() & 1);
+ return v;
+}
+
+template <std::size_t N>
+void test_left_shift()
+{
+ for (std::size_t s = 0; s <= N+1; ++s)
+ {
+ std::bitset<N> v1 = make_bitset<N>();
+ std::bitset<N> v2 = v1;
+ v1 <<= s;
+ for (std::size_t i = 0; i < N; ++i)
+ if (i < s)
+ assert(v1[i] == 0);
+ else
+ assert(v1[i] == v2[i-s]);
+ }
+}
+
+int main()
+{
+ test_left_shift<0>();
+ test_left_shift<1>();
+ test_left_shift<31>();
+ test_left_shift<32>();
+ test_left_shift<33>();
+ test_left_shift<63>();
+ test_left_shift<64>();
+ test_left_shift<65>();
+ test_left_shift<1000>();
+}
diff --git a/libcxx/test/utilities/template.bitset/bitset.members/none.pass.cpp b/libcxx/test/utilities/template.bitset/bitset.members/none.pass.cpp
index abba3fd54f0..5270a5a3320 100644
--- a/libcxx/test/utilities/template.bitset/bitset.members/none.pass.cpp
+++ b/libcxx/test/utilities/template.bitset/bitset.members/none.pass.cpp
@@ -1 +1,44 @@
-//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // test bool none() const; #include <bitset> #include <cassert> template <std::size_t N> void test_none() { std::bitset<N> v; v.reset(); assert(v.none() == true); v.set(); assert(v.none() == (N == 0)); if (N > 1) { v[N/2] = false; assert(v.none() == false); v.reset(); v[N/2] = true; assert(v.none() == false); } } int main() { test_none<0>(); test_none<1>(); test_none<31>(); test_none<32>(); test_none<33>(); test_none<63>(); test_none<64>(); test_none<65>(); test_none<1000>(); } \ No newline at end of file
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test bool none() const;
+
+#include <bitset>
+#include <cassert>
+
+template <std::size_t N>
+void test_none()
+{
+ std::bitset<N> v;
+ v.reset();
+ assert(v.none() == true);
+ v.set();
+ assert(v.none() == (N == 0));
+ if (N > 1)
+ {
+ v[N/2] = false;
+ assert(v.none() == false);
+ v.reset();
+ v[N/2] = true;
+ assert(v.none() == false);
+ }
+}
+
+int main()
+{
+ test_none<0>();
+ test_none<1>();
+ test_none<31>();
+ test_none<32>();
+ test_none<33>();
+ test_none<63>();
+ test_none<64>();
+ test_none<65>();
+ test_none<1000>();
+}
diff --git a/libcxx/test/utilities/template.bitset/bitset.members/not_all.pass.cpp b/libcxx/test/utilities/template.bitset/bitset.members/not_all.pass.cpp
index edaeac67305..7b30564f1f2 100644
--- a/libcxx/test/utilities/template.bitset/bitset.members/not_all.pass.cpp
+++ b/libcxx/test/utilities/template.bitset/bitset.members/not_all.pass.cpp
@@ -1 +1,46 @@
-//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // test bitset<N> operator~() const; #include <bitset> #include <cstdlib> #include <cassert> template <std::size_t N> std::bitset<N> make_bitset() { std::bitset<N> v; for (std::size_t i = 0; i < N; ++i) v[i] = static_cast<bool>(std::rand() & 1); return v; } template <std::size_t N> void test_not_all() { std::bitset<N> v1 = make_bitset<N>(); std::bitset<N> v2 = ~v1; for (std::size_t i = 0; i < N; ++i) assert(v2[i] == ~v1[i]); } int main() { test_not_all<0>(); test_not_all<1>(); test_not_all<31>(); test_not_all<32>(); test_not_all<33>(); test_not_all<63>(); test_not_all<64>(); test_not_all<65>(); test_not_all<1000>(); } \ No newline at end of file
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test bitset<N> operator~() const;
+
+#include <bitset>
+#include <cstdlib>
+#include <cassert>
+
+template <std::size_t N>
+std::bitset<N>
+make_bitset()
+{
+ std::bitset<N> v;
+ for (std::size_t i = 0; i < N; ++i)
+ v[i] = static_cast<bool>(std::rand() & 1);
+ return v;
+}
+
+template <std::size_t N>
+void test_not_all()
+{
+ std::bitset<N> v1 = make_bitset<N>();
+ std::bitset<N> v2 = ~v1;
+ for (std::size_t i = 0; i < N; ++i)
+ assert(v2[i] == ~v1[i]);
+}
+
+int main()
+{
+ test_not_all<0>();
+ test_not_all<1>();
+ test_not_all<31>();
+ test_not_all<32>();
+ test_not_all<33>();
+ test_not_all<63>();
+ test_not_all<64>();
+ test_not_all<65>();
+ test_not_all<1000>();
+}
diff --git a/libcxx/test/utilities/template.bitset/bitset.members/op_and_eq.pass.cpp b/libcxx/test/utilities/template.bitset/bitset.members/op_and_eq.pass.cpp
index 420443ea3ac..d1c878dd75c 100644
--- a/libcxx/test/utilities/template.bitset/bitset.members/op_and_eq.pass.cpp
+++ b/libcxx/test/utilities/template.bitset/bitset.members/op_and_eq.pass.cpp
@@ -1 +1,48 @@
-//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // test bitset<N>& operator&=(const bitset<N>& rhs); #include <bitset> #include <cstdlib> #include <cassert> template <std::size_t N> std::bitset<N> make_bitset() { std::bitset<N> v; for (std::size_t i = 0; i < N; ++i) v[i] = static_cast<bool>(std::rand() & 1); return v; } template <std::size_t N> void test_op_and_eq() { std::bitset<N> v1 = make_bitset<N>(); std::bitset<N> v2 = make_bitset<N>(); std::bitset<N> v3 = v1; v1 &= v2; for (std::size_t i = 0; i < N; ++i) assert(v1[i] == (v3[i] && v2[i])); } int main() { test_op_and_eq<0>(); test_op_and_eq<1>(); test_op_and_eq<31>(); test_op_and_eq<32>(); test_op_and_eq<33>(); test_op_and_eq<63>(); test_op_and_eq<64>(); test_op_and_eq<65>(); test_op_and_eq<1000>(); } \ No newline at end of file
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test bitset<N>& operator&=(const bitset<N>& rhs);
+
+#include <bitset>
+#include <cstdlib>
+#include <cassert>
+
+template <std::size_t N>
+std::bitset<N>
+make_bitset()
+{
+ std::bitset<N> v;
+ for (std::size_t i = 0; i < N; ++i)
+ v[i] = static_cast<bool>(std::rand() & 1);
+ return v;
+}
+
+template <std::size_t N>
+void test_op_and_eq()
+{
+ std::bitset<N> v1 = make_bitset<N>();
+ std::bitset<N> v2 = make_bitset<N>();
+ std::bitset<N> v3 = v1;
+ v1 &= v2;
+ for (std::size_t i = 0; i < N; ++i)
+ assert(v1[i] == (v3[i] && v2[i]));
+}
+
+int main()
+{
+ test_op_and_eq<0>();
+ test_op_and_eq<1>();
+ test_op_and_eq<31>();
+ test_op_and_eq<32>();
+ test_op_and_eq<33>();
+ test_op_and_eq<63>();
+ test_op_and_eq<64>();
+ test_op_and_eq<65>();
+ test_op_and_eq<1000>();
+}
diff --git a/libcxx/test/utilities/template.bitset/bitset.members/op_eq_eq.pass.cpp b/libcxx/test/utilities/template.bitset/bitset.members/op_eq_eq.pass.cpp
index beac3d31c77..4d37de6b9f2 100644
--- a/libcxx/test/utilities/template.bitset/bitset.members/op_eq_eq.pass.cpp
+++ b/libcxx/test/utilities/template.bitset/bitset.members/op_eq_eq.pass.cpp
@@ -1 +1,53 @@
-//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // test: // bool operator==(const bitset<N>& rhs) const; // bool operator!=(const bitset<N>& rhs) const; #include <bitset> #include <cstdlib> #include <cassert> template <std::size_t N> std::bitset<N> make_bitset() { std::bitset<N> v; for (std::size_t i = 0; i < N; ++i) v[i] = static_cast<bool>(std::rand() & 1); return v; } template <std::size_t N> void test_equality() { const std::bitset<N> v1 = make_bitset<N>(); std::bitset<N> v2 = v1; assert(v1 == v2); if (N > 0) { v2[N/2].flip(); assert(v1 != v2); } } int main() { test_equality<0>(); test_equality<1>(); test_equality<31>(); test_equality<32>(); test_equality<33>(); test_equality<63>(); test_equality<64>(); test_equality<65>(); test_equality<1000>(); } \ No newline at end of file
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test:
+
+// bool operator==(const bitset<N>& rhs) const;
+// bool operator!=(const bitset<N>& rhs) const;
+
+#include <bitset>
+#include <cstdlib>
+#include <cassert>
+
+template <std::size_t N>
+std::bitset<N>
+make_bitset()
+{
+ std::bitset<N> v;
+ for (std::size_t i = 0; i < N; ++i)
+ v[i] = static_cast<bool>(std::rand() & 1);
+ return v;
+}
+
+template <std::size_t N>
+void test_equality()
+{
+ const std::bitset<N> v1 = make_bitset<N>();
+ std::bitset<N> v2 = v1;
+ assert(v1 == v2);
+ if (N > 0)
+ {
+ v2[N/2].flip();
+ assert(v1 != v2);
+ }
+}
+
+int main()
+{
+ test_equality<0>();
+ test_equality<1>();
+ test_equality<31>();
+ test_equality<32>();
+ test_equality<33>();
+ test_equality<63>();
+ test_equality<64>();
+ test_equality<65>();
+ test_equality<1000>();
+}
diff --git a/libcxx/test/utilities/template.bitset/bitset.members/op_or_eq.pass.cpp b/libcxx/test/utilities/template.bitset/bitset.members/op_or_eq.pass.cpp
index 6de4b037693..041e2dd7ec0 100644
--- a/libcxx/test/utilities/template.bitset/bitset.members/op_or_eq.pass.cpp
+++ b/libcxx/test/utilities/template.bitset/bitset.members/op_or_eq.pass.cpp
@@ -1 +1,48 @@
-//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // test bitset<N>& operator|=(const bitset<N>& rhs); #include <bitset> #include <cstdlib> #include <cassert> template <std::size_t N> std::bitset<N> make_bitset() { std::bitset<N> v; for (std::size_t i = 0; i < N; ++i) v[i] = static_cast<bool>(std::rand() & 1); return v; } template <std::size_t N> void test_op_or_eq() { std::bitset<N> v1 = make_bitset<N>(); std::bitset<N> v2 = make_bitset<N>(); std::bitset<N> v3 = v1; v1 |= v2; for (std::size_t i = 0; i < N; ++i) assert(v1[i] == (v3[i] || v2[i])); } int main() { test_op_or_eq<0>(); test_op_or_eq<1>(); test_op_or_eq<31>(); test_op_or_eq<32>(); test_op_or_eq<33>(); test_op_or_eq<63>(); test_op_or_eq<64>(); test_op_or_eq<65>(); test_op_or_eq<1000>(); } \ No newline at end of file
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test bitset<N>& operator|=(const bitset<N>& rhs);
+
+#include <bitset>
+#include <cstdlib>
+#include <cassert>
+
+template <std::size_t N>
+std::bitset<N>
+make_bitset()
+{
+ std::bitset<N> v;
+ for (std::size_t i = 0; i < N; ++i)
+ v[i] = static_cast<bool>(std::rand() & 1);
+ return v;
+}
+
+template <std::size_t N>
+void test_op_or_eq()
+{
+ std::bitset<N> v1 = make_bitset<N>();
+ std::bitset<N> v2 = make_bitset<N>();
+ std::bitset<N> v3 = v1;
+ v1 |= v2;
+ for (std::size_t i = 0; i < N; ++i)
+ assert(v1[i] == (v3[i] || v2[i]));
+}
+
+int main()
+{
+ test_op_or_eq<0>();
+ test_op_or_eq<1>();
+ test_op_or_eq<31>();
+ test_op_or_eq<32>();
+ test_op_or_eq<33>();
+ test_op_or_eq<63>();
+ test_op_or_eq<64>();
+ test_op_or_eq<65>();
+ test_op_or_eq<1000>();
+}
diff --git a/libcxx/test/utilities/template.bitset/bitset.members/op_xor_eq.pass.cpp b/libcxx/test/utilities/template.bitset/bitset.members/op_xor_eq.pass.cpp
index b02e5cd5d00..4ebc187a503 100644
--- a/libcxx/test/utilities/template.bitset/bitset.members/op_xor_eq.pass.cpp
+++ b/libcxx/test/utilities/template.bitset/bitset.members/op_xor_eq.pass.cpp
@@ -1 +1,48 @@
-//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // test bitset<N>& operator^=(const bitset<N>& rhs); #include <bitset> #include <cstdlib> #include <cassert> template <std::size_t N> std::bitset<N> make_bitset() { std::bitset<N> v; for (std::size_t i = 0; i < N; ++i) v[i] = static_cast<bool>(std::rand() & 1); return v; } template <std::size_t N> void test_op_xor_eq() { std::bitset<N> v1 = make_bitset<N>(); std::bitset<N> v2 = make_bitset<N>(); std::bitset<N> v3 = v1; v1 ^= v2; for (std::size_t i = 0; i < N; ++i) assert(v1[i] == (v3[i] != v2[i])); } int main() { test_op_xor_eq<0>(); test_op_xor_eq<1>(); test_op_xor_eq<31>(); test_op_xor_eq<32>(); test_op_xor_eq<33>(); test_op_xor_eq<63>(); test_op_xor_eq<64>(); test_op_xor_eq<65>(); test_op_xor_eq<1000>(); } \ No newline at end of file
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test bitset<N>& operator^=(const bitset<N>& rhs);
+
+#include <bitset>
+#include <cstdlib>
+#include <cassert>
+
+template <std::size_t N>
+std::bitset<N>
+make_bitset()
+{
+ std::bitset<N> v;
+ for (std::size_t i = 0; i < N; ++i)
+ v[i] = static_cast<bool>(std::rand() & 1);
+ return v;
+}
+
+template <std::size_t N>
+void test_op_xor_eq()
+{
+ std::bitset<N> v1 = make_bitset<N>();
+ std::bitset<N> v2 = make_bitset<N>();
+ std::bitset<N> v3 = v1;
+ v1 ^= v2;
+ for (std::size_t i = 0; i < N; ++i)
+ assert(v1[i] == (v3[i] != v2[i]));
+}
+
+int main()
+{
+ test_op_xor_eq<0>();
+ test_op_xor_eq<1>();
+ test_op_xor_eq<31>();
+ test_op_xor_eq<32>();
+ test_op_xor_eq<33>();
+ test_op_xor_eq<63>();
+ test_op_xor_eq<64>();
+ test_op_xor_eq<65>();
+ test_op_xor_eq<1000>();
+}
diff --git a/libcxx/test/utilities/template.bitset/bitset.members/reset_all.pass.cpp b/libcxx/test/utilities/template.bitset/bitset.members/reset_all.pass.cpp
index 0d8695bd089..3d3d9a2fbbc 100644
--- a/libcxx/test/utilities/template.bitset/bitset.members/reset_all.pass.cpp
+++ b/libcxx/test/utilities/template.bitset/bitset.members/reset_all.pass.cpp
@@ -1 +1,36 @@
-//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // test bitset<N>& reset(); #include <bitset> #include <cassert> template <std::size_t N> void test_reset_all() { std::bitset<N> v; v.set(); v.reset(); for (std::size_t i = 0; i < N; ++i) assert(!v[i]); } int main() { test_reset_all<0>(); test_reset_all<1>(); test_reset_all<31>(); test_reset_all<32>(); test_reset_all<33>(); test_reset_all<63>(); test_reset_all<64>(); test_reset_all<65>(); test_reset_all<1000>(); } \ No newline at end of file
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test bitset<N>& reset();
+
+#include <bitset>
+#include <cassert>
+
+template <std::size_t N>
+void test_reset_all()
+{
+ std::bitset<N> v;
+ v.set();
+ v.reset();
+ for (std::size_t i = 0; i < N; ++i)
+ assert(!v[i]);
+}
+
+int main()
+{
+ test_reset_all<0>();
+ test_reset_all<1>();
+ test_reset_all<31>();
+ test_reset_all<32>();
+ test_reset_all<33>();
+ test_reset_all<63>();
+ test_reset_all<64>();
+ test_reset_all<65>();
+ test_reset_all<1000>();
+}
diff --git a/libcxx/test/utilities/template.bitset/bitset.members/reset_one.pass.cpp b/libcxx/test/utilities/template.bitset/bitset.members/reset_one.pass.cpp
index 61c1410c007..b37d2fa3da8 100644
--- a/libcxx/test/utilities/template.bitset/bitset.members/reset_one.pass.cpp
+++ b/libcxx/test/utilities/template.bitset/bitset.members/reset_one.pass.cpp
@@ -1 +1,47 @@
-//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // test bitset<N>& reset(size_t pos); #include <bitset> #include <cassert> template <std::size_t N> void test_reset_one() { std::bitset<N> v; try { v.set(); v.reset(50); if (50 >= v.size()) assert(false); for (unsigned i = 0; i < v.size(); ++i) if (i == 50) assert(!v[i]); else assert(v[i]); } catch (std::out_of_range&) { } } 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>(); } \ No newline at end of file
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test bitset<N>& reset(size_t pos);
+
+#include <bitset>
+#include <cassert>
+
+template <std::size_t N>
+void test_reset_one()
+{
+ std::bitset<N> v;
+ try
+ {
+ v.set();
+ v.reset(50);
+ if (50 >= v.size())
+ assert(false);
+ for (unsigned i = 0; i < v.size(); ++i)
+ if (i == 50)
+ assert(!v[i]);
+ else
+ assert(v[i]);
+ }
+ catch (std::out_of_range&)
+ {
+ }
+}
+
+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>();
+}
diff --git a/libcxx/test/utilities/template.bitset/bitset.members/right_shift.pass.cpp b/libcxx/test/utilities/template.bitset/bitset.members/right_shift.pass.cpp
index 4c48638ed38..817adabe8e3 100644
--- a/libcxx/test/utilities/template.bitset/bitset.members/right_shift.pass.cpp
+++ b/libcxx/test/utilities/template.bitset/bitset.members/right_shift.pass.cpp
@@ -1 +1,48 @@
-//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // test bitset<N> operator>>(size_t pos) const; #include <bitset> #include <cstdlib> #include <cassert> template <std::size_t N> std::bitset<N> make_bitset() { std::bitset<N> v; for (std::size_t i = 0; i < N; ++i) v[i] = static_cast<bool>(std::rand() & 1); return v; } template <std::size_t N> void test_right_shift() { for (std::size_t s = 0; s <= N+1; ++s) { std::bitset<N> v1 = make_bitset<N>(); std::bitset<N> v2 = v1; assert((v1 >>= s) == (v2 >> s)); } } int main() { test_right_shift<0>(); test_right_shift<1>(); test_right_shift<31>(); test_right_shift<32>(); test_right_shift<33>(); test_right_shift<63>(); test_right_shift<64>(); test_right_shift<65>(); test_right_shift<1000>(); } \ No newline at end of file
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test bitset<N> operator>>(size_t pos) const;
+
+#include <bitset>
+#include <cstdlib>
+#include <cassert>
+
+template <std::size_t N>
+std::bitset<N>
+make_bitset()
+{
+ std::bitset<N> v;
+ for (std::size_t i = 0; i < N; ++i)
+ v[i] = static_cast<bool>(std::rand() & 1);
+ return v;
+}
+
+template <std::size_t N>
+void test_right_shift()
+{
+ for (std::size_t s = 0; s <= N+1; ++s)
+ {
+ std::bitset<N> v1 = make_bitset<N>();
+ std::bitset<N> v2 = v1;
+ assert((v1 >>= s) == (v2 >> s));
+ }
+}
+
+int main()
+{
+ test_right_shift<0>();
+ test_right_shift<1>();
+ test_right_shift<31>();
+ test_right_shift<32>();
+ test_right_shift<33>();
+ test_right_shift<63>();
+ test_right_shift<64>();
+ test_right_shift<65>();
+ test_right_shift<1000>();
+}
diff --git a/libcxx/test/utilities/template.bitset/bitset.members/right_shift_eq.pass.cpp b/libcxx/test/utilities/template.bitset/bitset.members/right_shift_eq.pass.cpp
index 71f3347961b..8171a782547 100644
--- a/libcxx/test/utilities/template.bitset/bitset.members/right_shift_eq.pass.cpp
+++ b/libcxx/test/utilities/template.bitset/bitset.members/right_shift_eq.pass.cpp
@@ -1 +1,53 @@
-//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // test bitset<N>& operator<<=(size_t pos); #include <bitset> #include <cstdlib> #include <cassert> template <std::size_t N> std::bitset<N> make_bitset() { std::bitset<N> v; for (std::size_t i = 0; i < N; ++i) v[i] = static_cast<bool>(std::rand() & 1); return v; } template <std::size_t N> void test_right_shift() { for (std::size_t s = 0; s <= N+1; ++s) { std::bitset<N> v1 = make_bitset<N>(); std::bitset<N> v2 = v1; v1 >>= s; for (std::size_t i = 0; i < N; ++i) if (i + s < N) assert(v1[i] == v2[i + s]); else assert(v1[i] == 0); } } int main() { test_right_shift<0>(); test_right_shift<1>(); test_right_shift<31>(); test_right_shift<32>(); test_right_shift<33>(); test_right_shift<63>(); test_right_shift<64>(); test_right_shift<65>(); test_right_shift<1000>(); } \ No newline at end of file
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test bitset<N>& operator<<=(size_t pos);
+
+#include <bitset>
+#include <cstdlib>
+#include <cassert>
+
+template <std::size_t N>
+std::bitset<N>
+make_bitset()
+{
+ std::bitset<N> v;
+ for (std::size_t i = 0; i < N; ++i)
+ v[i] = static_cast<bool>(std::rand() & 1);
+ return v;
+}
+
+template <std::size_t N>
+void test_right_shift()
+{
+ for (std::size_t s = 0; s <= N+1; ++s)
+ {
+ std::bitset<N> v1 = make_bitset<N>();
+ std::bitset<N> v2 = v1;
+ v1 >>= s;
+ for (std::size_t i = 0; i < N; ++i)
+ if (i + s < N)
+ assert(v1[i] == v2[i + s]);
+ else
+ assert(v1[i] == 0);
+ }
+}
+
+int main()
+{
+ test_right_shift<0>();
+ test_right_shift<1>();
+ test_right_shift<31>();
+ test_right_shift<32>();
+ test_right_shift<33>();
+ test_right_shift<63>();
+ test_right_shift<64>();
+ test_right_shift<65>();
+ test_right_shift<1000>();
+}
diff --git a/libcxx/test/utilities/template.bitset/bitset.members/set_all.pass.cpp b/libcxx/test/utilities/template.bitset/bitset.members/set_all.pass.cpp
index 289eae31622..97e58b1f761 100644
--- a/libcxx/test/utilities/template.bitset/bitset.members/set_all.pass.cpp
+++ b/libcxx/test/utilities/template.bitset/bitset.members/set_all.pass.cpp
@@ -1 +1,35 @@
-//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // test bitset<N>& set(); #include <bitset> #include <cassert> template <std::size_t N> void test_set_all() { std::bitset<N> v; v.set(); for (std::size_t i = 0; i < N; ++i) assert(v[i]); } int main() { test_set_all<0>(); test_set_all<1>(); test_set_all<31>(); test_set_all<32>(); test_set_all<33>(); test_set_all<63>(); test_set_all<64>(); test_set_all<65>(); test_set_all<1000>(); } \ No newline at end of file
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test bitset<N>& set();
+
+#include <bitset>
+#include <cassert>
+
+template <std::size_t N>
+void test_set_all()
+{
+ std::bitset<N> v;
+ v.set();
+ for (std::size_t i = 0; i < N; ++i)
+ assert(v[i]);
+}
+
+int main()
+{
+ test_set_all<0>();
+ test_set_all<1>();
+ test_set_all<31>();
+ test_set_all<32>();
+ test_set_all<33>();
+ test_set_all<63>();
+ test_set_all<64>();
+ test_set_all<65>();
+ test_set_all<1000>();
+}
diff --git a/libcxx/test/utilities/template.bitset/bitset.members/set_one.pass.cpp b/libcxx/test/utilities/template.bitset/bitset.members/set_one.pass.cpp
index 899b2f4cfb8..869a5ca6a5c 100644
--- a/libcxx/test/utilities/template.bitset/bitset.members/set_one.pass.cpp
+++ b/libcxx/test/utilities/template.bitset/bitset.members/set_one.pass.cpp
@@ -1 +1,52 @@
-//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // test bitset<N>& set(size_t pos, bool val = true); #include <bitset> #include <cassert> template <std::size_t N> void test_set_one() { std::bitset<N> v; try { v.set(50); if (50 >= v.size()) assert(false); assert(v[50]); } catch (std::out_of_range&) { } try { v.set(50, false); if (50 >= v.size()) assert(false); assert(!v[50]); } catch (std::out_of_range&) { } } 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>(); } \ No newline at end of file
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test bitset<N>& set(size_t pos, bool val = true);
+
+#include <bitset>
+#include <cassert>
+
+template <std::size_t N>
+void test_set_one()
+{
+ std::bitset<N> v;
+ try
+ {
+ v.set(50);
+ if (50 >= v.size())
+ assert(false);
+ assert(v[50]);
+ }
+ catch (std::out_of_range&)
+ {
+ }
+ try
+ {
+ v.set(50, false);
+ if (50 >= v.size())
+ assert(false);
+ assert(!v[50]);
+ }
+ catch (std::out_of_range&)
+ {
+ }
+}
+
+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>();
+}
diff --git a/libcxx/test/utilities/template.bitset/bitset.members/size.pass.cpp b/libcxx/test/utilities/template.bitset/bitset.members/size.pass.cpp
index 9109d2a2c0f..641f9d672f4 100644
--- a/libcxx/test/utilities/template.bitset/bitset.members/size.pass.cpp
+++ b/libcxx/test/utilities/template.bitset/bitset.members/size.pass.cpp
@@ -1 +1,33 @@
-//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // test size_t count() const; #include <bitset> #include <cassert> template <std::size_t N> void test_size() { const std::bitset<N> v; assert(v.size() == N); } int main() { test_size<0>(); test_size<1>(); test_size<31>(); test_size<32>(); test_size<33>(); test_size<63>(); test_size<64>(); test_size<65>(); test_size<1000>(); } \ No newline at end of file
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test size_t count() const;
+
+#include <bitset>
+#include <cassert>
+
+template <std::size_t N>
+void test_size()
+{
+ const std::bitset<N> v;
+ assert(v.size() == N);
+}
+
+int main()
+{
+ test_size<0>();
+ test_size<1>();
+ test_size<31>();
+ test_size<32>();
+ test_size<33>();
+ test_size<63>();
+ test_size<64>();
+ test_size<65>();
+ test_size<1000>();
+}
diff --git a/libcxx/test/utilities/template.bitset/bitset.members/test.pass.cpp b/libcxx/test/utilities/template.bitset/bitset.members/test.pass.cpp
index 530cc1d9fe6..e2f0d39f02f 100644
--- a/libcxx/test/utilities/template.bitset/bitset.members/test.pass.cpp
+++ b/libcxx/test/utilities/template.bitset/bitset.members/test.pass.cpp
@@ -1 +1,53 @@
-//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // test constexpr bool test(size_t pos) const; #include <bitset> #include <cstdlib> #include <cassert> template <std::size_t N> std::bitset<N> make_bitset() { std::bitset<N> v; for (std::size_t i = 0; i < N; ++i) v[i] = static_cast<bool>(std::rand() & 1); return v; } template <std::size_t N> void test_test() { const std::bitset<N> v1 = make_bitset<N>(); try { bool b = v1.test(50); if (50 >= v1.size()) assert(false); assert(b == v1[50]); } catch (std::out_of_range&) { } } 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>(); } \ No newline at end of file
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test constexpr bool test(size_t pos) const;
+
+#include <bitset>
+#include <cstdlib>
+#include <cassert>
+
+template <std::size_t N>
+std::bitset<N>
+make_bitset()
+{
+ std::bitset<N> v;
+ for (std::size_t i = 0; i < N; ++i)
+ v[i] = static_cast<bool>(std::rand() & 1);
+ return v;
+}
+
+template <std::size_t N>
+void test_test()
+{
+ const std::bitset<N> v1 = make_bitset<N>();
+ try
+ {
+ bool b = v1.test(50);
+ if (50 >= v1.size())
+ assert(false);
+ assert(b == v1[50]);
+ }
+ catch (std::out_of_range&)
+ {
+ }
+}
+
+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>();
+}
diff --git a/libcxx/test/utilities/template.bitset/bitset.members/to_string.pass.cpp b/libcxx/test/utilities/template.bitset/bitset.members/to_string.pass.cpp
index a44877902b3..eebe8d1e23e 100644
--- a/libcxx/test/utilities/template.bitset/bitset.members/to_string.pass.cpp
+++ b/libcxx/test/utilities/template.bitset/bitset.members/to_string.pass.cpp
@@ -1 +1,160 @@
-//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // test: // template <class charT, class traits, class Allocator> // basic_string<charT, traits, Allocator> // to_string(charT zero = charT('0'), charT one = charT('1')) const; // // template <class charT, class traits> // basic_string<charT, traits, allocator<charT> > to_string() const; // // template <class charT> // basic_string<charT, char_traits<charT>, allocator<charT> > to_string() const; // // basic_string<char, char_traits<char>, allocator<char> > to_string() const; #include <bitset> #include <string> #include <cstdlib> #include <cassert> template <std::size_t N> std::bitset<N> make_bitset() { std::bitset<N> v; for (std::size_t i = 0; i < N; ++i) v[i] = static_cast<bool>(std::rand() & 1); return v; } template <std::size_t N> void test_to_string() { { std::bitset<N> v = make_bitset<N>(); { std::wstring s = v.template to_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >(); for (std::size_t i = 0; i < N; ++i) if (v[i]) assert(s[N - 1 - i] == '1'); else assert(s[N - 1 - i] == '0'); } { std::wstring s = v.template to_string<wchar_t, std::char_traits<wchar_t> >(); for (std::size_t i = 0; i < N; ++i) if (v[i]) assert(s[N - 1 - i] == '1'); else assert(s[N - 1 - i] == '0'); } { std::string s = v.template to_string<char>(); for (std::size_t i = 0; i < N; ++i) if (v[i]) assert(s[N - 1 - i] == '1'); else assert(s[N - 1 - i] == '0'); } { std::string s = v.to_string(); for (std::size_t i = 0; i < N; ++i) if (v[i]) assert(s[N - 1 - i] == '1'); else assert(s[N - 1 - i] == '0'); } } { std::bitset<N> v = make_bitset<N>(); { std::wstring s = v.template to_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >('0'); for (std::size_t i = 0; i < N; ++i) if (v[i]) assert(s[N - 1 - i] == '1'); else assert(s[N - 1 - i] == '0'); } { std::wstring s = v.template to_string<wchar_t, std::char_traits<wchar_t> >('0'); for (std::size_t i = 0; i < N; ++i) if (v[i]) assert(s[N - 1 - i] == '1'); else assert(s[N - 1 - i] == '0'); } { std::string s = v.template to_string<char>('0'); for (std::size_t i = 0; i < N; ++i) if (v[i]) assert(s[N - 1 - i] == '1'); else assert(s[N - 1 - i] == '0'); } { std::string s = v.to_string('0'); for (std::size_t i = 0; i < N; ++i) if (v[i]) assert(s[N - 1 - i] == '1'); else assert(s[N - 1 - i] == '0'); } } { std::bitset<N> v = make_bitset<N>(); { std::wstring s = v.template to_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >('0', '1'); for (std::size_t i = 0; i < N; ++i) if (v[i]) assert(s[N - 1 - i] == '1'); else assert(s[N - 1 - i] == '0'); } { std::wstring s = v.template to_string<wchar_t, std::char_traits<wchar_t> >('0', '1'); for (std::size_t i = 0; i < N; ++i) if (v[i]) assert(s[N - 1 - i] == '1'); else assert(s[N - 1 - i] == '0'); } { std::string s = v.template to_string<char>('0', '1'); for (std::size_t i = 0; i < N; ++i) if (v[i]) assert(s[N - 1 - i] == '1'); else assert(s[N - 1 - i] == '0'); } { std::string s = v.to_string('0', '1'); for (std::size_t i = 0; i < N; ++i) if (v[i]) assert(s[N - 1 - i] == '1'); else assert(s[N - 1 - i] == '0'); } } } int main() { test_to_string<0>(); test_to_string<1>(); test_to_string<31>(); test_to_string<32>(); test_to_string<33>(); test_to_string<63>(); test_to_string<64>(); test_to_string<65>(); test_to_string<1000>(); } \ No newline at end of file
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test:
+
+// template <class charT, class traits, class Allocator>
+// basic_string<charT, traits, Allocator>
+// to_string(charT zero = charT('0'), charT one = charT('1')) const;
+//
+// template <class charT, class traits>
+// basic_string<charT, traits, allocator<charT> > to_string() const;
+//
+// template <class charT>
+// basic_string<charT, char_traits<charT>, allocator<charT> > to_string() const;
+//
+// basic_string<char, char_traits<char>, allocator<char> > to_string() const;
+
+#include <bitset>
+#include <string>
+#include <cstdlib>
+#include <cassert>
+
+template <std::size_t N>
+std::bitset<N>
+make_bitset()
+{
+ std::bitset<N> v;
+ for (std::size_t i = 0; i < N; ++i)
+ v[i] = static_cast<bool>(std::rand() & 1);
+ return v;
+}
+
+template <std::size_t N>
+void test_to_string()
+{
+{
+ std::bitset<N> v = make_bitset<N>();
+ {
+ std::wstring s = v.template to_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >();
+ for (std::size_t i = 0; i < N; ++i)
+ if (v[i])
+ assert(s[N - 1 - i] == '1');
+ else
+ assert(s[N - 1 - i] == '0');
+ }
+ {
+ std::wstring s = v.template to_string<wchar_t, std::char_traits<wchar_t> >();
+ for (std::size_t i = 0; i < N; ++i)
+ if (v[i])
+ assert(s[N - 1 - i] == '1');
+ else
+ assert(s[N - 1 - i] == '0');
+ }
+ {
+ std::string s = v.template to_string<char>();
+ for (std::size_t i = 0; i < N; ++i)
+ if (v[i])
+ assert(s[N - 1 - i] == '1');
+ else
+ assert(s[N - 1 - i] == '0');
+ }
+ {
+ std::string s = v.to_string();
+ for (std::size_t i = 0; i < N; ++i)
+ if (v[i])
+ assert(s[N - 1 - i] == '1');
+ else
+ assert(s[N - 1 - i] == '0');
+ }
+}
+{
+ std::bitset<N> v = make_bitset<N>();
+ {
+ std::wstring s = v.template to_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >('0');
+ for (std::size_t i = 0; i < N; ++i)
+ if (v[i])
+ assert(s[N - 1 - i] == '1');
+ else
+ assert(s[N - 1 - i] == '0');
+ }
+ {
+ std::wstring s = v.template to_string<wchar_t, std::char_traits<wchar_t> >('0');
+ for (std::size_t i = 0; i < N; ++i)
+ if (v[i])
+ assert(s[N - 1 - i] == '1');
+ else
+ assert(s[N - 1 - i] == '0');
+ }
+ {
+ std::string s = v.template to_string<char>('0');
+ for (std::size_t i = 0; i < N; ++i)
+ if (v[i])
+ assert(s[N - 1 - i] == '1');
+ else
+ assert(s[N - 1 - i] == '0');
+ }
+ {
+ std::string s = v.to_string('0');
+ for (std::size_t i = 0; i < N; ++i)
+ if (v[i])
+ assert(s[N - 1 - i] == '1');
+ else
+ assert(s[N - 1 - i] == '0');
+ }
+}
+{
+ std::bitset<N> v = make_bitset<N>();
+ {
+ std::wstring s = v.template to_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >('0', '1');
+ for (std::size_t i = 0; i < N; ++i)
+ if (v[i])
+ assert(s[N - 1 - i] == '1');
+ else
+ assert(s[N - 1 - i] == '0');
+ }
+ {
+ std::wstring s = v.template to_string<wchar_t, std::char_traits<wchar_t> >('0', '1');
+ for (std::size_t i = 0; i < N; ++i)
+ if (v[i])
+ assert(s[N - 1 - i] == '1');
+ else
+ assert(s[N - 1 - i] == '0');
+ }
+ {
+ std::string s = v.template to_string<char>('0', '1');
+ for (std::size_t i = 0; i < N; ++i)
+ if (v[i])
+ assert(s[N - 1 - i] == '1');
+ else
+ assert(s[N - 1 - i] == '0');
+ }
+ {
+ std::string s = v.to_string('0', '1');
+ for (std::size_t i = 0; i < N; ++i)
+ if (v[i])
+ assert(s[N - 1 - i] == '1');
+ else
+ assert(s[N - 1 - i] == '0');
+ }
+}
+}
+
+int main()
+{
+ test_to_string<0>();
+ test_to_string<1>();
+ test_to_string<31>();
+ test_to_string<32>();
+ test_to_string<33>();
+ test_to_string<63>();
+ test_to_string<64>();
+ test_to_string<65>();
+ test_to_string<1000>();
+}
diff --git a/libcxx/test/utilities/template.bitset/bitset.members/to_ullong.pass.cpp b/libcxx/test/utilities/template.bitset/bitset.members/to_ullong.pass.cpp
index 0fbf212e82e..4b9b5cbda1f 100644
--- a/libcxx/test/utilities/template.bitset/bitset.members/to_ullong.pass.cpp
+++ b/libcxx/test/utilities/template.bitset/bitset.members/to_ullong.pass.cpp
@@ -1 +1,50 @@
-//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // test unsigned long long to_ullong() const; #include <bitset> #include <algorithm> #include <climits> #include <cassert> template <std::size_t N> void test_to_ullong() { const std::size_t M = sizeof(unsigned long long) * CHAR_BIT < N ? sizeof(unsigned long long) * CHAR_BIT : N; const std::size_t X = M == 0 ? sizeof(unsigned long long) * CHAR_BIT - 1 : sizeof(unsigned long long) * CHAR_BIT - M; const unsigned long long max = M == 0 ? 0 : (unsigned long long)(-1) >> X; unsigned long long tests[] = {0, std::min<unsigned long long>(1, max), std::min<unsigned long long>(2, max), std::min<unsigned long long>(3, max), std::min(max, max-3), std::min(max, max-2), std::min(max, max-1), max}; for (std::size_t i = 0; i < sizeof(tests)/sizeof(tests[0]); ++i) { unsigned long long j = tests[i]; std::bitset<N> v(j); assert(j == v.to_ullong()); } } int main() { test_to_ullong<0>(); test_to_ullong<1>(); test_to_ullong<31>(); test_to_ullong<32>(); test_to_ullong<33>(); test_to_ullong<63>(); test_to_ullong<64>(); test_to_ullong<65>(); test_to_ullong<1000>(); } \ No newline at end of file
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test unsigned long long to_ullong() const;
+
+#include <bitset>
+#include <algorithm>
+#include <climits>
+#include <cassert>
+
+template <std::size_t N>
+void test_to_ullong()
+{
+ const std::size_t M = sizeof(unsigned long long) * CHAR_BIT < N ? sizeof(unsigned long long) * CHAR_BIT : N;
+ const std::size_t X = M == 0 ? sizeof(unsigned long long) * CHAR_BIT - 1 : sizeof(unsigned long long) * CHAR_BIT - M;
+ const unsigned long long max = M == 0 ? 0 : (unsigned long long)(-1) >> X;
+ unsigned long long tests[] = {0,
+ std::min<unsigned long long>(1, max),
+ std::min<unsigned long long>(2, max),
+ std::min<unsigned long long>(3, max),
+ std::min(max, max-3),
+ std::min(max, max-2),
+ std::min(max, max-1),
+ max};
+ for (std::size_t i = 0; i < sizeof(tests)/sizeof(tests[0]); ++i)
+ {
+ unsigned long long j = tests[i];
+ std::bitset<N> v(j);
+ assert(j == v.to_ullong());
+ }
+}
+
+int main()
+{
+ test_to_ullong<0>();
+ test_to_ullong<1>();
+ test_to_ullong<31>();
+ test_to_ullong<32>();
+ test_to_ullong<33>();
+ test_to_ullong<63>();
+ test_to_ullong<64>();
+ test_to_ullong<65>();
+ test_to_ullong<1000>();
+}
diff --git a/libcxx/test/utilities/template.bitset/bitset.members/to_ulong.pass.cpp b/libcxx/test/utilities/template.bitset/bitset.members/to_ulong.pass.cpp
index da5f163362b..050b3f798ee 100644
--- a/libcxx/test/utilities/template.bitset/bitset.members/to_ulong.pass.cpp
+++ b/libcxx/test/utilities/template.bitset/bitset.members/to_ulong.pass.cpp
@@ -1 +1,50 @@
-//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // test unsigned long to_ulong() const; #include <bitset> #include <algorithm> #include <climits> #include <cassert> template <std::size_t N> void test_to_ulong() { const std::size_t M = sizeof(unsigned long) * CHAR_BIT < N ? sizeof(unsigned long) * CHAR_BIT : N; const std::size_t X = M == 0 ? sizeof(unsigned long) * CHAR_BIT - 1 : sizeof(unsigned long) * CHAR_BIT - M; const std::size_t max = M == 0 ? 0 : std::size_t(-1) >> X; std::size_t tests[] = {0, std::min<std::size_t>(1, max), std::min<std::size_t>(2, max), std::min<std::size_t>(3, max), std::min(max, max-3), std::min(max, max-2), std::min(max, max-1), max}; for (std::size_t i = 0; i < sizeof(tests)/sizeof(tests[0]); ++i) { std::size_t j = tests[i]; std::bitset<N> v(j); assert(j == v.to_ulong()); } } int main() { test_to_ulong<0>(); test_to_ulong<1>(); test_to_ulong<31>(); test_to_ulong<32>(); test_to_ulong<33>(); test_to_ulong<63>(); test_to_ulong<64>(); test_to_ulong<65>(); test_to_ulong<1000>(); } \ No newline at end of file
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test unsigned long to_ulong() const;
+
+#include <bitset>
+#include <algorithm>
+#include <climits>
+#include <cassert>
+
+template <std::size_t N>
+void test_to_ulong()
+{
+ const std::size_t M = sizeof(unsigned long) * CHAR_BIT < N ? sizeof(unsigned long) * CHAR_BIT : N;
+ const std::size_t X = M == 0 ? sizeof(unsigned long) * CHAR_BIT - 1 : sizeof(unsigned long) * CHAR_BIT - M;
+ const std::size_t max = M == 0 ? 0 : std::size_t(-1) >> X;
+ std::size_t tests[] = {0,
+ std::min<std::size_t>(1, max),
+ std::min<std::size_t>(2, max),
+ std::min<std::size_t>(3, max),
+ std::min(max, max-3),
+ std::min(max, max-2),
+ std::min(max, max-1),
+ max};
+ for (std::size_t i = 0; i < sizeof(tests)/sizeof(tests[0]); ++i)
+ {
+ std::size_t j = tests[i];
+ std::bitset<N> v(j);
+ assert(j == v.to_ulong());
+ }
+}
+
+int main()
+{
+ test_to_ulong<0>();
+ test_to_ulong<1>();
+ test_to_ulong<31>();
+ test_to_ulong<32>();
+ test_to_ulong<33>();
+ test_to_ulong<63>();
+ test_to_ulong<64>();
+ test_to_ulong<65>();
+ test_to_ulong<1000>();
+}
OpenPOWER on IntegriCloud