1 static int testdarray_from_lit(void);
2 static int testdarray_append_lit(void);
3 static int testdarray_prepend_lit(void);
5 static void testLits(void) {
6 testing(darray_from_lit);
7 ok1(testdarray_from_lit());
9 testing(testdarray_append_lit);
10 ok1(testdarray_append_lit());
12 testing(testdarray_prepend_lit);
13 ok1(testdarray_prepend_lit());
16 static int testdarray_from_lit(void) {
17 darray_char a = darray_new();
18 size_t testsPassed = 0;
23 darray_from_lit(a, @str);
25 if (len != sizeof(@str)-1)
31 if (strcmp(a.item, @str))
40 return testsPassed == @amount;
48 static int testdarray_append_lit(void) {
49 darray_char a = darray_new();
50 darray(testLits_string) strings = darray_new();
52 size_t testsPassed = 0;
54 testLits_string append;
59 append.size = sizeof(@str)-1;
61 darray_append_lit(a, @str);
62 if (a.size != oldSize+append.size)
68 if (memcmp(a.item+oldSize, @str, a.size-oldSize))
70 append.item = strdup(@str);
71 darray_append(strings, append);
75 if (strings.size != @amount)
78 darray_foreach(i, strings) {
79 if (a.size-offs < i->size)
81 if (memcmp(a.item+offs, i->item, i->size))
94 darray_foreach(i, strings)
97 return testsPassed == @amount+1;
100 static int testdarray_prepend_lit(void) {
101 darray_char a = darray_new();
102 darray(testLits_string) strings = darray_new();
104 size_t testsPassed = 0;
106 testLits_string append;
111 append.size = sizeof(@str)-1;
113 darray_prepend_lit(a, @str);
114 if (a.size != oldSize+append.size)
116 if (a.size > a.alloc)
120 if (memcmp(a.item, @str, a.size-oldSize))
122 append.item = strdup(@str);
123 darray_append(strings, append);
130 if (strings.size != @amount)
132 darray_foreach(i, strings) {
136 if (memcmp(a.item+offs, i->item, i->size))
145 darray_foreach(i, strings)
147 darray_free(strings);
148 return testsPassed == @amount+1;