Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygeninsert_test.cpp
Go to the documentation of this file.
00001 #include <deque> 00002 #include <vector> 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 InsertTest : public CPPUNIT_NS::TestCase 00015 { 00016 CPPUNIT_TEST_SUITE(InsertTest); 00017 CPPUNIT_TEST(insert1); 00018 CPPUNIT_TEST(insert2); 00019 CPPUNIT_TEST_SUITE_END(); 00020 00021 protected: 00022 void insert1(); 00023 void insert2(); 00024 }; 00025 00026 CPPUNIT_TEST_SUITE_REGISTRATION(InsertTest); 00027 00028 // 00029 // tests implementation 00030 // 00031 void InsertTest::insert1() 00032 { 00033 char const* array1 [] = { "laurie", "jennifer", "leisa" }; 00034 char const* array2 [] = { "amanda", "saskia", "carrie" }; 00035 00036 deque<char const*> names(array1, array1 + 3); 00037 deque<char const*>::iterator i = names.begin() + 2; 00038 00039 insert_iterator<deque <char const*> > itd(names, i); 00040 itd = copy(array2, array2 + 3, insert_iterator<deque <char const*> >(names, i)); 00041 00042 CPPUNIT_ASSERT( !strcmp(names[0], "laurie") ); 00043 CPPUNIT_ASSERT( !strcmp(names[1], "jennifer") ); 00044 CPPUNIT_ASSERT( !strcmp(names[2], "amanda") ); 00045 CPPUNIT_ASSERT( !strcmp(names[3], "saskia") ); 00046 CPPUNIT_ASSERT( !strcmp(names[4], "carrie") ); 00047 CPPUNIT_ASSERT( !strcmp(names[5], "leisa") ); 00048 00049 copy(array1, array1 + 3, itd); 00050 CPPUNIT_ASSERT( !strcmp(names[5], "laurie") ); 00051 CPPUNIT_ASSERT( !strcmp(names[6], "jennifer") ); 00052 CPPUNIT_ASSERT( !strcmp(names[7], "leisa") ); 00053 CPPUNIT_ASSERT( !strcmp(names[8], "leisa") ); 00054 } 00055 void InsertTest::insert2() 00056 { 00057 char const* array1 [] = { "laurie", "jennifer", "leisa" }; 00058 char const* array2 [] = { "amanda", "saskia", "carrie" }; 00059 00060 deque<char const*> names(array1, array1 + 3); 00061 deque<char const*>::iterator i = names.begin() + 2; 00062 copy(array2, array2 + 3, inserter(names, i)); 00063 00064 CPPUNIT_ASSERT( !strcmp(names[0], "laurie") ); 00065 CPPUNIT_ASSERT( !strcmp(names[1], "jennifer") ); 00066 CPPUNIT_ASSERT( !strcmp(names[2], "amanda") ); 00067 CPPUNIT_ASSERT( !strcmp(names[3], "saskia") ); 00068 CPPUNIT_ASSERT( !strcmp(names[4], "carrie") ); 00069 CPPUNIT_ASSERT( !strcmp(names[5], "leisa") ); 00070 } Generated on Sat May 26 2012 04:34:19 for ReactOS by
1.7.6.1
|