mirror of
https://bitbucket.org/Mattrixwv/myhelpers.git
synced 2025-12-06 18:43:59 -05:00
Added copy and compare functions
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
//myHelper/DynamicInt64Array.h
|
||||
//Matthew Ellison
|
||||
// Created: 03-08-19
|
||||
//Modified: 03-09-19
|
||||
//Modified: 03-10-19
|
||||
//This is the test for my dynamic array in c
|
||||
/*
|
||||
Copyright (C) 2019 Matthew Ellison
|
||||
@@ -178,8 +178,42 @@ int main(){
|
||||
return 1;
|
||||
}
|
||||
|
||||
//Test copy function
|
||||
struct DynamicInt64Array testAry2;
|
||||
initDynamicInt64Array(&testAry2);
|
||||
copyDynamicInt64Array(&testAry, &testAry2);
|
||||
if((testAry.ptr[0] == testAry2.ptr[0]) && (testAry.ptr[1] == testAry2.ptr[1]) && (testAry.ptr[2] == testAry2.ptr[2]) && (testAry.ptr[3] == testAry2.ptr[3]) && (testAry.ptr[4] == testAry2.ptr[4]) && (testAry.ptr[5] == testAry2.ptr[5])){
|
||||
printf("copy is working correctly\n");
|
||||
}
|
||||
else{
|
||||
printf("There is something wrong with copy\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
//Test compare function
|
||||
//Test equals
|
||||
if(compareDynamicInt64Array(&testAry, &testAry2) != 0){
|
||||
printf("There is a problem with compare equals\n");
|
||||
return 1;
|
||||
}
|
||||
//Test lessThan
|
||||
pushBackDynamicInt64Array(&testAry2, 7);
|
||||
if(compareDynamicInt64Array(&testAry, &testAry2) != -1){
|
||||
printf("There is a problem with compare less than\n");
|
||||
return 1;
|
||||
}
|
||||
//Test greaterThan
|
||||
if(compareDynamicInt64Array(&testAry2, &testAry) != 1){
|
||||
printf("There is a problem with compare greater than\n");
|
||||
return 1;
|
||||
}
|
||||
else{
|
||||
printf("compare is working correctly\n");
|
||||
}
|
||||
|
||||
//Release all of the memory allocated by the array
|
||||
destroyDynamicInt64Array(&testAry);
|
||||
destroyDynamicInt64Array(&testAry2);
|
||||
|
||||
printf("\n\nEND OF TESTS\n");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user