1 /***********************************************************************************
5 * Mark of the Unicorn, Inc.
7 * Permission to use, copy, modify, distribute and sell this software
8 * and its documentation for any purpose is hereby granted without fee,
9 * provided that the above copyright notice appear in all copies and
10 * that both that copyright notice and this permission notice appear
11 * in supporting documentation. Mark of the Unicorn makes no
12 * representations about the suitability of this software for any
13 * purpose. It is provided "as is" without express or implied warranty.
15 ***********************************************************************************/
18 # if defined (EH_NEW_HEADERS)
27 #include "LeakCheck.h"
28 #include "TestClass.h"
32 enum { kBufferSize
= 100 };
34 struct test_uninitialized_copy
36 test_uninitialized_copy()
37 : stuff( new TestClass
[kBufferSize
] ), end_of_stuff(stuff
+ kBufferSize
) {
38 gTestController
.SetCurrentTestName("uninitialized_copy()");
41 ~test_uninitialized_copy() { delete[] stuff
; }
43 void operator()( TestClass
* buffer
) const
45 EH_STD::uninitialized_copy((TestClass
*)stuff
, (TestClass
*)end_of_stuff
, buffer
);
46 EH_ASSERT( EH_STD::equal( (TestClass
*)stuff
, (TestClass
*)end_of_stuff
, buffer
) );
47 stl_destroy( buffer
, buffer
+kBufferSize
);
52 TestClass
* end_of_stuff
;
55 struct test_uninitialized_fill
57 test_uninitialized_fill() {
58 gTestController
.SetCurrentTestName("uninitialized_fill()");
61 void operator()( TestClass
* buffer
) const
63 TestClass
* buf_end
= buffer
+ kBufferSize
;
64 EH_STD::uninitialized_fill( buffer
, buf_end
, testValue
);
65 for ( EH_CSTD::size_t i
= 0; i
< kBufferSize
; i
++ )
66 EH_ASSERT( buffer
[i
] == testValue
);
67 stl_destroy( buffer
, buf_end
);
73 struct test_uninitialized_fill_n
75 test_uninitialized_fill_n() {
76 gTestController
.SetCurrentTestName("uninitialized_fill_n()");
78 void operator()( TestClass
* buffer
) const
80 TestClass
* end
= buffer
+ kBufferSize
;
81 EH_STD::uninitialized_fill_n( buffer
, (EH_CSTD::size_t)kBufferSize
, testValue
);
82 for ( EH_CSTD::size_t i
= 0; i
< kBufferSize
; i
++ )
83 EH_ASSERT( buffer
[i
] == testValue
);
84 stl_destroy( buffer
, end
);
93 double arr
[ sizeof(TestClass
) * kBufferSize
];
94 TestClass
* c
= (TestClass
*)arr
;
95 WeakCheck( c
, test_uninitialized_copy() );
96 WeakCheck( c
, test_uninitialized_fill() );
97 WeakCheck( c
, test_uninitialized_fill_n() );