Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inconsistent test cases in the Hamming exercise #1666

Closed
HenryRLee opened this issue Aug 4, 2020 · 3 comments
Closed

Inconsistent test cases in the Hamming exercise #1666

HenryRLee opened this issue Aug 4, 2020 · 3 comments

Comments

@HenryRLee
Copy link

HenryRLee commented Aug 4, 2020

In #1450, two tests cases are added to the Hamming exercise. If one of the argument is empty, it throws an exception with message "[left|right] strand must not be empty":

    {
      "description": "disallow left empty strand",
      "property": "distance",
      "input": {
        "strand1": "",
        "strand2": "G"
      },
      "expected": {"error": "left strand must not be empty"}
    },
    {
      "description": "disallow right empty strand",
      "property": "distance",
      "input": {
        "strand1": "G",
        "strand2": ""
      },
      "expected": {"error": "right strand must not be empty"}
    }

This message apparently contradicts with the first test case, where both arguments are empty, it runs without any exceptions:

    {
      "description": "empty strands",
      "property": "distance",
      "input": {
        "strand1": "",
        "strand2": ""
      },
      "expected": 0
    }

In my opinion, the error messages in these two cases, should be identical to the other different length exceptions, i.e. "left and right strands must be of equal length":

    {
      "description": "disallow first strand longer",
      "property": "distance",
      "input": {
        "strand1": "AATG",
        "strand2": "AAA"
      },
      "expected": {"error": "left and right strands must be of equal length"}
    }

A significant issue from the current test case is the exercise from the Java track, in order to pass all the test cases, I have to do:

// Only throw this if left strand is empty and right strand is not
if (leftStrand.isEmpty() && !rightStrand.isEmpty())
    throw new IllegalArgumentException("left strand must not be empty.");

// Only throw this if right strand is empty and left strand is not
if (rightStrand.isEmpty() && !leftStrand.isEmpty())
    throw new IllegalArgumentException("right strand must not be empty.");

if (leftStrand.length() != rightStrand.length())
    throw new IllegalArgumentException("leftStrand and rightStrand must be of equal length.");

where the condition and the message is not very consistent..

@HenryRLee HenryRLee changed the title Inconcise test cases in the Hamming exercise Illogical test cases in the Hamming exercise Aug 4, 2020
@HenryRLee HenryRLee changed the title Illogical test cases in the Hamming exercise Inconsistent test cases in the Hamming exercise Aug 4, 2020
@TomPradat
Copy link

I'll work on this

@TomPradat
Copy link

It looks like this has been fixed since #1783

@petertseng
Copy link
Member

rather, it was fixed in #1762

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants