THINK FIRST·CODE LATER

← All labs

Boundary-value test generator

Problem

Generate boundary-value tests for integer input fields.

Input: lines field min max until the end of input (the valid range is min..max, inclusive, min < max).

For each field print the field name followed by the test values, each with its expected classification, in this order: min-1, min, min+1, a nominal value (min + max) / 2 (integer division), max-1, max, max+1. Skip a value if it is equal to one already printed for this field (e.g., when the range is small). Format:

field:
  value -> VALID|INVALID

At the end print Total: t tests (v valid, i invalid).

Input:

titleLength 5 100
groupSize 2 6

Output:

titleLength:
  4 -> INVALID
  5 -> VALID
  6 -> VALID
  52 -> VALID
  99 -> VALID
  100 -> VALID
  101 -> INVALID
groupSize:
  1 -> INVALID
  2 -> VALID
  3 -> VALID
  4 -> VALID
  5 -> VALID
  6 -> VALID
  7 -> INVALID
Total: 14 tests (10 valid, 4 invalid)

Write it here or in your IDE, then paste it. Compile and test it yourself before comparing. Your code stays in your browser — it is never sent to or stored on the server.