ReactOS 0.4.15-dev-7998-gdb93cb1
bitset_test.cpp
Go to the documentation of this file.
1#include <bitset>
2#include <algorithm>
3#if !defined (STLPORT) || !defined (_STLP_USE_NO_IOSTREAMS)
4# include <sstream>
5#endif
6
8
9#if !defined (STLPORT) || defined(_STLP_USE_NAMESPACES)
10using namespace std;
11#endif
12
13//
14// TestCase class
15//
16class BitsetTest : public CPPUNIT_NS::TestCase
17{
20#if defined (STLPORT) && defined (_STLP_USE_NO_IOSTREAMS)
22#endif
25
26protected:
27 void bitset1();
28 void iostream();
29};
30
32
33//
34// tests implementation
35//
37{
38 bitset<13U> b1(0xFFFF);
39 bitset<13U> b2(0x1111);
40 CPPUNIT_ASSERT(b1.size() == 13);
41 CPPUNIT_ASSERT(b1 == 0x1FFF);
42 CPPUNIT_ASSERT(b2.size() == 13);
43 CPPUNIT_ASSERT(b2 == 0x1111);
44
45#if !defined (STLPORT) || !defined (_STLP_NON_TYPE_TMPL_PARAM_BUG)
46 b1 = b1 ^ (b2 << 2);
47 CPPUNIT_ASSERT(b1 == 0x1BBB);
48
49 CPPUNIT_ASSERT(b1.count() == 10);
50 CPPUNIT_ASSERT(b2.count() == 4);
51
52# if defined (STLPORT) && !defined (_STLP_NO_EXTENSIONS)
53 size_t __pos = b2._Find_first();
54 CPPUNIT_ASSERT( __pos == 0 );
55 __pos = b2._Find_next(__pos);
56 CPPUNIT_ASSERT( __pos == 4 );
57 __pos = b2._Find_next(__pos);
58 CPPUNIT_ASSERT( __pos == 8 );
59 __pos = b2._Find_next(__pos);
60 CPPUNIT_ASSERT( __pos == 12 );
61 __pos = b2._Find_next(__pos);
62 CPPUNIT_ASSERT( __pos == 13 );
63# endif
64#endif
65
66#if !defined (STLPORT) || !defined (_STLP_NO_MEMBER_TEMPLATES) && !defined (_STLP_NO_EXPLICIT_FUNCTION_TMPL_ARGS)
67 string representation = b2.to_string<char, char_traits<char>, allocator<char> >();
68 CPPUNIT_ASSERT( representation == "1000100010001" );
69# if !defined (STLPORT) || !defined (_STLP_NO_WCHAR_T)
70 wstring wrepresentation = b2.to_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >();
71 CPPUNIT_ASSERT( wrepresentation == L"1000100010001" );
72# endif
73#else
74 CPPUNIT_ASSERT( b2.to_string() == "1000100010001" );
75#endif
76}
77
79{
80#if !defined (STLPORT) || !defined (_STLP_USE_NO_IOSTREAMS)
81 {
82 stringstream sstr;
83 bitset<13U> b(0x1111);
84 sstr << b;
85 CPPUNIT_ASSERT( sstr.str() == "1000100010001" );
86
88 sstr >> b1;
89 CPPUNIT_ASSERT( b1.test(0) );
90 CPPUNIT_ASSERT( b1.test(4) );
91 CPPUNIT_ASSERT( b1.test(8) );
92 CPPUNIT_ASSERT( b1.test(12) );
93 }
94# if !defined (STLPORT) || !defined (_STLP_NO_WCHAR_T)
95 {
96 wstringstream sstr;
97 bitset<13U> b(0x1111);
98 sstr << b;
99 CPPUNIT_ASSERT( sstr.str() == L"1000100010001" );
100
102 sstr >> b1;
103 CPPUNIT_ASSERT( b1.test(0) );
104 CPPUNIT_ASSERT( b1.test(4) );
105 CPPUNIT_ASSERT( b1.test(8) );
106 CPPUNIT_ASSERT( b1.test(12) );
107 }
108# endif
109#endif
110}
void bitset1()
Definition: bitset_test.cpp:36
CPPUNIT_TEST(iostream)
CPPUNIT_TEST_SUITE(BitsetTest)
CPPUNIT_TEST_SUITE_END()
CPPUNIT_TEST(bitset1)
void iostream()
Definition: bitset_test.cpp:78
_String str() const
Definition: _sstream.h:230
#define CPPUNIT_IGNORE
Definition: cppunit_mini.h:185
#define CPPUNIT_TEST_SUITE_REGISTRATION(X)
Definition: cppunit_mini.h:193
#define CPPUNIT_ASSERT(X)
Definition: cppunit_mini.h:200
unsigned char
Definition: typeof.h:29
#define b
Definition: ke_i.h:79
static CRYPT_DATA_BLOB b2[]
Definition: msg.c:582
static CRYPT_DATA_BLOB b1[]
Definition: msg.c:573
Definition: features.h:417
#define L(x)
Definition: ntvdm.h:50
#define wchar_t
Definition: wchar.h:102