+ array_push(arr, lotsOfNumbers[i]);
+ ok1(arr.size == countof(lotsOfNumbers));
+ ok1(arr.alloc >= arr.size);
+ ok1(!memcmp(arr.item, lotsOfNumbers, sizeof(lotsOfNumbers)));
+ }
+ reset(arr);
+
+ testing(array_prepend, array_pop_nocheck);
+ {
+ for (i=countof(lotsOfNumbers); i;)
+ array_prepend(arr, lotsOfNumbers[--i]);
+ ok1(arr.size == countof(lotsOfNumbers));
+ ok1(arr.alloc >= arr.size);
+ ok1(!memcmp(arr.item, lotsOfNumbers, sizeof(lotsOfNumbers)));
+
+ for (i=countof(lotsOfNumbers); i;) {
+ if (array_pop_nocheck(arr) != (long)lotsOfNumbers[--i]) {
+ i++;
+ break;
+ }
+ }
+ ok1(i==0);
+ ok1(arr.size == 0);
+ }
+ reset(arr);
+
+ testing(array_from_c, array_for, array_rof);
+ {
+ size_t i_correct, r_correct;
+
+ array_from_c(arr, lotsOfNumbers);
+ ok1(arr.size == countof(lotsOfNumbers));
+ ok1(arr.alloc >= arr.size);
+ ok1(!memcmp(arr.item, lotsOfNumbers, sizeof(lotsOfNumbers)));
+
+ i_correct = 0;
+ r_correct = countof(lotsOfNumbers)-1;
+ array_for(i, arr,
+ if (i_correct != _i)
+ break;
+ if (r_correct != _r)
+ break;
+ if (i != arr.item+_i)
+ break;
+ if (*i != (long)lotsOfNumbers[_i])
+ break;
+ i_correct++;
+ r_correct--;
+ );
+ ok1(i_correct == countof(lotsOfNumbers));
+
+ i_correct = countof(lotsOfNumbers)-1;
+ r_correct = 0;
+ array_rof(i, arr,
+ if (i_correct != _i)
+ break;
+ if (r_correct != _r)
+ break;
+ if (i != arr.item+_i)
+ break;
+ if (*i != (long)lotsOfNumbers[_i])
+ break;
+ i_correct--;
+ r_correct++;
+ );
+ ok1(r_correct == countof(lotsOfNumbers));
+ }
+ reset(arr);
+
+ testing(array_append_string);
+ {
+ for (i=0; i<countof(lotsOfStrings); i++)
+ array_append_string(str, lotsOfStrings[i]);
+ ok1(str.size == amalgams.stringsSize);
+ ok1(str.alloc > str.size);
+ ok1(str.item[str.size] == 0);
+ ok1(!strcmp(str.item, amalgams.stringsF));
+ }
+ reset(str);
+
+ testing(array_prepend_string);
+ {
+ for (i=0; i<countof(lotsOfStrings); i++)
+ array_prepend_string(str, lotsOfStrings[i]);
+ ok1(str.size == amalgams.stringsSize);
+ ok1(str.alloc > str.size);
+ ok1(str.item[str.size] == 0);
+ ok1(!strcmp(str.item, amalgams.stringsB));
+ }
+ reset(str);
+
+ testing(array_from_string);
+ {
+ for (i=0; i<countof(lotsOfStrings); i++) {
+ array_from_string(str, lotsOfStrings[i]);
+ if (str.size != strlen(lotsOfStrings[i]))
+ break;
+ if (str.alloc < strlen(lotsOfStrings[i])+1)
+ break;
+ if (strcmp(str.item, lotsOfStrings[i]))
+ break;
+ }
+ ok1(i == countof(lotsOfStrings));
+ }
+ reset(str);
+
+ testing(array_resize0);
+ {
+ size_t prevSize=0, size;
+ for (i=0; i<countof(lotsOfNumbers); i++, prevSize=size) {
+ size = lotsOfNumbers[i] & 0xFFFF;
+ array_resize0(arr, size);
+ if (arr.size != size)
+ break;
+ if (arr.alloc < size)
+ break;
+ if (size>prevSize) {
+ if (!isZeros(arr.item+prevSize, (size-prevSize)*sizeof(*arr.item)))
+ break;
+ }
+ //fill the array with lotsOfNumbers garbage
+ memtile(arr.item, arr.size*sizeof(*arr.item), lotsOfNumbers, sizeof(lotsOfNumbers));
+ }
+ ok1(i==countof(lotsOfNumbers));
+ }
+ reset(arr);
+
+ testing(array_realloc);
+ {
+ size_t s,a;
+ for (i=0; i<countof(lotsOfNumbers); i++) {
+ arr.size = (s = lotsOfNumbers[i] >> 16);
+ //give size a nonsense value to make sure array_realloc doesn't care about it
+ a = amalgams.stringsSize/sizeof(*arr.item)+2;
+ array_realloc(arr, a = lotsOfNumbers[i] % ((amalgams.stringsSize/sizeof(*arr.item))+1));
+ if (a*sizeof(*arr.item) > amalgams.stringsSize)
+ break;
+ if (arr.alloc != a)
+ break;
+ if (arr.size != s)
+ break;
+ memtile(arr.item, a*sizeof(*arr.item), amalgams.stringsF, a*sizeof(*arr.item));
+ if (memcmp(arr.item, amalgams.stringsF, a*sizeof(*arr.item)))
+ break;
+ }
+ ok1(i==countof(lotsOfNumbers));