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

func_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 FuncTest : public CPPUNIT_NS::TestCase
00015 {
00016   CPPUNIT_TEST_SUITE(FuncTest);
00017   CPPUNIT_TEST(func1);
00018   CPPUNIT_TEST(func2);
00019   CPPUNIT_TEST(func3);
00020   CPPUNIT_TEST_SUITE_END();
00021 
00022 protected:
00023   void func1();
00024   void func2();
00025   void func3();
00026   static bool bigger(int i_);
00027   static bool bigger_than(int x_, int y_);
00028 };
00029 
00030 CPPUNIT_TEST_SUITE_REGISTRATION(FuncTest);
00031 
00032 //
00033 // tests implementation
00034 //
00035 bool FuncTest::bigger(int i_)
00036 {
00037   return i_ > 3;
00038 }
00039 bool FuncTest::bigger_than(int x_, int y_)
00040 {
00041     return x_ > y_;
00042 }
00043 void FuncTest::func1()
00044 {
00045   vector<int>v;
00046   v.push_back(4);
00047   v.push_back(1);
00048   v.push_back(5);
00049   int n = count_if(v.begin(), v.end(), bigger);
00050   CPPUNIT_ASSERT( n == 2 )
00051 }
00052 
00053 void FuncTest::func2()
00054 {
00055   vector<int> v;
00056   v.push_back(4);
00057   v.push_back(1);
00058   v.push_back(5);
00059   sort(v.begin(), v.end(), bigger_than);
00060 
00061   CPPUNIT_ASSERT( v[0] == 5 );
00062   CPPUNIT_ASSERT( v[1] == 4 );
00063   CPPUNIT_ASSERT( v[2] == 1 );
00064 }
00065 void FuncTest::func3()
00066 {
00067   vector<int> v;
00068   v.push_back(4);
00069   v.push_back(1);
00070   v.push_back(5);
00071   sort(v.begin(), v.end(), greater<int>());
00072 
00073   CPPUNIT_ASSERT( v[0] == 5 );
00074   CPPUNIT_ASSERT( v[1] == 4 );
00075   CPPUNIT_ASSERT( v[2] == 1 );
00076 }

Generated on Mon May 28 2012 04:35:12 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.