Curriculum

Curriculum

Test Empty Lists and Single-Item Lists

Scenario

Test findMaxFreeSeats(seatList) on [], [4], and [2, 5, 1].

Selected choicePick a choice below
Result—

Try it yourself

Compare what length-0 and length-1 fixtures expose.

Reveal the explanation
  1. seatList = []

    Returns NO_ROOMS instead of crashing on seatList[0].

  2. seatList = [4]

    Returns 4 — catches loops that start at index 1 or skip the last item.

  3. seatList = [2, 5, 1]

    Returns 5 — confirms full traversal across multiple items.

Every list function deserves at least three shape tests: 0 items, 1 item, and 3+ items.

Review first
Download shared test cases

Your turn

Write 0-item, 1-item, and 3-item test cases for scoreQuiz(answerKey, studentAnswers).

Common mistake Testing only 3-question quizzes and never verifying ([], []) or (["A"], ["A"]).

Check your work

([], []) -> 0; (["A"], ["A"]) -> 1; (["A","B","C"], ["A","X","C"]) -> 2.

Quick check

Which bug is specifically exposed by testing a 1-item list like [4]?
Show the answer and reasoning

Correct answer A loop that accidentally skips the first or last element (e.g., i < len - 1)

On a 1-item list, skipping either end leaves zero items processed.