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

test_algobase.cpp
Go to the documentation of this file.
00001 /***********************************************************************************
00002   test_algobase.cpp
00003 
00004  * Copyright (c) 1997
00005  * Mark of the Unicorn, Inc.
00006  *
00007  * Permission to use, copy, modify, distribute and sell this software
00008  * and its documentation for any purpose is hereby granted without fee,
00009  * provided that the above copyright notice appear in all copies and
00010  * that both that copyright notice and this permission notice appear
00011  * in supporting documentation.  Mark of the Unicorn makes no
00012  * representations about the suitability of this software for any
00013  * purpose.  It is provided "as is" without express or implied warranty.
00014 
00015 ***********************************************************************************/
00016 
00017 # include "Prefix.h"
00018 # if defined (EH_NEW_HEADERS)
00019 # ifdef __SUNPRO_CC
00020 # include <stdio.h>
00021 # endif
00022 #include <algorithm>
00023 # else
00024 #include <algo.h>
00025 # endif
00026 #include "Tests.h"
00027 #include "LeakCheck.h"
00028 #include "TestClass.h"
00029 
00030 // EH_USE_STD
00031 
00032 enum { kBufferSize = 100 };
00033 
00034 struct test_uninitialized_copy
00035 {
00036     test_uninitialized_copy()
00037         : stuff( new TestClass[kBufferSize] ), end_of_stuff(stuff + kBufferSize) {
00038         gTestController.SetCurrentTestName("uninitialized_copy()");
00039         }
00040 
00041     ~test_uninitialized_copy() { delete[] stuff; }
00042 
00043     void operator()( TestClass* buffer ) const
00044     {
00045         EH_STD::uninitialized_copy((TestClass*)stuff, (TestClass*)end_of_stuff, buffer );
00046         EH_ASSERT( EH_STD::equal( (TestClass*)stuff, (TestClass*)end_of_stuff, buffer ) );
00047         stl_destroy( buffer, buffer+kBufferSize );
00048     }
00049 
00050 private:
00051     TestClass * stuff;
00052     TestClass * end_of_stuff;
00053 };
00054 
00055 struct test_uninitialized_fill
00056 {
00057     test_uninitialized_fill() {
00058         gTestController.SetCurrentTestName("uninitialized_fill()");
00059     }
00060 
00061     void operator()( TestClass* buffer ) const
00062     {
00063         TestClass* buf_end = buffer + kBufferSize;
00064         EH_STD::uninitialized_fill( buffer, buf_end, testValue );
00065         for ( EH_CSTD::size_t i = 0; i < kBufferSize; i++ )
00066             EH_ASSERT( buffer[i] == testValue );
00067         stl_destroy( buffer, buf_end );
00068     }
00069 private:
00070     TestClass testValue;
00071 };
00072 
00073 struct test_uninitialized_fill_n
00074 {
00075     test_uninitialized_fill_n() {
00076         gTestController.SetCurrentTestName("uninitialized_fill_n()");
00077     }
00078     void operator()( TestClass* buffer ) const
00079     {
00080         TestClass* end = buffer + kBufferSize;
00081         EH_STD::uninitialized_fill_n( buffer, (EH_CSTD::size_t)kBufferSize, testValue );
00082         for ( EH_CSTD::size_t i = 0; i < kBufferSize; i++ )
00083             EH_ASSERT( buffer[i] == testValue );
00084         stl_destroy( buffer, end );
00085     }
00086 private:
00087     TestClass testValue;
00088 };
00089 
00090 void test_algobase()
00091 {
00092   // force alignment
00093   double arr[ sizeof(TestClass) * kBufferSize ];
00094   TestClass* c = (TestClass*)arr;
00095   WeakCheck( c, test_uninitialized_copy() );
00096   WeakCheck( c, test_uninitialized_fill() );
00097   WeakCheck( c, test_uninitialized_fill_n() );
00098 }

Generated on Fri May 25 2012 04:33:43 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.