ReactOS  0.4.15-dev-2704-gd5265b0
bvector_test.cpp
Go to the documentation of this file.
1 #include <vector>
2 
4 
5 #if !defined (STLPORT) || defined (_STLP_USE_NAMESPACES)
6 using namespace std;
7 #endif
8 
9 //
10 // TestCase class
11 //
12 class BvectorTest : public CPPUNIT_NS::TestCase
13 {
15 #if !defined (STLPORT) || defined (_STLP_NO_EXTENSIONS)
17 #endif
18  CPPUNIT_TEST(bvec1);
20 
21 protected:
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 }
#define CPPUNIT_TEST_SUITE(X)
Definition: cppunit_mini.h:142
_STLP_END_NAMESPACE _STLP_BEGIN_NAMESPACE typedef vector< bool, allocator< bool > > bit_vector
Definition: _vector.h:744
#define CPPUNIT_TEST(X)
Definition: cppunit_mini.h:182
Definition: features.h:417
CPPUNIT_TEST_SUITE_REGISTRATION(BvectorTest)
#define CPPUNIT_TEST_SUITE_END()
Definition: cppunit_mini.h:191
#define b
Definition: ke_i.h:79
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
#define CPPUNIT_ASSERT(X)
Definition: cppunit_mini.h:200
void exit(int exitcode)
Definition: _exit.c:33