Skip to content

simple-cipher: add test to check that messages longer than the key can be decoded.#611

Merged
SleeplessByte merged 1 commit intoexercism:masterfrom
paparomeo:simple-cipher-test-decode-message-longer-than-key
Feb 14, 2019
Merged

simple-cipher: add test to check that messages longer than the key can be decoded.#611
SleeplessByte merged 1 commit intoexercism:masterfrom
paparomeo:simple-cipher-test-decode-message-longer-than-key

Conversation

@paparomeo
Copy link
Copy Markdown
Contributor

@paparomeo paparomeo commented Feb 11, 2019

I just come across a solution for the "Simple Cipher" exercise from a student, which could encode messages longer than the key but failed to decode messages longer than the key, and yet, because we haven't a test to cover this, all tests would pass giving an illusion of correctness.

This pull request adds a test to also check that a message longer than the key can be decoded.

Correspondent problem specifications PR: exercism/problem-specifications#1460.

@paparomeo paparomeo changed the title Add test to check that messages longer than the key can be decoded. simple-cipher: add test to check that messages longer than the key can be decoded. Feb 11, 2019
});

xtest('can decode messages longer than the key', () => {
expect(new Cipher('abc').encode('iboaqcnecbfcr'))
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you're trying to decode this.

Suggested change
expect(new Cipher('abc').encode('iboaqcnecbfcr'))
expect(new Cipher('abc').decode('iboaqcnecbfcr'))

@SleeplessByte
Copy link
Copy Markdown
Member

Actually, looking at the canonical data, you probably took it from there:

{
  "description": "Can handle messages longer than the key",
  "property": "encode",
  "input": {
    "key": "abc",
    "plaintext": "iamapandabear"
  },
  "expected": "iboaqcnecbfcr"
}

This expects a plaintext of `"iamapandabear" and expected value of "iboaqcnecbfcr" after encode.

@SleeplessByte SleeplessByte added the sync 🔄 Sync an exercise with the latest version of the problem-spec label Feb 12, 2019
@paparomeo
Copy link
Copy Markdown
Contributor Author

Silly me. Copy / paste error... 🤦‍♂️. I'll fix as soon as I get home (the invoked method should be decode rather than encode. Actually you've reminded me that I need to update the test canonical data first / instead. Thanks!

@paparomeo paparomeo force-pushed the simple-cipher-test-decode-message-longer-than-key branch from e002513 to 9eb5acd Compare February 12, 2019 18:25
@paparomeo paparomeo force-pushed the simple-cipher-test-decode-message-longer-than-key branch from 9eb5acd to f227715 Compare February 12, 2019 18:32
@paparomeo
Copy link
Copy Markdown
Contributor Author

@SleeplessByte: Fixed! Correspondent problem specifications PR: exercism/problem-specifications#1460.

@paparomeo
Copy link
Copy Markdown
Contributor Author

exercism/problem-specifications#1460 has been merged @SleeplessByte.

@SleeplessByte SleeplessByte merged commit 68595a7 into exercism:master Feb 14, 2019
@SleeplessByte
Copy link
Copy Markdown
Member

You're the best @paparomeo

@junedev
Copy link
Copy Markdown
Member

junedev commented Feb 19, 2019

This was bugging me all the time when mentoring. As I came around to addressing this here I found it was fixed already. Many thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

sync 🔄 Sync an exercise with the latest version of the problem-spec

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants