Take an existing booking [10, 20) and a requested booking [5, 25). They share ten units of time, so the request must be rejected. Yet a tempting overlap check asks only whether the new booking's start or end falls inside the existing one. Both endpoints sit outside [10, 20), so that check returns False. A booking that surrounds another has slipped through.
The boundary convention matters. These are half-open intervals: the start is included and the end is excluded. A booking ending at 20 may therefore sit next to one starting at 20 without a conflict. For positive-duration intervals, the compact rule is that each booking must start before the other one ends:
def overlaps(new_start, new_end, existing_start, existing_end):
return new_start < existing_end and existing_start < new_end
cases = [
((5, 25, 10, 20), True),
((5, 10, 10, 20), False),
((20, 25, 10, 20), False),
]
for args, expected in cases:
assert overlaps(*args) is expected
print("checked", len(cases), "cases")
This small snippet was executed as written and checked the surrounding case plus both touching boundaries. It is an illustration, not a production booking component: it does not validate inputs or address dates, time zones, storage, concurrency, or multiple existing bookings.
The more interesting failure is in the test oracle. In the bounded demonstration, a weak suite included the surrounding interval but calculated its expected answer with a copied version of the same endpoint-only rule. The deliberately faulty implementation passed all 9 of those tests. When the expected answers came instead from the written interval contract, it passed 8 of 9 and failed exactly on [5, 25). The corrected predicate passed all 9 requirement cases. It also failed the weak suite on that same case, because the weak suite expected the wrong answer.
That is why adding more examples to a circular oracle is not enough. Write the requirement table first and make its expected results literal: gaps before and after, touching at either boundary, partial overlaps, a booking contained inside another, a booking that contains the existing one, and identical intervals. Then run both the suspected implementation and the test oracle against that table. A correct implementation should not be forced to agree with a copied mistake.
For AI-assisted testing, the same order is useful: ask for the cases and expected outcomes from the stated booking rules before asking for executable tests. Review the surrounding and touching cases yourself. This demonstration used nine selected integer intervals, not a failure-rate estimate or evidence about generated code in general. It establishes one precise counterexample and a practical way to keep the specification separate from the predicate.