ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

inplace_test.cpp
Go to the documentation of this file.
00001 #include <vector>
00002 #include <algorithm>
00003 #include <functional>
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 InplaceTest : public CPPUNIT_NS::TestCase
00015 {
00016   CPPUNIT_TEST_SUITE(InplaceTest);
00017   CPPUNIT_TEST(inplmrg1);
00018   CPPUNIT_TEST(inplmrg2);
00019   CPPUNIT_TEST_SUITE_END();
00020 
00021 protected:
00022   void inplmrg1();
00023   void inplmrg2();
00024 };
00025 
00026 CPPUNIT_TEST_SUITE_REGISTRATION(InplaceTest);
00027 
00028 //
00029 // tests implementation
00030 //
00031 void InplaceTest::inplmrg1()
00032 {
00033   int numbers[6] = { 1, 10, 42, 3, 16, 32 };
00034   inplace_merge(numbers, numbers + 3, numbers + 6);
00035 
00036   CPPUNIT_ASSERT(numbers[0]==1);
00037   CPPUNIT_ASSERT(numbers[1]==3);
00038   CPPUNIT_ASSERT(numbers[2]==10);
00039   CPPUNIT_ASSERT(numbers[3]==16);
00040   CPPUNIT_ASSERT(numbers[4]==32);
00041   CPPUNIT_ASSERT(numbers[5]==42);
00042 }
00043 void InplaceTest::inplmrg2()
00044 {
00045   vector<size_t> v1(10);
00046   for(size_t i = 0; i < v1.size(); ++i)
00047     v1[i] =(v1.size() - i - 1) % 5;
00048 
00049   inplace_merge(v1.begin(), v1.begin() + 5, v1.end(), greater<size_t>());
00050 
00051   CPPUNIT_ASSERT(v1[0]==4);
00052   CPPUNIT_ASSERT(v1[1]==4);
00053   CPPUNIT_ASSERT(v1[2]==3);
00054   CPPUNIT_ASSERT(v1[3]==3);
00055   CPPUNIT_ASSERT(v1[4]==2);
00056   CPPUNIT_ASSERT(v1[5]==2);
00057   CPPUNIT_ASSERT(v1[6]==1);
00058   CPPUNIT_ASSERT(v1[7]==1);
00059   CPPUNIT_ASSERT(v1[8]==0);
00060   CPPUNIT_ASSERT(v1[9]==0);
00061 }

Generated on Sun May 27 2012 04:35:26 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.