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

Add test cases to Secret Handshake exercise #624

Closed
irene-mandarine opened this issue Mar 25, 2024 · 1 comment
Closed

Add test cases to Secret Handshake exercise #624

irene-mandarine opened this issue Mar 25, 2024 · 1 comment

Comments

@irene-mandarine
Copy link

There is a small gap in test cases which would allow error prone code to pass the tests.
For example, there is checked 32 with empty list as the result (because it's 10_000 in binary), and it works fine for following code (returns empty list on after index == 4 check) :
` fun calculateHandshake(number: Int): List {
val action = Integer.toBinaryString(number).reversed()
val result = mutableListOf()

    for((index, n) in action.withIndex()) {
        if (index == 4) {
            return result.reversed()
        }
        if (n.toString().toInt() == 1) {
           result.add(Signal.values()[index])
        }
    }
    return result
}`

Once you change test number to 33, which also should return an empty list, the list actually contains "WINK"

I propose to add one more test case to cover that little gap

Copy link
Contributor

Hello. Thanks for opening an issue on Exercism 🙂

At Exercism we use our Community Forum, not GitHub issues, as the primary place for discussion. That allows maintainers and contributors from across Exercism's ecosystem to discuss your problems/ideas/suggestions without them having to subscribe to hundreds of repositories.

This issue will be automatically closed. Please use this link to copy your GitHub Issue into a new topic on the forum, where we look forward to chatting with you!

If you're interested in learning more about this auto-responder, please read this blog post.

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

1 participant