Last change
on this file since df8ba61a was
766ec62,
checked in by Thierry Delisle <tdelisle@…>, 5 years ago
|
Really really stupid temporary fix for the build failure, will add ticket to track later
|
-
Property mode set to
100644
|
File size:
1.6 KB
|
Line | |
---|
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 | // vector.cfa -- |
---|
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 Dec 4 22:02:39 2018 |
---|
13 | // Update Count : 29 |
---|
14 | // |
---|
15 | |
---|
16 | #include <vector.hfa> |
---|
17 | #include <fstream.hfa> |
---|
18 | |
---|
19 | #undef assert |
---|
20 | #define assert(x) \ |
---|
21 | do { \ |
---|
22 | if ( !(x) ) { \ |
---|
23 | sout | "CHECK failed :" | #x | "at" | __FILE__ | " :" | __LINE__; \ |
---|
24 | abort(); \ |
---|
25 | } \ |
---|
26 | } while( 0 == 1 ) |
---|
27 | |
---|
28 | int main() { |
---|
29 | vector( int ) iv; |
---|
30 | |
---|
31 | assert( ((uintptr_t)&iv.storage.storage ) == (((uintptr_t)&iv)) ); |
---|
32 | assert( ((uintptr_t)&iv.storage.capacity) == (((uintptr_t)&iv) + sizeof(void *)) ); |
---|
33 | assert( ((uintptr_t)&iv.size ) == (((uintptr_t)&iv) + sizeof(void *) + sizeof(size_t)) ); |
---|
34 | |
---|
35 | assert( empty( &iv ) ); |
---|
36 | assert( size( &iv ) == 0 ); |
---|
37 | sout | size( &iv ); |
---|
38 | |
---|
39 | push_back( &iv, 1 ); |
---|
40 | assert( size( &iv ) == 1 ); |
---|
41 | sout | size( &iv ); |
---|
42 | |
---|
43 | push_back( &iv, 2 ); |
---|
44 | assert( size( &iv ) == 2 ); |
---|
45 | sout | size( &iv ); |
---|
46 | |
---|
47 | push_back( &iv, 3 ); |
---|
48 | assert( size( &iv ) == 3 ); |
---|
49 | sout | size( &iv ); |
---|
50 | |
---|
51 | assert( !empty( &iv ) ); |
---|
52 | assert( size( &iv ) == 3 ); |
---|
53 | assert( at( &iv, 0 ) == 1 ); |
---|
54 | assert( (&iv)[0] == 1 ); |
---|
55 | assert( at( &iv, 1 ) == 2 ); |
---|
56 | assert( (&iv)[1] == 2 ); |
---|
57 | assert( at( &iv, 2 ) == 3 ); |
---|
58 | assert( (&iv)[2] == 3 ); |
---|
59 | |
---|
60 | clear( &iv ); |
---|
61 | |
---|
62 | assert( empty( &iv ) ); |
---|
63 | assert( size( &iv ) == 0 ); |
---|
64 | sout | size( &iv ); |
---|
65 | } |
---|
66 | |
---|
67 | // Local Variables: // |
---|
68 | // tab-width: 4 // |
---|
69 | // compile-command: "cfa vector.cfa" // |
---|
70 | // End: // |
---|
Note: See
TracBrowser
for help on using the repository browser.