Question: Problem 49 A unit tester tests an arbitrary function f: T => S by applying it to a list of inputs, one at a time,
Problem 49
A unit tester tests an arbitrary function f: T => S by applying it to a list of inputs, one at a time, comparing each output to the expected output, then returns the number of errors detected. For example:
def cube(n: Int) = n * n * n unitTest(cube, Array((1, 1), (2, 8), (3, 9), (4, 64), (5, 124)))
//> res1: Int = 2
Notes:
The first input to the unit tester is the function to be tested: cube.
The second input to the unit tester is a partial graph of the desired function.
Recall that the graph of a function g is the set of all pairs of the form (x, g(x)).
Although the implementation of cube is correct, the unit tester found two errors. This was due to the fact that the specified expected values were incorrect.
Implement and test unitTest.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
