15 vec_ints ints = vec_ints_new_with_capacity(10);
16 const int32_t upto = 100;
18 for (int32_t i = 0; i < upto; i++) {
19 vec_ints_push(&ints, i);
21 assert(vec_ints_size(&ints) == upto);
23 for (int32_t i = 0; i < upto; i++) {
24 int* value = vec_ints_write(&ints, i);
28 for (int32_t i = 0; i < upto; i++) {
29 assert(*vec_ints_read(&ints, i) == i + 1);
33 int32_t last_value = vec_ints_pop(&ints);
34 assert(last_value == upto);
35 assert(vec_ints_size(&ints) == upto - 1);
37 vec_ints_delete(&ints);
53 vec_complex vec = vec_complex_new_with_capacity(5);
55 for (
size_t i = 0; i < entries; i++) {
56 struct complex item = {.description = strdup(
"Complex item"), .score = i * 10};
57 vec_complex_push(&vec, item);
60 assert(vec_complex_size(&vec) == entries);
62 struct complex* first_item = vec_complex_write(&vec, 0);
63 first_item->
score += 5;
65 assert(vec_complex_read(&vec, 0)->
score == 5);
67 struct complex popped = vec_complex_pop(&vec);
68 assert(popped.
score == 40);
70 vec_complex_delete(&vec);
79 char_vec vec = char_vec_new();
80 char_vec_push(&vec,
'H');
81 char_vec_push(&vec,
'e');
82 char_vec_push(&vec,
'l');
83 char_vec_push(&vec,
'l');
84 char_vec_push(&vec,
'o');
85 char_vec_push(&vec,
' ');
86 char_vec_push(&vec,
'W');
87 char_vec_push(&vec,
'o');
88 char_vec_push(&vec,
'r');
89 char_vec_push(&vec,
'l');
90 char_vec_push(&vec,
'd');
92 assert(char_vec_size(&vec) == 11);
95 char_vec_iter_const iter = char_vec_get_iter_const(&vec);
96 char const* item = NULL;
97 while (item = char_vec_iter_const_next(&iter), item != NULL) {
104 char_vec_iter_const iter = char_vec_get_iter_const(&vec);
105 ITER_LOOP(char_vec_iter_const, iter,
char const*,
foo) { printf(
"%c", *
foo); }
109 char_vec_delete(&vec);