ReactOS 0.4.16-dev-117-g38f21f9
bvector_test.cpp
Go to the documentation of this file.
1#include <vector>
2
4
5#if !defined (STLPORT) || defined (_STLP_USE_NAMESPACES)
6using namespace std;
7#endif
8
9//
10// TestCase class
11//
12class BvectorTest : public CPPUNIT_NS::TestCase
13{
15#if !defined (STLPORT) || defined (_STLP_NO_EXTENSIONS)
17#endif
20
21protected:
22 void bvec1();
23};
24
26
27//
28// tests implementation
29//
31{
32#if defined (STLPORT) && !defined (_STLP_NO_EXTENSIONS)
33 bool ii[3]= {1,0,1};
34 bit_vector b(3);
35
36 CPPUNIT_ASSERT(b[0]==0);
37 CPPUNIT_ASSERT(b[1]==0);
38 CPPUNIT_ASSERT(b[2]==0);
39
40 b[0] = b[2] = 1;
41
42 CPPUNIT_ASSERT(b[0]==1);
43 CPPUNIT_ASSERT(b[1]==0);
44 CPPUNIT_ASSERT(b[2]==1);
45
46 b.insert(b.begin(),(bool*)ii, ii+2);
47
48 CPPUNIT_ASSERT(b[0]==1);
49 CPPUNIT_ASSERT(b[1]==0);
50 CPPUNIT_ASSERT(b[2]==1);
51 CPPUNIT_ASSERT(b[3]==0);
52 CPPUNIT_ASSERT(b[4]==1);
53
54 bit_vector bb = b;
55 if (bb != b)
56 exit(1);
57
58 b[0] |= 0;
59 b[1] |= 0;
60 b[2] |= 1;
61 b[3] |= 1;
62 CPPUNIT_ASSERT(!((b[0] != 1) || (b[1] != 0) || (b[2] != 1) || (b[3] != 1)));
63
64
65 bb[0] &= 0;
66 bb[1] &= 0;
67 bb[2] &= 1;
68 bb[3] &= 1;
69 CPPUNIT_ASSERT(!((bb[0] != 0) || (bb[1] != 0) || (bb[2] != 1) || (bb[3] != 0)));
70#endif
71}
_STLP_END_NAMESPACE _STLP_BEGIN_NAMESPACE typedef vector< bool, allocator< bool > > bit_vector
Definition: _vector.h:744
CPPUNIT_TEST_SUITE(BvectorTest)
CPPUNIT_TEST(bvec1)
CPPUNIT_TEST_SUITE_END()
#define CPPUNIT_TEST_SUITE_REGISTRATION(X)
Definition: cppunit_mini.h:193
#define CPPUNIT_ASSERT(X)
Definition: cppunit_mini.h:200
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
#define b
Definition: ke_i.h:79
Definition: features.h:417
#define exit(n)
Definition: config.h:202