Loading main.cpp +23 −9 Original line number Diff line number Diff line Loading @@ -24,12 +24,11 @@ void assertFalse(bool val, std::string failureReport) { #ifdef LAB3 // add lab 3 stubs void e61(); void e610(); bool same_elements(int a[], int b[], int size); void e610(); bool same_elements(int a[], int b[], int size); void p66(); void e74(); void e74(); double* maximum(double* a, int size); void e715(); void e79(); void e79(); //char* replace_all(const char s[], const char t[], const char u[]); #endif // TESTS Loading @@ -38,20 +37,35 @@ void testE610() { int a[]={1,4,9,16,9,7,4,9,11}; int b[]={11,1,4,9,16,9,7,4,9}; int c[]={11,11,7,9,16,4,1,4,9}; int d[]={}; assertTrue(same_elements(a,b, 9), "Failed first book test - 1 4 9 16 9 7 4 9 11 should be the same as 1 4 9 16 9 7 4 9 11."); assertFalse(same_elements(a,c, 9), "Failed first book test - 1 4 9 16 9 7 4 9 11 should NOT be the same as 11 11 7 9 16 4 1 4 9."); assertTrue( same_elements(d,d,0), "same_elements on two empty lists should return true"); } void testE74() { double nullList[]={}; double simpleList[]={1,2,3,4,5}; double complexList[]={-1.0, 2.3, -4.3, -2.3, 4.3, 3.2}; assertTrue(maximum((double *){},0) == nullptr,"maximum of empty list should return nullptr"); assertTrue(*maximum(simpleList ,5) == 5,"maximum of {1,2,3,4,5} should return 5"); assertTrue(*maximum(complexList ,6) == 4.3,"maximum of {-1.0, 2.3, -4.3, -2.3, 4.3, 3.2} should return 4.3"); } void testE79() { // to do } // MAIN int main() { #ifdef LAB3 // lab 3 tests e61(); testE610(); e61(); testE610(); p66(); e74(); e74(); testE74(); e715(); e79(); e79(); testE79(); #endif } No newline at end of file Loading
main.cpp +23 −9 Original line number Diff line number Diff line Loading @@ -24,12 +24,11 @@ void assertFalse(bool val, std::string failureReport) { #ifdef LAB3 // add lab 3 stubs void e61(); void e610(); bool same_elements(int a[], int b[], int size); void e610(); bool same_elements(int a[], int b[], int size); void p66(); void e74(); void e74(); double* maximum(double* a, int size); void e715(); void e79(); void e79(); //char* replace_all(const char s[], const char t[], const char u[]); #endif // TESTS Loading @@ -38,20 +37,35 @@ void testE610() { int a[]={1,4,9,16,9,7,4,9,11}; int b[]={11,1,4,9,16,9,7,4,9}; int c[]={11,11,7,9,16,4,1,4,9}; int d[]={}; assertTrue(same_elements(a,b, 9), "Failed first book test - 1 4 9 16 9 7 4 9 11 should be the same as 1 4 9 16 9 7 4 9 11."); assertFalse(same_elements(a,c, 9), "Failed first book test - 1 4 9 16 9 7 4 9 11 should NOT be the same as 11 11 7 9 16 4 1 4 9."); assertTrue( same_elements(d,d,0), "same_elements on two empty lists should return true"); } void testE74() { double nullList[]={}; double simpleList[]={1,2,3,4,5}; double complexList[]={-1.0, 2.3, -4.3, -2.3, 4.3, 3.2}; assertTrue(maximum((double *){},0) == nullptr,"maximum of empty list should return nullptr"); assertTrue(*maximum(simpleList ,5) == 5,"maximum of {1,2,3,4,5} should return 5"); assertTrue(*maximum(complexList ,6) == 4.3,"maximum of {-1.0, 2.3, -4.3, -2.3, 4.3, 3.2} should return 4.3"); } void testE79() { // to do } // MAIN int main() { #ifdef LAB3 // lab 3 tests e61(); testE610(); e61(); testE610(); p66(); e74(); e74(); testE74(); e715(); e79(); e79(); testE79(); #endif } No newline at end of file