summaryrefslogtreecommitdiff
path: root/libstdc++-v3/testsuite/23_containers/bitset/cons
diff options
context:
space:
mode:
authorupstream source tree <ports@midipix.org>2015-03-15 20:14:05 -0400
committerupstream source tree <ports@midipix.org>2015-03-15 20:14:05 -0400
commit554fd8c5195424bdbcabf5de30fdc183aba391bd (patch)
tree976dc5ab7fddf506dadce60ae936f43f58787092 /libstdc++-v3/testsuite/23_containers/bitset/cons
downloadcbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.bz2
cbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.xz
obtained gcc-4.6.4.tar.bz2 from upstream website;upstream
verified gcc-4.6.4.tar.bz2.sig; imported gcc-4.6.4 source tree from verified upstream tarball. downloading a git-generated archive based on the 'upstream' tag should provide you with a source tree that is binary identical to the one extracted from the above tarball. if you have obtained the source via the command 'git clone', however, do note that line-endings of files in your working directory might differ from line-endings of the respective files in the upstream repository.
Diffstat (limited to 'libstdc++-v3/testsuite/23_containers/bitset/cons')
-rw-r--r--libstdc++-v3/testsuite/23_containers/bitset/cons/1.cc84
-rw-r--r--libstdc++-v3/testsuite/23_containers/bitset/cons/16020.cc41
-rw-r--r--libstdc++-v3/testsuite/23_containers/bitset/cons/2.cc46
-rw-r--r--libstdc++-v3/testsuite/23_containers/bitset/cons/3.cc62
-rw-r--r--libstdc++-v3/testsuite/23_containers/bitset/cons/38244.cc43
-rw-r--r--libstdc++-v3/testsuite/23_containers/bitset/cons/50268.cc84
-rw-r--r--libstdc++-v3/testsuite/23_containers/bitset/cons/6282.cc63
-rw-r--r--libstdc++-v3/testsuite/23_containers/bitset/cons/constexpr.cc37
-rw-r--r--libstdc++-v3/testsuite/23_containers/bitset/cons/dr1325-1.cc26
-rw-r--r--libstdc++-v3/testsuite/23_containers/bitset/cons/dr1325-2.cc80
-rw-r--r--libstdc++-v3/testsuite/23_containers/bitset/cons/dr396.cc51
11 files changed, 617 insertions, 0 deletions
diff --git a/libstdc++-v3/testsuite/23_containers/bitset/cons/1.cc b/libstdc++-v3/testsuite/23_containers/bitset/cons/1.cc
new file mode 100644
index 000000000..cc391c419
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/bitset/cons/1.cc
@@ -0,0 +1,84 @@
+// 1999-06-08 bkoz
+
+// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009
+// Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 23.3.5.1 bitset constructors
+
+#include <string>
+#include <bitset>
+#include <algorithm> // std::reverse
+#include <stdexcept>
+#include <testsuite_hooks.h>
+
+bool test01(void)
+{
+ bool test __attribute__((unused)) = true;
+
+ // bitset()
+ const size_t n1 = 5;
+ std::bitset<n1> bit01;
+ for (size_t i = 0; i < n1; ++i)
+ VERIFY( !bit01.test(i) );
+
+ // bitset(unsigned long)
+ const size_t n2 = 32;
+ unsigned long ul1 = 2;
+ std::bitset<n2> bit02(ul1);
+ VERIFY( !bit02.test(0) );
+ VERIFY( bit02.test(1) );
+ VERIFY( !bit02.test(2) );
+
+ // template<_CharT, _Traits, _Alloc>
+ // explicit bitset(const basic_string<_C,_T,_A>&, size_type pos, size_type n)
+ std::string str01("stuff smith sessions");
+ const size_t n3 = 128;
+ try {
+ std::bitset<n3> bit03(str01, 5);
+ }
+ catch(std::invalid_argument& fail) {
+ VERIFY( true );
+ }
+ catch(...) {
+ VERIFY( false );
+ }
+
+ std::string str02("010101000011");
+ int sz = str02.size();
+ try {
+ std::bitset<n3> bit03(str02, 0);
+ std::string str03;
+ for (int i = 0; i < sz; ++i)
+ str03 += (bit03.test(i) ? '1' : '0');
+ std::reverse(str03.begin(), str03.end());
+ VERIFY( str03 == str02 );
+ }
+ catch(std::invalid_argument& fail) {
+ VERIFY( false );
+ }
+ catch(...) {
+ VERIFY( false );
+ }
+ return test;
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/23_containers/bitset/cons/16020.cc b/libstdc++-v3/testsuite/23_containers/bitset/cons/16020.cc
new file mode 100644
index 000000000..f30746161
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/bitset/cons/16020.cc
@@ -0,0 +1,41 @@
+// Copyright (C) 2004, 2006, 2009 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <debug/bitset>
+#include <testsuite_hooks.h>
+
+// libstdc++/16020
+void test01()
+{
+ using __gnu_debug::bitset;
+ bool test __attribute__((unused)) = true;
+
+ bitset<5> b(7);
+ bitset<5> c;
+
+ bitset<5> bb(b);
+ c = bb;
+
+ VERIFY( bb == b );
+ VERIFY( c == bb );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/23_containers/bitset/cons/2.cc b/libstdc++-v3/testsuite/23_containers/bitset/cons/2.cc
new file mode 100644
index 000000000..4a394473f
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/bitset/cons/2.cc
@@ -0,0 +1,46 @@
+// { dg-options "-std=gnu++0x" }
+
+// Copyright (C) 2009, 2010 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <bitset>
+#include <string>
+#include <testsuite_hooks.h>
+
+struct X
+{
+ operator const char*() { return "10101010"; }
+};
+
+void
+test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ X x;
+ std::string s(x);
+ std::bitset<32> b1(static_cast<const char*>(x));
+ std::bitset<32> b2(s);
+ VERIFY( b1 == b2 );
+}
+
+int
+main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/23_containers/bitset/cons/3.cc b/libstdc++-v3/testsuite/23_containers/bitset/cons/3.cc
new file mode 100644
index 000000000..b90806870
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/bitset/cons/3.cc
@@ -0,0 +1,62 @@
+// { dg-options "-std=gnu++0x" }
+
+// 2009-12-31 Paolo Carlini <paolo.carlini@oracle.com>
+
+// Copyright (C) 2009 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <bitset>
+#include <testsuite_hooks.h>
+
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ const unsigned long long num0 = 0ULL;
+ std::bitset<0> bs0(num0);
+ VERIFY( bs0.to_ullong() == num0 );
+
+ const unsigned long long num1 = 215ULL;
+ std::bitset<32> bs1(num1);
+ VERIFY( bs1.to_ullong() == num1 );
+
+ const unsigned long long num2 = 215ULL;
+ std::bitset<64> bs2(num2);
+ VERIFY( bs2.to_ullong() == num2 );
+
+ const unsigned long long num3 = 343353215ULL;
+ std::bitset<32> bs3(num3);
+ VERIFY( bs3.to_ullong() == num3 );
+
+ const unsigned long long num4 = 343353215ULL;
+ std::bitset<64> bs4(num4);
+ VERIFY( bs4.to_ullong() == num4 );
+
+ const unsigned long long num5 = 13008719539498589283ULL;
+ std::bitset<64> bs5(num5);
+ VERIFY( bs5.to_ullong() == num5 );
+
+ const unsigned long long num6 = 13008719539498589283ULL;
+ std::bitset<128> bs6(num6);
+ VERIFY( bs6.to_ullong() == num6 );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/23_containers/bitset/cons/38244.cc b/libstdc++-v3/testsuite/23_containers/bitset/cons/38244.cc
new file mode 100644
index 000000000..fae2174b0
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/bitset/cons/38244.cc
@@ -0,0 +1,43 @@
+// Copyright (C) 2008, 2009 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// { dg-do compile }
+
+#include <bitset>
+
+class C0
+{
+ public:
+ C0() : b(0) { }
+ private:
+ std::bitset<1> b;
+};
+
+class C1
+{
+ public:
+ C1() : b(1) { }
+ private:
+ std::bitset<1> b;
+};
+
+// libstdc++/38244
+void func()
+{
+ C0 val0;
+ C1 val1;
+}
diff --git a/libstdc++-v3/testsuite/23_containers/bitset/cons/50268.cc b/libstdc++-v3/testsuite/23_containers/bitset/cons/50268.cc
new file mode 100644
index 000000000..6a61d7e2f
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/bitset/cons/50268.cc
@@ -0,0 +1,84 @@
+// { dg-options "-std=gnu++0x" }
+
+// Copyright (C) 2011 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <bitset>
+#include <testsuite_hooks.h>
+
+// libstdc++/50268
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::bitset<1> b1(3ULL);
+ VERIFY( b1.count() == 1ULL );
+
+ std::bitset<3> b2(30ULL);
+ VERIFY( b2.count() == 2ULL );
+
+ std::bitset<6> b3(300ULL);
+ VERIFY( b3.count() == 3ULL );
+
+ std::bitset<9> b4(3000ULL);
+ VERIFY( b4.count() == 5ULL );
+
+ std::bitset<16> b5(300000ULL);
+ VERIFY( b5.count() == 7ULL );
+
+ std::bitset<24> b6(30000000ULL);
+ VERIFY( b6.count() == 9ULL );
+
+ std::bitset<32> b7(30000000000ULL);
+ VERIFY( b7.count() == 13ULL );
+
+ std::bitset<37> b8(3000000000000ULL);
+ VERIFY( b8.count() == 18ULL );
+
+ std::bitset<40> b9(30000000000000ULL);
+ VERIFY( b9.count() == 16ULL );
+
+ std::bitset<45> b10(30000000000000ULL);
+ VERIFY( b10.count() == 20ULL );
+
+ std::bitset<64> b11(30000000000000ULL);
+ VERIFY( b11.count() == 20ULL );
+
+ std::bitset<100> b12(30000000000000ULL);
+ VERIFY( b12.count() == 20ULL );
+
+ std::bitset<200> b13(30000000000000ULL);
+ VERIFY( b13.count() == 20ULL );
+
+ std::bitset<45> b14(18446744073709551615ULL);
+ VERIFY( b14.count() == 45ULL );
+
+ std::bitset<64> b15(18446744073709551615ULL);
+ VERIFY( b15.count() == 64ULL );
+
+ std::bitset<100> b16(18446744073709551615ULL);
+ VERIFY( b16.count() == 64ULL );
+
+ std::bitset<200> b17(18446744073709551615ULL);
+ VERIFY( b17.count() == 64ULL );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/23_containers/bitset/cons/6282.cc b/libstdc++-v3/testsuite/23_containers/bitset/cons/6282.cc
new file mode 100644
index 000000000..387852412
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/bitset/cons/6282.cc
@@ -0,0 +1,63 @@
+// 1999-06-08 bkoz
+
+// Copyright (C) 1999, 2000, 2002, 2003, 2009 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 23.3.5.1 bitset constructors
+
+#include <string>
+#include <bitset>
+#include <stdexcept>
+#include <testsuite_hooks.h>
+
+// boundary condition: a zero-sized set
+// libstdc++/6282
+bool test02(void)
+{
+ using std::char_traits; using std::allocator;
+ bool test __attribute__((unused)) = true;
+
+ std::bitset<0> z1;
+ VERIFY( z1.any() == false );
+
+ std::bitset<0> z2(12345);
+ VERIFY( z2.any() == false );
+
+ std::bitset<0> z3(std::string("10101010101"));
+ VERIFY( z3.any() == false );
+
+ try {
+ z1.set(0);
+ VERIFY( false );
+ }
+ catch(std::out_of_range& fail) {
+ VERIFY( true );
+ }
+ catch(...) {
+ VERIFY( false );
+ }
+
+ VERIFY( z1.to_ulong() == 0 );
+ VERIFY( (z1.to_string<char,char_traits<char>,allocator<char> >().empty() ));
+ return test;
+}
+
+int main()
+{
+ test02();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/23_containers/bitset/cons/constexpr.cc b/libstdc++-v3/testsuite/23_containers/bitset/cons/constexpr.cc
new file mode 100644
index 000000000..aea503013
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/bitset/cons/constexpr.cc
@@ -0,0 +1,37 @@
+// { dg-do compile }
+// { dg-options "-std=gnu++0x" }
+
+// Copyright (C) 2010 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <bitset>
+#include <testsuite_common_types.h>
+
+int main()
+{
+ __gnu_test::constexpr_default_constructible test1;
+ test1.operator()<std::bitset<0>>();
+ test1.operator()<std::bitset<1>>();
+ test1.operator()<std::bitset<256>>();
+
+ __gnu_test::constexpr_single_value_constructible test2;
+ test2.operator()<std::bitset<0>, unsigned long long>();
+ test2.operator()<std::bitset<1>, unsigned long long>();
+ test2.operator()<std::bitset<256>, unsigned long long>();
+
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/23_containers/bitset/cons/dr1325-1.cc b/libstdc++-v3/testsuite/23_containers/bitset/cons/dr1325-1.cc
new file mode 100644
index 000000000..c79727e04
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/bitset/cons/dr1325-1.cc
@@ -0,0 +1,26 @@
+// { dg-options "-std=gnu++0x" }
+// { dg-do compile }
+
+// 2010-10-11 Paolo Carlini <paolo.carlini@oracle.com>
+
+// Copyright (C) 2010 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <bitset>
+
+// DR 1325.
+std::bitset<10> b(0);
diff --git a/libstdc++-v3/testsuite/23_containers/bitset/cons/dr1325-2.cc b/libstdc++-v3/testsuite/23_containers/bitset/cons/dr1325-2.cc
new file mode 100644
index 000000000..e261ce5e6
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/bitset/cons/dr1325-2.cc
@@ -0,0 +1,80 @@
+// { dg-options "-std=gnu++0x" }
+
+// 2010-10-11 Paolo Carlini <paolo.carlini@oracle.com>
+
+// Copyright (C) 2010 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <bitset>
+#include <testsuite_hooks.h>
+
+template<std::size_t Nb, typename CharT>
+ std::bitset<Nb>
+ test01_ref(const CharT* str,
+ typename std::basic_string<CharT>::size_type n
+ = std::basic_string<CharT>::npos,
+ CharT zero = CharT('0'), CharT one = CharT('1'))
+ {
+ return std::bitset<Nb>(n == std::basic_string<CharT>::npos
+ ? std::basic_string<CharT>(str)
+ : std::basic_string<CharT>(str, n),
+ 0, n, zero, one);
+ }
+
+// DR 1325.
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+ using namespace std;
+
+ const char s1[4] = { '0', '1', '0', '1' };
+ VERIFY( bitset<4>(s1, 4) == test01_ref<4>(s1, 4) );
+
+ const char s2[3] = { '1', '1', '0' };
+ VERIFY( bitset<6>(s2, 3) == test01_ref<6>(s2, 3) );
+
+ const char* s3 = "1110110";
+ VERIFY( bitset<7>(s3) == test01_ref<7>(s3) );
+
+ const char* s4 = "0011";
+ VERIFY( bitset<10>(s4) == test01_ref<10>(s4) );
+
+ const char* s5 = "011110000111001";
+ VERIFY( bitset<5>(s5) == test01_ref<5>(s5) );
+
+ const char* s6 = "1cc1c1";
+ VERIFY( bitset<6>(s6, basic_string<char>::npos, 'c')
+ == test01_ref<6>(s6, basic_string<char>::npos, 'c') );
+
+ const char* s7 = "001011101";
+ VERIFY( bitset<9>(s7, basic_string<char>::npos, '0', '1')
+ == test01_ref<9>(s7, basic_string<char>::npos, '0', '1') );
+
+ const char* s8 = "babb";
+ VERIFY( bitset<4>(s8, basic_string<char>::npos, 'a', 'b')
+ == test01_ref<4>(s8, basic_string<char>::npos, 'a', 'b') );
+
+ const char* s9 = "bbabbbaaa";
+ VERIFY( bitset<100>(s9, basic_string<char>::npos, 'a', 'b')
+ == test01_ref<100>(s9, basic_string<char>::npos, 'a', 'b') );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/23_containers/bitset/cons/dr396.cc b/libstdc++-v3/testsuite/23_containers/bitset/cons/dr396.cc
new file mode 100644
index 000000000..9fdb807d8
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/bitset/cons/dr396.cc
@@ -0,0 +1,51 @@
+// 2009-09-23 Paolo Carlini <paolo.carlini@oracle.com>
+
+// Copyright (C) 2008, 2009 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <bitset>
+#include <testsuite_hooks.h>
+
+// DR 396. what are characters zero and one.
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::bitset<4> z1(std::string("bbab"), 0, std::string::npos, 'a', 'b');
+ VERIFY( z1.to_string('a', 'b') == "bbab" );
+
+ std::bitset<4> z2(std::string("11a1"), 0, std::string::npos, 'a');
+ VERIFY( z2.to_string('a') == "11a1" );
+
+ std::bitset<8> z3(std::string("babb"), 0, std::string::npos, 'a', 'b');
+ VERIFY( z3.to_string('a', 'b') == "aaaababb" );
+
+ std::bitset<8> z4(std::string("1a11"), 0, std::string::npos, 'a');
+ VERIFY( z4.to_string('a') == "aaaa1a11" );
+
+ std::bitset<2> z5(std::string("bbab"), 0, std::string::npos, 'a', 'b');
+ VERIFY( z5.to_string('a', 'b') == "bb" );
+
+ std::bitset<2> z6(std::string("11a1"), 0, std::string::npos, 'a');
+ VERIFY( z6.to_string('a') == "11" );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}