Skip to content

isbn-verifier: Test Suite Omits Important Edge Case #1052

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

Closed
kytrinyx opened this issue Dec 29, 2017 · 7 comments · Fixed by #1055
Closed

isbn-verifier: Test Suite Omits Important Edge Case #1052

kytrinyx opened this issue Dec 29, 2017 · 7 comments · Fixed by #1055

Comments

@kytrinyx
Copy link
Member

Reported by @p0st0culus in exercism/exercism#3702

Confirmed missing from canonical data.


The test suite for the ISBN Verifier problem in the Swift track should test for an empty string ISBN. This is a an important edge case that @damlar noted was missing from my solutions which is also omitted from the test suite.

It's something that, in hindsight, I should have known to test for, but I didn't. That's the whole point of a well thought out test suite though: Code against assertions of what a valid solution should produce. I tend to implicitly put trust in the test suites, so that's my lesson learned. I'll take an active role in the test suites going forward.

I recommend modifying IsbnVerifierTests.swift as follows. Other content from the test suite omitted with ellipses for clarity:

class IsbnVerifierTests: XCTestCase {

    //...

    func testEmptyIsbn() {
        XCTAssertFalse(IsbnVerifier.isValid(""))
    }

    //...

    static var allTests: [(String, (IsbnVerifierTests) -> () throws -> Void)] {
        return [
            //...
            ("testEmptyIsbn", testEmptyIsbn),
            //...
        ]
    }
}

Thanks.

@rpottsoh
Copy link
Member

This seems related to #902, which is dealing with including or excluding cases that test for invalid input. The recent trend has been to steer clear of test cases that check for invalid input unless the test has relevance to the problem. The assumption being that, in real life, some algorithm would likely pre-screen the input before passing it on to the algorithm, ISBN Verifier in this instance.

I personally have no issue with adding another test case that looks for an empty ISBN code to be verified.

@TwilightCitizen
Copy link

TwilightCitizen commented Dec 30, 2017 via email

@coriolinus
Copy link
Member

I have a somewhat different understanding from #902: as I see it, all exercises should be able to implicitly assume that inputs have been pre-screened for validity.

However, I'd agree that in this case we're actually performing validation, and a zero-length string is a reasonable case to test here.

@rpottsoh
Copy link
Member

Appears to me that there are two changes that need to be made.

  1. Add a case that checks for an empty string input.
  2. All cases updated to include an input class per JSON Schema proposal: All inputs should appear under the input key #996.

@coriolinus
Copy link
Member

Yes, but those two should be in separate PRs; they're distinct.

@rpottsoh
Copy link
Member

I agree

@rpottsoh
Copy link
Member

@p0st0culus where should this new case appear in the test data? I am working on a PR to get #996 out of the way.

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

Successfully merging a pull request may close this issue.

4 participants