Answered step by step
Verified Expert Solution
Question
1 Approved Answer
I need simple code to test out the units in C. 10 11 int testAddingRoot) 12 13 14 15 16 17 18 19 int succeedfalse;
I need simple code to test out the units in C.
10 11 int testAddingRoot) 12 13 14 15 16 17 18 19 int succeedfalse; // Create our Tree Root struct Node * rootmakeNode (5); if ( (root->value = 5) && (root->left = NULL) && (root-> right = NULL)){ succeed = true; free(root); 21 if (succeedfalse) printf("Adding to Root Test Failed! ") 23 25 return succeed; 27 28 int testAddingToLeftofRoot(O 29 30 31 32 int succeed = false; // Create our Tree Root struct Node * rootmakeNode (5); addValue (root,4) if (root->left != NULL){ if ( (root->left->value 4) && (root->left->parent root )) { # 35 return true; 37 free(root->left); root->left = NULL; free(root); 40 41 42 43 if (succeedfalse) printf("Adding to Left of Root Test Failed! "); 45 46 47 48 return succeed; 50 int testRemovingLeaf) 51 52 53 54 int succeed = false; struct Node * root = makeNode(5); addValue (root,4) if (root->left != NULL){ 56 57 58 59 60 61 62 63 64 65 removeValue (root,4); if (root->left = NULL){ succeed = true; free(root); if (succeed-false){ printf("Removing Leaf Test Failed! "); 67 68 69 70 return succeed; 72 11- 73 1I 74 75 int main) 76 MAIN CODE int numTestCorrect 0; int totalTests0; 78 79 80 81 82 83 84 85 86 87 /Test Printing the tree // Test code goes here.... // Test Adding to the tree numTestCorrect = numTestCorrect + testAddingRoot(); totalTests++ numTestCorrect = numTestCorrect + testAddingToLeftOfRoot(); totalTests++ // More Test code goes here.... //Test Removing from the tree nunTestcorrect = numTestcorrect + testRemovingLeaf ( ); totalTests++ // More Test code goes here.... //Test Deleting the tree // Test code goes here.... //Test isLeaf // Test code goes here.... printf("%d/%d successful tests. ", numTestCorrect, totalTests); return0; 10 11 int testAddingRoot) 12 13 14 15 16 17 18 19 int succeedfalse; // Create our Tree Root struct Node * rootmakeNode (5); if ( (root->value = 5) && (root->left = NULL) && (root-> right = NULL)){ succeed = true; free(root); 21 if (succeedfalse) printf("Adding to Root Test Failed! ") 23 25 return succeed; 27 28 int testAddingToLeftofRoot(O 29 30 31 32 int succeed = false; // Create our Tree Root struct Node * rootmakeNode (5); addValue (root,4) if (root->left != NULL){ if ( (root->left->value 4) && (root->left->parent root )) { # 35 return true; 37 free(root->left); root->left = NULL; free(root); 40 41 42 43 if (succeedfalse) printf("Adding to Left of Root Test Failed! "); 45 46 47 48 return succeed; 50 int testRemovingLeaf) 51 52 53 54 int succeed = false; struct Node * root = makeNode(5); addValue (root,4) if (root->left != NULL){ 56 57 58 59 60 61 62 63 64 65 removeValue (root,4); if (root->left = NULL){ succeed = true; free(root); if (succeed-false){ printf("Removing Leaf Test Failed! "); 67 68 69 70 return succeed; 72 11- 73 1I 74 75 int main) 76 MAIN CODE int numTestCorrect 0; int totalTests0; 78 79 80 81 82 83 84 85 86 87 /Test Printing the tree // Test code goes here.... // Test Adding to the tree numTestCorrect = numTestCorrect + testAddingRoot(); totalTests++ numTestCorrect = numTestCorrect + testAddingToLeftOfRoot(); totalTests++ // More Test code goes here.... //Test Removing from the tree nunTestcorrect = numTestcorrect + testRemovingLeaf ( ); totalTests++ // More Test code goes here.... //Test Deleting the tree // Test code goes here.... //Test isLeaf // Test code goes here.... printf("%d/%d successful tests. ", numTestCorrect, totalTests); return0
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access with AI-Powered Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started