ReactOS 0.4.16-dev-340-g0540c21
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)
8using namespace std;
9#endif
10
11//
12// TestCase class
13//
14class ReviterTest : public CPPUNIT_NS::TestCase
15{
21
22protected:
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);
53 vector<int>::reverse_iterator r;
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);
66 list<int>::reverse_iterator r(v.rbegin());
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}
void reviter1()
void reviter2()
CPPUNIT_TEST(revbit1)
CPPUNIT_TEST(reviter1)
CPPUNIT_TEST_SUITE_END()
CPPUNIT_TEST(reviter2)
void revbit1()
CPPUNIT_TEST_SUITE(ReviterTest)
#define CPPUNIT_TEST_SUITE_REGISTRATION(X)
Definition: cppunit_mini.h:193
#define CPPUNIT_ASSERT(X)
Definition: cppunit_mini.h:200
const GLdouble * v
Definition: gl.h:2040
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
Definition: features.h:417