3 #if !defined (STLPORT) || !defined (_STLP_USE_NO_IOSTREAMS)
7 #include "cppunit/cppunit_proxy.h"
9 #if !defined (STLPORT) || defined(_STLP_USE_NAMESPACES)
16 class BitsetTest
: public CPPUNIT_NS::TestCase
18 CPPUNIT_TEST_SUITE(BitsetTest
);
19 CPPUNIT_TEST(bitset1
);
20 #if defined (STLPORT) && defined (_STLP_USE_NO_IOSTREAMS)
23 CPPUNIT_TEST(iostream
);
24 CPPUNIT_TEST_SUITE_END();
31 CPPUNIT_TEST_SUITE_REGISTRATION(BitsetTest
);
34 // tests implementation
36 void BitsetTest::bitset1()
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);
45 #if !defined (STLPORT) || !defined (_STLP_NON_TYPE_TMPL_PARAM_BUG)
47 CPPUNIT_ASSERT(b1
== 0x1BBB);
49 CPPUNIT_ASSERT(b1
.count() == 10);
50 CPPUNIT_ASSERT(b2
.count() == 4);
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 );
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" );
74 CPPUNIT_ASSERT( b2
.to_string() == "1000100010001" );
78 void BitsetTest::iostream()
80 #if !defined (STLPORT) || !defined (_STLP_USE_NO_IOSTREAMS)
83 bitset
<13U> b(0x1111);
85 CPPUNIT_ASSERT( sstr
.str() == "1000100010001" );
89 CPPUNIT_ASSERT( b1
.test(0) );
90 CPPUNIT_ASSERT( b1
.test(4) );
91 CPPUNIT_ASSERT( b1
.test(8) );
92 CPPUNIT_ASSERT( b1
.test(12) );
94 # if !defined (STLPORT) || !defined (_STLP_NO_WCHAR_T)
97 bitset
<13U> b(0x1111);
99 CPPUNIT_ASSERT( sstr
.str() == L
"1000100010001" );
103 CPPUNIT_ASSERT( b1
.test(0) );
104 CPPUNIT_ASSERT( b1
.test(4) );
105 CPPUNIT_ASSERT( b1
.test(8) );
106 CPPUNIT_ASSERT( b1
.test(12) );