Skip to content

Commit

Permalink
Add more tests for allocating chunks.
Browse files Browse the repository at this point in the history
  • Loading branch information
bacek committed Nov 16, 2010
1 parent 77b71f1 commit 5f23c8e
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions t/src/pointer_array.t
Expand Up @@ -38,7 +38,7 @@ int main(int argc, char* argv[])
{
Interp *interp = Parrot_new(NULL);
Parrot_Pointer_Array *pa = Parrot_pa_new(interp);
int i, j;
int i, count;
void *pi, *pj;
if (!pa) {
Expand All @@ -51,20 +51,42 @@ int main(int argc, char* argv[])
/* Push first pointer */
pi = Parrot_pa_insert(interp, pa, &i);
if (!pa->total_chunks == 1) {
if (pa->total_chunks != 1) {
printf("Fail to allocate 1 chunk");
return EXIT_FAILURE;
}
printf("ok 2\n");
if (pa->current_chunk != 0) {
printf("current_chunk is wrong");
return EXIT_FAILURE;
}
printf("ok 3\n");
/* Insert many pointers */
for (count = CELL_PER_CHUNK * 2; count; count--) {
pi = Parrot_pa_insert(interp, pa, &i);
}
if (pa->total_chunks < 2) {
printf("Fail to allocate more chunks");
return EXIT_FAILURE;
}
printf("ok 4\n");
if (pa->current_chunk != pa->total_chunks - 1) {
printf("current_chunk is wrong");
return EXIT_FAILURE;
}
printf("ok 5\n");
return EXIT_SUCCESS;
}
CODE
ok 1
ok 2
ok 3
ok 4
ok 5
OUTPUT

# Local Variables:
Expand Down

0 comments on commit 5f23c8e

Please sign in to comment.