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 888ee76 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
|
Line | |
---|
1 | #include <stdlib> |
---|
2 | |
---|
3 | extern "C" { |
---|
4 | #include <stdio.h> |
---|
5 | } |
---|
6 | |
---|
7 | #include <containers/vector> |
---|
8 | |
---|
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 | |
---|
15 | int main(int argc, char const *argv[]) { |
---|
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)); |
---|
22 | |
---|
23 | push_back(&iv, 1); |
---|
24 | printf("%d\n", size(&iv)); |
---|
25 | assert(size(&iv) == 1); |
---|
26 | push_back(&iv, 2); |
---|
27 | printf("%d\n", size(&iv)); |
---|
28 | assert(size(&iv) == 2); |
---|
29 | push_back(&iv, 3); |
---|
30 | printf("%d\n", size(&iv)); |
---|
31 | assert(size(&iv) == 3); |
---|
32 | |
---|
33 | assert(!empty(&iv)); |
---|
34 | assert(size(&iv) == 3); |
---|
35 | assert(at(&iv, 0) == 1); |
---|
36 | assert((&iv)[0] == 1); |
---|
37 | assert(at(&iv, 1) == 2); |
---|
38 | assert((&iv)[1] == 2); |
---|
39 | assert(at(&iv, 2) == 3); |
---|
40 | assert((&iv)[2] == 3); |
---|
41 | |
---|
42 | clear(&iv); |
---|
43 | |
---|
44 | assert(empty(&iv)); |
---|
45 | assert(size(&iv) == 0); |
---|
46 | printf("%d\n", size(&iv)); |
---|
47 | |
---|
48 | return 0; |
---|
49 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.