Skip to content

Test with negative and 0 lengths sides of invalid triangles #1871

Closed

Description

@szabgab

I've encountered solution where the student only checked if the sides are 0 and not if they are negative. In other cases only one of the functions was checking if the triangle is even valid.

I submitted some additional tests for the Python track exercism/python#2704 , but was pointed to this file: https://github.com/exercism/problem-specifications/blob/main/exercises/triangle/canonical-data.json
Before adding those tests to the json file, I'd like to know if you think those should be added or it is ok if people only check for 0 length sides.

Activity

  1. BethanyG commented on Oct 29, 2021

    @BethanyG
    Member

    @szabgab -- take a look at #1836 as well -- which might change the need for additional cases.

  2. ErikSchierboom commented on Jan 27, 2022

    @ErikSchierboom
    Member

    I'd prefer not to add test cases for negative length sides. While technically indeed an option, our exercises don't have to be exhaustive in their tests. In other words: we don't have to guard against all invalid input. That said, if other people disagree, feel free to let me know. CC @exercism/reviewers

  3. booniepepper commented on Jan 31, 2022

    @booniepepper
    Contributor

    @szabgab I've benefited enormously from your work! I feel like I come across your blogs & posts multiple times a year

    I agree in general that most exercises don't have to be exhaustive (and especially the easy, early exercises probably should not). That said, @kotp noted here that this question about triangles and side length validation is a recurring issue.

    My 2 cents is: I am lazy, and I don't like having the same discussion multiple times. My advice would be to add some tests. Implementing a <= is reasonable for a beginner exercise in my opinion. Individual tracks can decide to adopt or ignore the test cases.

  4. IsaacG commented on Jul 29, 2026

    @IsaacG
    Member

    Degenerate triangles are not explicitly excluded from this exercise. See #2579
    Negative and zero sides should be similarly excluded.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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