OSDN Git Service

2008-09-23 Paolo Carlini <paolo.carlini@oracle.com>
[pf3gnuchains/gcc-fork.git] / libstdc++-v3 / testsuite / 23_containers / bitset / cons / dr396.cc
1 // 2009-09-23  Paolo Carlini  <paolo.carlini@oracle.com>
2
3 // Copyright (C) 2008 Free Software Foundation, Inc.
4 //
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)
9 // any later version.
10
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.
15
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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
19 // USA.
20
21 #include <bitset>
22 #include <testsuite_hooks.h>
23
24 // DR 396. what are characters zero and one.
25 void test01()
26 {
27   bool test __attribute__((unused)) = true;
28
29   std::bitset<4> z1("bbab", 'a', 'b');
30   std::bitset<4> z1_ref(std::string("bbab"), 0, std::string::npos, 'a', 'b');
31   VERIFY( z1.to_string('a', 'b') == "bbab" );
32   VERIFY( z1 == z1_ref );
33
34   std::bitset<4> z2("11a1", 'a');
35   std::bitset<4> z2_ref(std::string("11a1"), 0, std::string::npos, 'a');
36   VERIFY( z2.to_string('a') == "11a1" );
37   VERIFY( z2 == z2_ref );
38
39   std::bitset<8> z3("babb", 'a', 'b');
40   std::bitset<8> z3_ref(std::string("babb"), 0, std::string::npos, 'a', 'b');
41   VERIFY( z3.to_string('a', 'b') == "aaaababb" );
42   VERIFY( z3 == z3_ref );
43
44   std::bitset<8> z4("1a11", 'a');
45   std::bitset<8> z4_ref(std::string("1a11"), 0, std::string::npos, 'a');
46   VERIFY( z4.to_string('a') == "aaaa1a11" );
47   VERIFY( z4 == z4_ref );
48
49   std::bitset<2> z5("bbab", 'a', 'b');
50   std::bitset<2> z5_ref(std::string("bbab"), 0, std::string::npos, 'a', 'b');
51   VERIFY( z5.to_string('a', 'b') == "bb" );
52   VERIFY( z5 == z5_ref );
53
54   std::bitset<2> z6("11a1", 'a');
55   std::bitset<2> z6_ref(std::string("11a1"), 0, std::string::npos, 'a');
56   VERIFY( z6.to_string('a') == "11" );
57   VERIFY( z6 == z6_ref );
58 }
59
60 int main()
61 {
62   test01();
63   return 0;
64 }