Skip to content

[#1475] Update Cipher Tests#1639

Merged
FridaTveit merged 10 commits into
exercism:masterfrom
RonakLakhotia:cipher
Mar 18, 2019
Merged

[#1475] Update Cipher Tests#1639
FridaTveit merged 10 commits into
exercism:masterfrom
RonakLakhotia:cipher

Conversation

@RonakLakhotia

Copy link
Copy Markdown
Contributor

Fixes #1475

@RonakLakhotia

Copy link
Copy Markdown
Contributor Author

@FridaTveit how to detect the checkstyle errors?

@FridaTveit

Copy link
Copy Markdown
Contributor

See our contributing guide. You can run the plugin locally by running gradle check from the root folder of the exercise. Then the checkstyle plugin will show you every style violation of your code. Let me know if you have any issues with that 🙂

@RonakLakhotia

RonakLakhotia commented Mar 9, 2019

Copy link
Copy Markdown
Contributor Author

I seem to be getting a command not found error. @FridaTveit

@RonakLakhotia

Copy link
Copy Markdown
Contributor Author

@FridaTveit gentle reminder. 🙂

@FridaTveit

Copy link
Copy Markdown
Contributor

@RonakLakhotia We are all maintaining this as volunteers in our spare time and therefore it will sometimes take a while for us to get back to you. Please be patient 🙂

@RonakLakhotia

Copy link
Copy Markdown
Contributor Author

We are all maintaining this as volunteers in our spare time and therefore it will sometimes take a while for us to get back to you. Please be patient 🙂

My apologies.

@RonakLakhotia

Copy link
Copy Markdown
Contributor Author

rectified the checkstyle errors. 🙂

@FridaTveit FridaTveit left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks great, thanks @RonakLakhotia! 🙂

I've left a few comments, let me know if you have any questions or disagree with any of it 🙂

for (int i = 0; i < Math.min(copy.length(), key.length()); i++) {
ciphertext.append(encodeCharacter(copy, i));
}
copy = plainText.substring(ciphertext.length(), plainText.length());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why use this instead of the for loop?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

You mean for loop instead of substring?

Comment thread exercises/simple-cipher/src/test/java/SimpleCipherStepOneTest.java
Comment thread exercises/simple-cipher/src/test/java/SimpleCipherStepThreeIncorrectKeyTest.java Outdated
Comment thread exercises/simple-cipher/src/test/java/SimpleCipherStepThreeIncorrectKeyTest.java Outdated
Comment thread exercises/simple-cipher/.meta/version Outdated
}
copy = "";
for (int i = ciphertext.length(); i < plainText.length(); i++) {
copy = copy + plainText.charAt(i);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Like this you mean?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No, sorry if I wasn't clear. I meant why did this have to change at all? Why not keep the for loop as it used to be? Does that not work with the changes to the tests? 🙂

@RonakLakhotia RonakLakhotia Mar 18, 2019

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

With the original code, the cipherMessageLongerThanKey test case seems to be failing in SimpleCipherStepTwoSubsitutionTest

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Oh I see 🙂 Well, I think adding the extra while loop makes it a bit confusing? Maybe it would be easier to add a small helper method which will pad or cut the key so that it's the same length as the plaintext? That is something like:

String sameLengthKey = getKeySameLengthAsPlaintext(plaintext, key);
for (int index = 0; index < plaintext.length(); index++) {
  ciphertext.append(encodeCharacter(plaintext, index, key));
}

What do you think? 🙂 It's not very important though, so feel free to keep it as it is if you like. But if so please change it back to use substring 🙂

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@FridaTveit made the relevant changes as you suggested. 👍

@FridaTveit FridaTveit left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This looks great! Thanks for making those changes @RonakLakhotia 🙂 I've left a few comments but they're all very minor things 🙂

Comment thread exercises/simple-cipher/.meta/src/reference/java/Cipher.java Outdated
Comment thread exercises/simple-cipher/.meta/src/reference/java/Cipher.java Outdated
Comment thread exercises/simple-cipher/.meta/src/reference/java/Cipher.java Outdated

@FridaTveit FridaTveit left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks great, thanks @RonakLakhotia 🙂

@RonakLakhotia

Copy link
Copy Markdown
Contributor Author

Looks great, thanks @RonakLakhotia 🙂

Thanks for the guidance @FridaTveit 👍

@FridaTveit FridaTveit merged commit 83e8cb9 into exercism:master Mar 18, 2019
apetresc added a commit to apetresc/java that referenced this pull request Oct 18, 2023
This test file was removed years ago in exercism#1639, but the instructions still mention it (which caused me, at least, quite a bit of confusion since I thought I had deleted something erroneously).

This fixes the documentation to remove the reference to Step Three. If the intent was to never have deleted SimpleCipherStepThreeTest.java in the first place, let me know and I'll amend the PR to that.
apetresc added a commit to apetresc/java that referenced this pull request Oct 18, 2023
This test file was removed years ago in exercism#1639, but the instructions still mention it (which caused me, at least, quite a bit of confusion since I thought I had deleted something erroneously).

This fixes the documentation to remove the reference to Step Three. If the intent was to never have deleted SimpleCipherStepThreeTest.java in the first place, let me know and I'll amend the PR to that.
sanderploegsma pushed a commit that referenced this pull request Oct 20, 2023
…2523)

* [simple-cipher] Fix outdated reference to SimpleCipherStepThreeTest

This test file was removed years ago in #1639, but the instructions still mention it (which caused me, at least, quite a bit of confusion since I thought I had deleted something erroneously).

This fixes the documentation to remove the reference to Step Three. If the intent was to never have deleted SimpleCipherStepThreeTest.java in the first place, let me know and I'll amend the PR to that.

* [simple-cipher] Fix incorrect reference to test file in instructions.

This revealed that actually there's a typo in the class name itself.
Determining next whether to fix that or leave it be.

* [simple-cipher] Combine the two test classes into a single suite

* [simple-cipher] Fix checkstyle failures

* [simple-cipher] Remove outdated test files from .meta/config.json

* [simple-cipher] Use Enclosed JUnit runner for inner test classes
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 this pull request may close these issues.

2 participants