Skip to content

Line Up Exercise - Missing test case for ordinal suffix,multiples of 11/12/13 outside the teens range are not covered #1647

Description

@QuentinNev

Description

The test suite for line-up does not include any numbers whose last two digits are a multiple of 11, 12, or 13 outside the 11–13 range itself (e.g. 22, 24, 33, 36, 44, 52, 60, 63, 65, 72, 78, 91, 96...).

This gap allows an incorrect implementation to pass. For example, a common bug is checking divisibility instead of range when handling the "teens" exception:

if (last2 % 11 === 0 || last2 % 12 === 0 || last2 % 13 === 0) return `${number}th`;

This looks like it's meant to handle the 11th/12th/13th exception (and does, since 11%11=0, 12%12=0, 13%13=0), but it also incorrectly catches any other multiple of 11, 12, or 13 — such as 22, 33, 44, 52, 91 — and returns "th" for them instead of the correct "nd"/"rd"/"st".

Expected behavior

  • 22"22nd" (a buggy implementation using the check above would produce "22th")
  • 33"33rd"
  • 52"52nd"
  • 91"91st"

Suggested fix

Add at least one test case per suffix category (1st/2nd/3rd/4th-equivalents) that is also a multiple of 11, 12, or 13, to catch this class of bug (e.g. 22, 33, 52, 91.)

If line-up has canonical data in problem-specifications, it may be worth raising there too, since it's shared across tracks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions