Skip to content

collatz-conjecture: test positive but invalid values #2103

@gabo-cs

Description

@gabo-cs

The tests are missing a really cool scenario, that is, numbers less than one and any decimal number actually.

With the existing error cases (0 and -15), a raise if n < 1 does the trick and students wouldn't even think of an is_integer check, but we know the Collatz Conjecture wouldn't like that.

From a mentoring discussion with @kotp :

The tests that exist are not enforcing that we use only valid numbers, it only touches on zero and negative numbers, but it is not inclusive of the numbers that are not valid.

So how about something like this?

{
      "description": "positive value but less than one is an error",
      "comments": ["Collatz Conjecture holds only for positive integers"],
      "property": "steps",
      "input": {
        "number": 0.5
      },
      "expected": {
        "error": "Only positive integers are allowed"
      }
    }

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