fix bugs in new stretchy buffer code, add stretchy buffer tests

This commit is contained in:
Sean Barrett
2014-06-01 08:01:01 -07:00
parent 728d435591
commit a57dfc50fc
9 changed files with 168 additions and 13 deletions

24
tests/stretch_test.c Normal file
View File

@ -0,0 +1,24 @@
#include "stretchy_buffer.h"
#include <assert.h>
int main(int arg, char **argv)
{
int i;
int *arr = NULL;
for (i=0; i < 1000000; ++i)
sb_push(arr, i);
assert(sb_count(arr) == 1000000);
for (i=0; i < 1000000; ++i)
assert(arr[i] == i);
sb_free(arr);
arr = NULL;
for (i=0; i < 1000; ++i)
sb_add(arr, 1000);
assert(sb_count(arr) == 1000000);
return 0;
}