Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

sorry if this is excessive but idk how to figure out the test case for every single thing. i have included both the codes for

sorry if this is excessive but idk how to figure out the test case for every single thing. i have included both the codes for the two programs as well. Thanks in advance :)
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
i have also included the the original instructions for the both the programs and the full instructions. lmk if you might need any other information image text in transcribed
image text in transcribed
image text in transcribed
i am just suppsed to list test cases in this question
- Our challenge: - List all the test cases you would need in order to completely test - Your program verticalgraph.c (Task 9 of Lab 2) and - Your function In Rectangle.c (Task 10 of Lab 2) "completely" means that all statements in your function/program have been exercised (executed), hence tested by the test cases! - You will need 2 lists of test cases: - 1 list of test cases to test verticalgraph.c and -1 list of test cases to test InRectangle.c - Our challenge (cont'd): - Requirement: Your lists cannot contain 2 test cases that test exactly the same statements in your function/program - This is to say that each list of test cases must be composed of distinct test cases Our challenge (cont'd): - Here is an example of what we mean by distinct test cases: If you were to test your function scrambled.c (Lab 2 Task 4), you could use the following test cases: -Test Case A Input data: arr1= {2,1,3,4,5}, arr2 = {1,2,4,3,5} - Expected result: 1 Test Case B Input data: arr1= {7,6,8,9,10}, arr2 = {6,7,9,8,10} - Expected result : 1 - Our challenge (cont'd): But you would not be able to put both of these test cases in your list of test cases for scrambled.c because both are testing the same statements in your function, i.e., the statements that confirm arri is indeed a scrambled version of arr2 -So, you would have to come up with another test case such as: - Test Case C - Input data: arr1={6,8,9,10}, arr2 = {7,9,8,10} - Expected result: 0 Create a document in which you first copy the content of your verticalgraph.c function then you put your list of test cases for this function following this format: Lab 2 - Task 9 Test case 1 - input data: blah, expected result: blah Test case x - input data: blah, expected result: blah - Then copy the content of your In Rectangle.c function then put your list of test cases for this function following the same format: Lab 2 - Task 10 Test case 1 - input data: blah, expected result: blah Test case y - input data: blah, expected result: blah X inrect.c 1 #include 2 #include 4 int InRectangle( float pt [2], float rect [4] { 6 if(pt[0] >= rect[0] && pt [0] = rect[1] && pt [1] #include #include co vou WN #define MAX_LENGTH 80 char *userinput(FILE* fp, size_t size) { char *str; int ch; size_t len = 0; str = realloc(NULL, sizeof(char)*size); if(!str)return str; while(EOF!=(ch=fgetc(fp))){ str[len++]='\0'; if(len==size) { str = realloc(str, sizeof(char) *(size+=16)); if(!str)return str; 16 18 20 str[len++]=''; return realloc(str, sizeof(char) *len); 21 22 23 24 25 int main(void) { char *usrStr; char* token; int k=0,1-0, num[MAX_LENGTH] = {0,1,j=0, column=0, row=0, largest=0, l=0; printf("Enter the input string : "); usrStr = userInputStream(stdin, 10); 28 29 30 31 for(i=0; i0; --j) { 1=0; for(k=0; k= j) { printf("#"); } else { printf(" "); 1++; 59 60 61 printf(" "); 62 63 64 free(usrStr); return 0; 65 9. Vertical graph In Lab 1 we plotted a histogram horizontally. In order to plota histogram vertically, we need to have finished reading all the input before we start drawing the graph on the output. An array is suitable for this. A standard terminal window is 80 character-columns across. If we limit the number of columns we can graph to a maximum of 80, we know how large an array we need to allocate and this program is simple to write. Requirements 1. Read integer values from stdin, separated by one or more spaces or newlines, until reaching EOF. 2. The input is guaranteed to be well-formed. (Hum... what does this mean?) 3. The input contains no more than 80 values. 4. On standard output, render a simple vertical column graph representation of the input values, in order left to right, using hash '#' characters as shown in the examples below. The number of hashes printed in each column should be equal to the corresponding input value. 5. The area above a completed column should be filled with space characters. 6. Ignore empty lines. Do not output a column for an empty line. 7. The entire graph must end with a newline character. Guide Hint: you may find it helpful to draw your graphs upside down (increasing down the screen) first, then change your code to flip the output it up the right way. Examples 1. Input: 1131 Output: The requirements mean that the graph fills a rectangular area with hashes and spaces, so this example is printed as: In particular, notice the spaces before the newlines on the first two lines. They are necessary. 2. Input: 3 4 5 Output: ### 1. Write a function that matches the following declaration: int InRectangle float pt 121, float rect14]); 2. Argument pt [2] defines a point on the plane: ptol is the x-coordinate, pt (1) is the y-coordinate Argument rect [4] defines a rectangle on the same plane rectal and rect[1] define the x- and y-cordinates respectively of one comer of the rectangle rect(2) and rect13define the opposite comer. 4. Coordinates may be any valid floating point value, including negative values 5. The function returns into false) for any point that is outside the rectangle, and 1 (true) for any other point (.e. points inside and on the boundary of the rectangle). Guide and Testing It is very common to represent geometric figures using small fond-size arrays like this. Note that the side of the rays are specified in the function declaration. This allows the completo check that the function is called with a correctly sized array Since this task calls for a function only, and not a complete program, you need to write a program to test your function. The grading robot uses a program that looks something like this 1. // declaration of function to test 2. int InRectangle float pt 121. float rect 4 ); 4. int maint int arge, char* argv[l) // define a rectangle from (1.1) to (2.2) float rect(4) = (1.0, 1.0, 2.0, 2.0); // define a point that is inside the rectangle float p_in21 (1.5, 1.5 ): 11. 12. // define a point that is outside the rectangle float p_out 12) = (2.5, .5): 15. // define a point that is on the edge of the rectangle float p_edge12] - (1.0, 1.0); 17. 18, // InRectangle() should return false) for points that are NOT in // the rectangle, and non-zero (true) for points that are in the // rectangle. Points on the edge are considered in the rectangle. 23. // test 1 if( In Rectangle Din, rect) puts( "error: should return true for p_in.); return 1; // indicate error // test 2 ifInRectanglel p_out, rect) != ) puts "errort should return false for p out." ); return 1; // indicate error // test 3 if In Rectangle p_edge, rect) ) puts( "error: should return true for p edge."); return 1; // indicate error return $; // all tests passed 44. ) The code tests that the function works correctly with these Weekly Exercise 5 - 5 6 of 8 - Our challenge (cont'd): But you would not be able to put both of these test cases in your list of test cases for scrambled.c because both are testing the same statements in your function, ie, the statements that confirm arrt is indeed a scrambled version of art2 - So. you would have to come up with another test case such as: -Test Case C -input dato: arr1=[6.8.9.10), arr2 = 7.9.8.10) -Expected result: 0 Weekly Exercise 5-6 - Our challenge (contid: - You would now be able to include Test Case A (or Test Case B) and Test Case C in your list of test cases for scrambled.c because both are testing different statements in your function, ie. -Test Case A tests the statements that confirm arri is a scrambled version of arr2 -Test Case Ctests the statements that confirm arri is not a scrambled version of arr2 Note that: -There may be an overlap between these two groups of statements You may have to include other test cases into the list of test cases for scrambled.cos Test Case A and Test Case C may not be the only two test cases needed to completely test scrambled.c Weekly Exercise 5-7 - Submission: Create a document in which you first copy the content of your verticalgraph.c function then you put your list of test cases for this function following this format: Lob 2-Toska Test Case - input debih expected result: bich Test cosex-input dat bloexpected result bih - Then copy the content of your infectangle.c function then put your list of test cases for this function following the some format: Lab 2010 Test cose 1 - input data biohexpected result: bio Test cose y-input dolorblich expected result: bich

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions