ReactOS  0.4.15-dev-3440-g915569a
reviter_test.cpp
Go to the documentation of this file.
1 #include <vector>
2 #include <list>
3 #include <algorithm>
4 
6 
7 #if !defined (STLPORT) || defined(_STLP_USE_NAMESPACES)
8 using namespace std;
9 #endif
10 
11 //
12 // TestCase class
13 //
14 class ReviterTest : public CPPUNIT_NS::TestCase
15 {
17  CPPUNIT_TEST(reviter1);
18  CPPUNIT_TEST(reviter2);
19  CPPUNIT_TEST(revbit1);
21 
22 protected:
23  void reviter1();
24  void reviter2();
25  void revbit1();
26 };
27 
29 
30 //
31 // tests implementation
32 //
34 {
35  int array [] = { 1, 5, 2, 3 };
36 
37  vector<int> v(array, array + 4);
38  typedef vector<int>::reverse_iterator reviter;
39  reviter r(v.rend());
40  r--;
41 
42  CPPUNIT_ASSERT(*r-- == 1);
43  CPPUNIT_ASSERT(*r-- == 5);
44  CPPUNIT_ASSERT(*r-- == 2);
45  CPPUNIT_ASSERT(*r == 3);
46  CPPUNIT_ASSERT(r==v.rbegin());
47 }
49 {
50  int array [] = { 1, 5, 2, 3 };
51 
52  vector<int> v(array, array + 4);
54  r = v.rbegin();
55  CPPUNIT_ASSERT(*r++ == 3);
56  CPPUNIT_ASSERT(*r++ == 2);
57  CPPUNIT_ASSERT(*r++ == 5);
58  CPPUNIT_ASSERT(*r++ == 1);
59  CPPUNIT_ASSERT(r==v.rend());
60 }
62 {
63  int array [] = { 1, 5, 2, 3 };
64 
65  list<int> v(array, array + 4);
67  CPPUNIT_ASSERT(*r++ == 3);
68  CPPUNIT_ASSERT(*r++ == 2);
69  CPPUNIT_ASSERT(*r++ == 5);
70  CPPUNIT_ASSERT(*r++ == 1);
71  CPPUNIT_ASSERT(r==v.rend());
72 }
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define reverse_iterator
Definition: _abbrevs.h:34
#define CPPUNIT_TEST_SUITE(X)
Definition: cppunit_mini.h:142
#define CPPUNIT_TEST(X)
Definition: cppunit_mini.h:182
void reviter1()
Definition: features.h:417
void revbit1()
#define CPPUNIT_TEST_SUITE_END()
Definition: cppunit_mini.h:191
CPPUNIT_TEST_SUITE_REGISTRATION(ReviterTest)
#define CPPUNIT_ASSERT(X)
Definition: cppunit_mini.h:200
const GLdouble * v
Definition: gl.h:2040
void reviter2()