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

unary_test.cpp
Go to the documentation of this file.
00001 #include <vector>
00002 #include "unary.h"
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 UnaryTest : public CPPUNIT_NS::TestCase
00015 {
00016   CPPUNIT_TEST_SUITE(UnaryTest);
00017 #if !defined (STLPORT) || defined (_STLP_NO_EXTENSIONS)
00018   CPPUNIT_IGNORE;
00019 #endif
00020   CPPUNIT_TEST(ucompos1);
00021   CPPUNIT_TEST(ucompos2);
00022   CPPUNIT_STOP_IGNORE;
00023   CPPUNIT_TEST(unegate1);
00024   CPPUNIT_TEST(unegate2);
00025 #if defined (STLPORT) && !defined (_STLP_CLASS_PARTIAL_SPECIALIZATION)
00026   CPPUNIT_IGNORE;
00027 #endif
00028   CPPUNIT_TEST(unegate3);
00029   CPPUNIT_TEST_SUITE_END();
00030 
00031 protected:
00032   void ucompos1();
00033   void ucompos2();
00034   void unegate1();
00035   void unegate2();
00036   void unegate3();
00037 };
00038 
00039 CPPUNIT_TEST_SUITE_REGISTRATION(UnaryTest);
00040 
00041 //
00042 // tests implementation
00043 //
00044 void UnaryTest::unegate1()
00045 {
00046   int array [3] = { 1, 2, 3 };
00047   //unary_negate<odd>::argument_type arg_val = 0;
00048   int* p = find_if((int*)array, (int*)array + 3, unary_negate<odd>(odd()));
00049   CPPUNIT_ASSERT((p != array + 3));
00050   CPPUNIT_ASSERT(*p==2);
00051 }
00052 void UnaryTest::unegate2()
00053 {
00054   int array [3] = { 1, 2, 3 };
00055   int* p = find_if((int*)array, (int*)array + 3, not1(odd()));
00056   CPPUNIT_ASSERT(p != array + 3);
00057   CPPUNIT_ASSERT(*p==2);
00058 }
00059 
00060 bool test_func(int param) {
00061   return param < 3;
00062 }
00063 void UnaryTest::unegate3()
00064 {
00065 #if !defined (STLPORT) || defined (_STLP_CLASS_PARTIAL_SPECIALIZATION)
00066   int array [3] = { 1, 2, 3 };
00067   int* p = find_if((int*)array, (int*)array + 3, not1(ptr_fun(test_func)));
00068   CPPUNIT_ASSERT(p != array + 3);
00069   CPPUNIT_ASSERT(*p==3);
00070 #endif
00071 }
00072 
00073 void UnaryTest::ucompos1()
00074 {
00075 #if defined (STLPORT) && !defined (_STLP_NO_EXTENSIONS)
00076   int input [3] = { -1, -4, -16 };
00077 
00078   double output[3];
00079   transform((int*)input, (int*)input + 3, output, unary_compose<square_root, negate<int> >(square_root(), negate<int>()));
00080 
00081   CPPUNIT_ASSERT(output[0]==1);
00082   CPPUNIT_ASSERT(output[1]==2);
00083   CPPUNIT_ASSERT(output[2]==4);
00084 #endif
00085 }
00086 void UnaryTest::ucompos2()
00087 {
00088 #if defined (STLPORT) && !defined (_STLP_NO_EXTENSIONS)
00089   int input [3] = { -1, -4, -16 };
00090 
00091   double output [3];
00092   transform((int*)input, (int*)input + 3, output, compose1(square_root(), negate<int>()));
00093 
00094   CPPUNIT_ASSERT(output[0]==1);
00095   CPPUNIT_ASSERT(output[1]==2);
00096   CPPUNIT_ASSERT(output[2]==4);
00097 #endif
00098 }

Generated on Sat May 26 2012 04:34:48 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.