Bitpath

Lesson 2 · Unit 01

Choosing cases

Edges, boundaries and inputs that must be rejected

12 exercisesabout 3 min

What you practise

  • Happy path, edges (empty, one, many, boundaries, duplicates, negative), error cases
  • Equivalence classes
  • The bug is usually at the boundary

Try a question from this lesson

Pick one

The spec says a score of 90 or more is an A. Which single test input reveals the bug?

def grade(score):
    if score > 90:
        return "A"
    if score > 80:
        return "B"
    return "C"
function grade(score) {
  if (score > 90) return "A";
  if (score > 80) return "B";
  return "C";
}
function grade(score: number): string {
  if (score > 90) return "A";
  if (score > 80) return "B";
  return "C";
}
Hint

Three of these inputs sit comfortably inside a grade. One sits exactly on a line.

The idea

Concept cards are short on purpose. In the app they appear between questions, after you have met the idea.

Concept

Classes and boundaries

Inputs that the code treats the same way form a class. One test per class is enough: a second one from the same class finds nothing new.

Then test each boundary between classes, on both sides. That is where > gets written for >=.

score  0 .... 79 | 80 .. 89 | 90 .. 100
grade      C     |    B     |     A
tests  50     79 | 80    89 | 90     95

10 more exercises in the app

  • 2× type the answer
  • 4× multiple choice
  • 1× fill the blanks
  • 1× true or false
  • 1× order the lines
  • 1× match the pairs

Bitpath is an iOS app in development. Join the waitlist and you get one email when it is ready to try.

One email when Bitpath is ready to try. Nothing else. Privacy