]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/23_containers/bitset/cons/dr1325-2.cc
1 // { dg-do run { target c++11 } }
3 // 2010-10-11 Paolo Carlini <paolo.carlini@oracle.com>
5 // Copyright (C) 2010-2019 Free Software Foundation, Inc.
7 // This file is part of the GNU ISO C++ Library. This library is free
8 // software; you can redistribute it and/or modify it under the
9 // terms of the GNU General Public License as published by the
10 // Free Software Foundation; either version 3, or (at your option)
13 // This library is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU General Public License for more details.
18 // You should have received a copy of the GNU General Public License along
19 // with this library; see the file COPYING3. If not see
20 // <http://www.gnu.org/licenses/>.
23 #include <testsuite_hooks.h>
25 template<std::size_t Nb
, typename CharT
>
27 test01_ref(const CharT
* str
,
28 typename
std::basic_string
<CharT
>::size_type n
29 = std::basic_string
<CharT
>::npos
,
30 CharT zero
= CharT('0'), CharT one
= CharT('1'))
32 return std::bitset
<Nb
>(n
== std::basic_string
<CharT
>::npos
33 ? std::basic_string
<CharT
>(str
)
34 : std::basic_string
<CharT
>(str
, n
),
43 const char s1
[4] = { '0', '1', '0', '1' };
44 VERIFY( bitset
<4>(s1
, 4) == test01_ref
<4>(s1
, 4) );
46 const char s2
[3] = { '1', '1', '0' };
47 VERIFY( bitset
<6>(s2
, 3) == test01_ref
<6>(s2
, 3) );
49 const char* s3
= "1110110";
50 VERIFY( bitset
<7>(s3
) == test01_ref
<7>(s3
) );
52 const char* s4
= "0011";
53 VERIFY( bitset
<10>(s4
) == test01_ref
<10>(s4
) );
55 const char* s5
= "011110000111001";
56 VERIFY( bitset
<5>(s5
) == test01_ref
<5>(s5
) );
58 const char* s6
= "1cc1c1";
59 VERIFY( bitset
<6>(s6
, basic_string
<char>::npos
, 'c')
60 == test01_ref
<6>(s6
, basic_string
<char>::npos
, 'c') );
62 const char* s7
= "001011101";
63 VERIFY( bitset
<9>(s7
, basic_string
<char>::npos
, '0', '1')
64 == test01_ref
<9>(s7
, basic_string
<char>::npos
, '0', '1') );
66 const char* s8
= "babb";
67 VERIFY( bitset
<4>(s8
, basic_string
<char>::npos
, 'a', 'b')
68 == test01_ref
<4>(s8
, basic_string
<char>::npos
, 'a', 'b') );
70 const char* s9
= "bbabbbaaa";
71 VERIFY( bitset
<100>(s9
, basic_string
<char>::npos
, 'a', 'b')
72 == test01_ref
<100>(s9
, basic_string
<char>::npos
, 'a', 'b') );