Choosing a discriminating harness self-check

A harness self-check exercises a test harness using implementations whose behaviour you already know. You want to check whether your harness actually compares returned integers with expected integers.


The required function returns the square of its integer input. Your deliberately incorrect implementation instead returns twice its input:


Python
def candidate(n):
    return 2 * n


Assume the harness calculates the expected square correctly and should report pass exactly when the returned and expected integers are equal.


Complete the statements using pass, fail, or an integer as appropriate.


For input 2, a correctly functioning harness reports . For input 3, a correctly functioning harness reports . Of these two inputs, the one that can expose a faulty harness that always reports pass is .

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

More Test Harnesses Questions: