Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygenreviter_test.cpp
Go to the documentation of this file.
00001 #include <vector> 00002 #include <list> 00003 #include <algorithm> 00004 00005 #include "cppunit/cppunit_proxy.h" 00006 00007 #if !defined (STLPORT) || defined(_STLP_USE_NAMESPACES) 00008 using namespace std; 00009 #endif 00010 00011 // 00012 // TestCase class 00013 // 00014 class ReviterTest : public CPPUNIT_NS::TestCase 00015 { 00016 CPPUNIT_TEST_SUITE(ReviterTest); 00017 CPPUNIT_TEST(reviter1); 00018 CPPUNIT_TEST(reviter2); 00019 CPPUNIT_TEST(revbit1); 00020 CPPUNIT_TEST_SUITE_END(); 00021 00022 protected: 00023 void reviter1(); 00024 void reviter2(); 00025 void revbit1(); 00026 }; 00027 00028 CPPUNIT_TEST_SUITE_REGISTRATION(ReviterTest); 00029 00030 // 00031 // tests implementation 00032 // 00033 void ReviterTest::reviter1() 00034 { 00035 int array [] = { 1, 5, 2, 3 }; 00036 00037 vector<int> v(array, array + 4); 00038 typedef vector<int>::reverse_iterator reviter; 00039 reviter r(v.rend()); 00040 r--; 00041 00042 CPPUNIT_ASSERT(*r-- == 1); 00043 CPPUNIT_ASSERT(*r-- == 5); 00044 CPPUNIT_ASSERT(*r-- == 2); 00045 CPPUNIT_ASSERT(*r == 3); 00046 CPPUNIT_ASSERT(r==v.rbegin()); 00047 } 00048 void ReviterTest::reviter2() 00049 { 00050 int array [] = { 1, 5, 2, 3 }; 00051 00052 vector<int> v(array, array + 4); 00053 vector<int>::reverse_iterator r; 00054 r = v.rbegin(); 00055 CPPUNIT_ASSERT(*r++ == 3); 00056 CPPUNIT_ASSERT(*r++ == 2); 00057 CPPUNIT_ASSERT(*r++ == 5); 00058 CPPUNIT_ASSERT(*r++ == 1); 00059 CPPUNIT_ASSERT(r==v.rend()); 00060 } 00061 void ReviterTest::revbit1() 00062 { 00063 int array [] = { 1, 5, 2, 3 }; 00064 00065 list<int> v(array, array + 4); 00066 list<int>::reverse_iterator r(v.rbegin()); 00067 CPPUNIT_ASSERT(*r++ == 3); 00068 CPPUNIT_ASSERT(*r++ == 2); 00069 CPPUNIT_ASSERT(*r++ == 5); 00070 CPPUNIT_ASSERT(*r++ == 1); 00071 CPPUNIT_ASSERT(r==v.rend()); 00072 } Generated on Sun May 27 2012 04:35:44 for ReactOS by
1.7.6.1
|