Skip to content

Commit

Permalink
testing at uint64_max impractical
Browse files Browse the repository at this point in the history
  • Loading branch information
prathameshd30 committed Jul 12, 2024
1 parent 00e2cc3 commit 3a48e13
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 17 deletions.
2 changes: 1 addition & 1 deletion include/data_structures/vector/vector.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ NAME* new_##NAME(uint64_t size){ /*Size is set only after allocation of vector->
}\
if(size == 0){\
new_obj->data = NULL;\
new_obj->size = 0 ;\
new_obj->size = 0;\
return new_obj;\
}\
new_obj->data = calloc(size,sizeof(TYPE));\
Expand Down
40 changes: 24 additions & 16 deletions tests/data_structures/vector/vector_primitive_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,21 +66,25 @@ int main(void){
return -1;
}

// Test at uint64_t max
iv = new_intVec(UINT64_MAX);
if(iv->size!=UINT64_MAX){
puts("Incorrect vector size set at UINT64_MAX");
return -1;
}
if(iv->data==NULL){
puts("Vector data is NULL at size UINT64_MAX");
return -1;
}
delete_intVec(&iv,NULL);
if(iv!=NULL){
puts("Vector is not null after being freed at UINT64_MAX");
return -1;
}
// Test at uint64_t max (IMPRACTICAL, Roughly 73700 Petabytes of RAM needed)
// iv = new_intVec(UINT64_MAX);
// if(!iv){
// puts("Vector not created cleanly at size UINT64_MAX");
// return -1;
// }
// if(iv->size!=UINT64_MAX){
// puts("Incorrect vector size set at UINT64_MAX");
// return -1;
// }
// if(iv->data==NULL){
// puts("Vector data is NULL at size UINT64_MAX");
// return -1;
// }
// delete_intVec(&iv,NULL);
// if(iv!=NULL){
// puts("Vector is not null after being freed at UINT64_MAX");
// return -1;
// }

/* Negative size testing is not possible as parameter passed to the constructor
is in itself an unsigned quantity. Hence, a negative number would just be
Expand All @@ -102,7 +106,11 @@ int main(void){
}
print_intVec(iv,print_int);
putchar('\n');

delete_intVec(&iv, NULL);
if(iv!=NULL){
puts("Deleted vector not NULL");
return -1;
}
// Construction from array tested


Expand Down

0 comments on commit 3a48e13

Please sign in to comment.