@@ -247,6 +247,7 @@ int main(int argc, char *argv[]) {
247247#endif
248248 int test_case = atoi (argv [1 ]);
249249 int test_index = atoi (argv [2 ]); //e.q. ./test 2 3
250+ int test_orig = atoi (argv [3 ]);
250251 bool compare = true;
251252
252253 double input5 [TEST_SIZE ][4 ] = {
@@ -422,60 +423,80 @@ int main(int argc, char *argv[]) {
422423
423424 case 6 : ;
424425 struct Node * root = NULL ;
426+ int * actual_output6 = NULL ;
425427
426- for (int i = 0 ; i < 11 ; i ++ ) {
427- root = Insert (root , input6_1 [test_index ][i ]);
428- }
428+ if (test_orig == 0 ) {
429+ for (int i = 0 ; i < 11 ; i ++ ) {
430+ root = Insert (root , input6_1 [test_index ][i ]);
431+ }
429432
430433
431- for (int i = 0 ; i < 3 ; i ++ ) {
432- root = Delete (root , input6_2 [test_index ][i ]);
433- }
434+ for (int i = 0 ; i < 3 ; i ++ ) {
435+ root = Delete (root , input6_2 [test_index ][i ]);
436+ }
434437// root = arrDelete(root, input6_2[test_index][0]
435438// , input6_2[test_index][1]
436439// , input6_2[test_index][2]);
437440
438- int * actual_output6 = getInorder (root );
441+ actual_output6 = getInorder (root );
442+ }
443+ else {
444+ root = NULL ;
445+ root = arrInsertDelete (root , input6_1 [test_index ][0 ]
446+ , input6_1 [test_index ][1 ]
447+ , input6_1 [test_index ][2 ]
448+ , input6_1 [test_index ][3 ]
449+ , input6_1 [test_index ][4 ]
450+ , input6_1 [test_index ][5 ]
451+ , input6_1 [test_index ][6 ]
452+ , input6_1 [test_index ][7 ]
453+ , input6_1 [test_index ][8 ]
454+ , input6_1 [test_index ][9 ]
455+ , input6_1 [test_index ][10 ]
456+ );
457+
458+ actual_output6 = getInorder (root );
459+ }
460+
439461
440- root = NULL ;
441- root = arrInsertDelete (root , input6_1 [test_index ][0 ]
442- , input6_1 [test_index ][1 ]
443- , input6_1 [test_index ][2 ]
444- , input6_1 [test_index ][3 ]
445- , input6_1 [test_index ][4 ]
446- , input6_1 [test_index ][5 ]
447- , input6_1 [test_index ][6 ]
448- , input6_1 [test_index ][7 ]
449- , input6_1 [test_index ][8 ]
450- , input6_1 [test_index ][9 ]
451- , input6_1 [test_index ][10 ]
452- );
453462
454- int * actual_output6_2 = getInorder (root );
455463
456464 for (int i = 0 ; i < 11 ; i ++ ) {
457465 printf ("%d, " , actual_output6 [i ]);
458466 }
459467 int i = 0 ;
460468 compare = true;
461- for (int i = 0 ; i < 11 ; i ++ ) {
462- printf ("Actual: %d Expected: %d\n" , actual_output6 [i ], expected_output6_orig [test_index ][i ]);
463- if (actual_output6 [i ] != expected_output6_orig [test_index ][i ]) {
464-
465- compare = false;
466- break ;
469+ if (test_orig == 0 ) {
470+ for (int i = 0 ; i < 11 ; i ++ ) {
471+ printf ("Actual: %d Expected: %d\n" , actual_output6 [i ], expected_output6_orig [test_index ][i ]);
472+ if (actual_output6 [i ] != expected_output6_orig [test_index ][i ]) {
473+
474+ compare = false;
475+ break ;
476+ }
467477 }
468478 }
479+ else {
480+ for (int i = 0 ; i < 11 ; i ++ ) {
481+ printf ("Actual: %d Expected: %d\n" , actual_output6 [i ], expected_output6 [test_index ][i ]);
482+ if (actual_output6 [i ] != expected_output6 [test_index ][i ]) {
469483
470- for (int i = 0 ; i < 11 ; i ++ ) {
471- printf ("Actual: %d Expected: %d\n" , actual_output6_2 [i ], expected_output6 [test_index ][i ]);
472- if (actual_output6_2 [i ] != expected_output6 [test_index ][i ]) {
473-
474- // compare = false;
475- break ;
484+ compare = false;
485+ break ;
486+ }
476487 }
477488 }
478489
490+
491+ // for (int i = 0; i < 11; i++) {
492+ // printf("Actual: %d Expected: %d\n", actual_output6_2[i], expected_output6[test_index][i]);
493+ // if (actual_output6_2[i] != expected_output6[test_index][i]) {
494+ //
495+ //// compare = false;
496+ // break;
497+ // }
498+ // }
499+
479500 if (compare ) {
480501 printf ("PASSED\n" );
481502 }
0 commit comments