Question: Purpose: To create white-box tests for a function you wrote yourself. Degree of Difficulty: Moderate, only because some students struggle with white-box test reasoning White-box

 Purpose: To create white-box tests for a function you wrote yourself.

Purpose: To create white-box tests for a function you wrote yourself. Degree of Difficulty: Moderate, only because some students struggle with white-box test reasoning White-box tests need to be created after the function being tested has been written. The idea behind white-box testing is that perhaps looking at/writing the code will give you an idea for a test case that you may not have thought of otherwise. For this question, you'll create some white-box tests to test a function that you wrote yourself. The closest_to_zero() function Write a function called closest_to_zero(num1, num2, num3). The function should have 3 parameters which are each integers, and returns the value that is closest to 0 from among those 3 . For example, given the inputs 2,7 and 0 , the function should return 0 . Given the inputs 3,1 and 5 , the function should return 1. It is possible that there is a tie. For example, 1 and 1 are equally close to 0 . In the case of a tie between a positive and negative value, the function should return the positive value. Hint: the abs () function may be useful in your solution. Write a test driver Write a test driver that contains several tests for the closest_to_zero() function. Use the examples of the textbook to get an idea for the format of the tests. Choose your test cases thoughtfully, using insights gained from writing the code. Think about every single individual line of code that you wrote, and how you might create a test case to test that line. Do NOT bother with test cases that use incorrect data types (i.e. passing in strings instead of integers). Exactly how many test cases to use is up to you; include as many as you think you need to be confident that your function is correct

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!