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 30e81fb was
888ee76,
checked in by Thierry Delisle <tdelisle@…>, 8 years ago
|
fixed the tests for lib vector
|
-
Property mode set to
100644
|
File size:
907 bytes
|
Rev | Line | |
---|
[ea29e73] | 1 | #include <stdlib> |
---|
| 2 | |
---|
[ed3f3bf4] | 3 | extern "C" { |
---|
| 4 | #include <stdio.h> |
---|
| 5 | } |
---|
| 6 | |
---|
[ea29e73] | 7 | #include <containers/vector> |
---|
| 8 | |
---|
[ed3f3bf4] | 9 | #define assert(x) do {\ |
---|
| 10 | if(!(x)) {\ |
---|
| 11 | printf("CHECK failed : %s at %s:%i\n", #x, __FILE__, __LINE__);\ |
---|
| 12 | abort();\ |
---|
| 13 | }}while(0 == 1)\ |
---|
| 14 | |
---|
[ea29e73] | 15 | int main(int argc, char const *argv[]) { |
---|
[ed3f3bf4] | 16 | vector(int, heap_allocator(int)) iv; |
---|
| 17 | ctor(&iv); |
---|
| 18 | |
---|
| 19 | assert(empty(&iv)); |
---|
| 20 | assert(size(&iv) == 0); |
---|
| 21 | printf("%d\n", size(&iv)); |
---|
[ea29e73] | 22 | |
---|
| 23 | push_back(&iv, 1); |
---|
[ed3f3bf4] | 24 | printf("%d\n", size(&iv)); |
---|
| 25 | assert(size(&iv) == 1); |
---|
[ea29e73] | 26 | push_back(&iv, 2); |
---|
[ed3f3bf4] | 27 | printf("%d\n", size(&iv)); |
---|
| 28 | assert(size(&iv) == 2); |
---|
[ea29e73] | 29 | push_back(&iv, 3); |
---|
[ed3f3bf4] | 30 | printf("%d\n", size(&iv)); |
---|
| 31 | assert(size(&iv) == 3); |
---|
[ea29e73] | 32 | |
---|
| 33 | assert(!empty(&iv)); |
---|
| 34 | assert(size(&iv) == 3); |
---|
| 35 | assert(at(&iv, 0) == 1); |
---|
[ed3f3bf4] | 36 | assert((&iv)[0] == 1); |
---|
[ea29e73] | 37 | assert(at(&iv, 1) == 2); |
---|
[ed3f3bf4] | 38 | assert((&iv)[1] == 2); |
---|
[ea29e73] | 39 | assert(at(&iv, 2) == 3); |
---|
[ed3f3bf4] | 40 | assert((&iv)[2] == 3); |
---|
[ea29e73] | 41 | |
---|
| 42 | clear(&iv); |
---|
| 43 | |
---|
| 44 | assert(empty(&iv)); |
---|
| 45 | assert(size(&iv) == 0); |
---|
[888ee76] | 46 | printf("%d\n", size(&iv)); |
---|
[ea29e73] | 47 | |
---|
| 48 | return 0; |
---|
| 49 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.