3 // Copyright (C) 1999, 2000, 2002, 2003 Free Software Foundation, Inc.
5 // This file is part of the GNU ISO C++ Library. This library is free
6 // software; you can redistribute it and/or modify it under the
7 // terms of the GNU General Public License as published by the
8 // Free Software Foundation; either version 2, or (at your option)
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License along
17 // with this library; see the file COPYING. If not, write to the Free
18 // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
21 // 23.3.5.1 bitset constructors
26 #include <testsuite_hooks.h>
30 bool test __attribute__((unused)) = true;
34 std::bitset<n1> bit01;
35 for (size_t i = 0; i < n1; ++i)
36 VERIFY( !bit01.test(i) );
38 // bitset(unsigned long)
40 unsigned long ul1 = 2;
41 std::bitset<n2> bit02(ul1);
42 VERIFY( !bit02.test(0) );
43 VERIFY( bit02.test(1) );
44 VERIFY( !bit02.test(2) );
46 // template<_CharT, _Traits, _Alloc>
47 // explicit bitset(const basic_string<_C,_T,_A>&, size_type pos, size_type n)
48 std::string str01("stuff smith sessions");
49 const size_t n3 = 128;
51 std::bitset<n3> bit03(str01, 5);
53 catch(std::invalid_argument& fail) {
60 std::string str02("010101000011");
61 int sz = str02.size();
63 std::bitset<n3> bit03(str02, 0);
65 for (int i = 0; i < sz; ++i)
66 str03 += (bit03.test(i) ? '1' : '0');
67 std::reverse(str03.begin(), str03.end());
68 VERIFY( str03 == str02 );
70 catch(std::invalid_argument& fail) {