update README
[cvector.git] / src / test / test.c
bloba2c334854877f0c584589d969264f6b34c964ee4
1 #include "test/vectors.h"
3 #include <stdint.h>
4 #include <stdbool.h>
5 #include <stdio.h>
6 #include <assert.h>
7 #include "macros.h"
9 #define ARRAY_SIZE(array) (sizeof(array) / sizeof(array[0]))
10 enum {
11 NB = SIZE_C(10),
14 char sentence[] = "bonjour";
16 bool equalChar(const char c1, const char c2) {
17 return c1 == c2;
20 int main() {
21 char sentence2[ARRAY_SIZE(sentence) + 2U];
22 stringvec vec = stringvec_create(NB);
23 uint32_t i = 0U;
24 charvec string, stringCopy;
25 for (; i<NB; i++) {
26 sprintf(sentence2, "%s%02u", sentence, i);
27 string = charvec_create(ARRAY_SIZE(sentence2) - 1U - 1U);
28 charvec_push_array(&string, sentence2, ARRAY_SIZE(sentence2)-1U);
29 stringvec_push(&vec, string);
32 i = 0U;
33 for (; i<NB; i++) {
34 charvec_print(string = stringvec_get(vec, i), "%c", "");
35 printf(":%zu ", string.size);
36 stringCopy = charvec_copy(string);
37 charvec_print(stringCopy, "%c", "");
38 printf(":%zu\n", string.size);
39 assert(charvec_eqv(string, stringCopy, equalChar));
40 charvec_free(&stringCopy);