๐Ÿฉบ Sickbay

Write the Test

Stardate 55163.2 ยท UES Magnanimous

Briefing

Commander Raghunathan has four implementations of the shield clamp from Season 1, written by four different people, and she does not want to read them. She wants a test: a function that takes a clamp implementation, tries it, and says whether it is correct. Then she can run it on all four and only read the ones that fail.

A test is only worth anything if it can fail. So ARCHIE will hand your test a correct clamp and expect a yes, and then several broken ones, each broken in a specific way, and expect a no for each. If your test says yes to a broken clamp, it did not check the thing that was broken. That is the whole discipline of testing, in one mission.

Mission objectives

ARCHIE checks all five every time you run diagnostics.

  • โ€ขAccepts a correct clamp
  • โ€ขRejects a clamp with no lower bound
  • โ€ขRejects a clamp whose upper bound is off by one
  • โ€ขRejects a clamp that does nothing at all
  • โ€ขAccepts a second correct clamp written a different way
Ask Commander Raghunathan for a hint

Call the clamp with a handful of chosen inputs and compare against what a correct clamp returns: something negative, zero, something in range, exactly 100, something above 100. Return whether every one matched. The inputs you choose are the test.