ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsctordeferred_resndemanglerenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxmemorynew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumresolv-newwith_gc
Last change
on this file since 82da9b8 was
00b7cd3,
checked in by Peter A. Buhr <pabuhr@…>, 8 years ago
|
update include files for test programs
|
-
Property mode set to
100644
|
File size:
1.5 KB
|
Rev | Line | |
---|
[00b7cd3] | 1 | // |
---|
| 2 | // Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo |
---|
| 3 | // |
---|
| 4 | // The contents of this file are covered under the licence agreement in the |
---|
| 5 | // file "LICENCE" distributed with Cforall. |
---|
| 6 | // |
---|
| 7 | // libcfa_vector.c -- |
---|
| 8 | // |
---|
| 9 | // Author : Thierry Delisle |
---|
| 10 | // Created On : Mon Jul 4 23:36:19 2016 |
---|
| 11 | // Last Modified By : Peter A. Buhr |
---|
| 12 | // Last Modified On : Tue Jul 5 15:08:05 2016 |
---|
| 13 | // Update Count : 26 |
---|
| 14 | // |
---|
[ea29e73] | 15 | |
---|
[00b7cd3] | 16 | #include <fstream> |
---|
| 17 | #include <vector> |
---|
| 18 | |
---|
| 19 | #undef assert |
---|
| 20 | #define assert(x) \ |
---|
| 21 | do { \ |
---|
| 22 | if ( !(x) ) { \ |
---|
| 23 | sout | "CHECK failed :" | #x | "at" | __FILE__ | " :" | __LINE__ | endl; \ |
---|
| 24 | abort(); \ |
---|
| 25 | } \ |
---|
| 26 | } while( 0 == 1 ) |
---|
| 27 | |
---|
| 28 | int main() { |
---|
| 29 | vector( int, heap_allocator(int) ) iv; |
---|
| 30 | ctor( &iv ); |
---|
| 31 | |
---|
| 32 | assert( empty( &iv ) ); |
---|
| 33 | assert( size( &iv ) == 0 ); |
---|
| 34 | sout | size( &iv ) | endl; |
---|
| 35 | |
---|
| 36 | push_back( &iv, 1 ); |
---|
| 37 | assert( size( &iv ) == 1 ); |
---|
| 38 | sout | size( &iv ) | endl; |
---|
[ed3f3bf4] | 39 | |
---|
[00b7cd3] | 40 | push_back( &iv, 2 ); |
---|
| 41 | assert( size( &iv ) == 2 ); |
---|
| 42 | sout | size( &iv ) | endl; |
---|
| 43 | |
---|
| 44 | push_back( &iv, 3 ); |
---|
| 45 | assert( size( &iv ) == 3 ); |
---|
| 46 | sout | size( &iv ) | endl; |
---|
| 47 | |
---|
| 48 | assert( !empty( &iv ) ); |
---|
| 49 | assert( size( &iv ) == 3 ); |
---|
| 50 | assert( at( &iv, 0 ) == 1 ); |
---|
| 51 | assert( (&iv)[0] == 1 ); |
---|
| 52 | assert( at( &iv, 1 ) == 2 ); |
---|
| 53 | assert( (&iv)[1] == 2 ); |
---|
| 54 | assert( at( &iv, 2 ) == 3 ); |
---|
| 55 | assert( (&iv)[2] == 3 ); |
---|
| 56 | |
---|
| 57 | clear( &iv ); |
---|
| 58 | |
---|
| 59 | assert( empty( &iv ) ); |
---|
| 60 | assert( size( &iv ) == 0 ); |
---|
| 61 | sout | size( &iv ) | endl; |
---|
[ea29e73] | 62 | } |
---|
[00b7cd3] | 63 | |
---|
| 64 | // Local Variables: // |
---|
| 65 | // tab-width: 4 // |
---|
| 66 | // compile-command: "cfa libcfa_vector.c" // |
---|
| 67 | // End: // |
---|
Note: See
TracBrowser
for help on using the repository browser.