problem-specifications icon indicating copy to clipboard operation
problem-specifications copied to clipboard

Test with negative and 0 lengths sides of invalid triangles

Open szabgab opened this issue 4 years ago • 3 comments

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 https://github.com/exercism/python/pull/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.

szabgab avatar Oct 29 '21 19:10 szabgab

@szabgab -- take a look at https://github.com/exercism/problem-specifications/pull/1836 as well -- which might change the need for additional cases.

BethanyG avatar Oct 29 '21 22:10 BethanyG

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

ErikSchierboom avatar Jan 27 '22 10:01 ErikSchierboom

@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.

booniepepper avatar Jan 31 '22 22:01 booniepepper