Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

uestion 2 (8 points): Purpose: To create white-box tests for a function you wrote yourself. Degree of Difficulty: Moderate, only because some students struggle with

image text in transcribed

uestion 2 (8 points): 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. What to Hand In - A document called a3q2v1.py containing your function. - A document called a3q2v1_testdriver.py containing your test driver. This file can import your function from a3q2v1.py in order to test it. The version number (v1) portion of the file names must be changed to v2, v3 etc. each time you resubmit your assignment. Remember to include all your solution files each time you submit/resubmit your assignment

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored 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

Recommended Textbook for

IBM Db2 11 1 Certification Guide Explore Techniques To Master Database Programming And Administration Tasks In IBM Db2

Authors: Mohankumar Saraswatipura ,Robert Collins

1st Edition

1788626915, 978-1788626910

More Books

Students also viewed these Databases questions

Question

How are the key biographical characteristics relevant to OB?

Answered: 1 week ago