lots of exercises in java... from https://github.com/exercism/java

CryptoSquareTest.java 2.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. import org.junit.Test;
  2. import org.junit.Ignore;
  3. import java.util.Arrays;
  4. import java.util.List;
  5. import static org.junit.Assert.assertEquals;
  6. public class CryptoSquareTest {
  7. @Test
  8. public void emptyPlaintextResultsInEmptyCiphertext() {
  9. CryptoSquare cryptoSquare = new CryptoSquare("");
  10. String expectedOutput = "";
  11. assertEquals(expectedOutput, cryptoSquare.getCiphertext());
  12. }
  13. @Ignore("Remove to run test")
  14. @Test
  15. public void lettersAreLowerCasedDuringEncryption() {
  16. CryptoSquare cryptoSquare = new CryptoSquare("A");
  17. String expectedOutput = "a";
  18. assertEquals(expectedOutput, cryptoSquare.getCiphertext());
  19. }
  20. @Ignore("Remove to run test")
  21. @Test
  22. public void spacesAreRemovedDuringEncryption() {
  23. CryptoSquare cryptoSquare = new CryptoSquare(" b ");
  24. String expectedOutput = "b";
  25. assertEquals(expectedOutput, cryptoSquare.getCiphertext());
  26. }
  27. @Ignore("Remove to run test")
  28. @Test
  29. public void punctuationIsRemovedDuringEncryption() {
  30. CryptoSquare cryptoSquare = new CryptoSquare("@1,%!");
  31. String expectedOutput = "1";
  32. assertEquals(expectedOutput, cryptoSquare.getCiphertext());
  33. }
  34. @Ignore("Remove to run test")
  35. @Test
  36. public void nineCharacterPlaintextResultsInThreeChunksOfThreeCharacters() {
  37. CryptoSquare cryptoSquare = new CryptoSquare("This is fun!");
  38. String expectedOutput = "tsf hiu isn";
  39. assertEquals(expectedOutput, cryptoSquare.getCiphertext());
  40. }
  41. @Ignore("Remove to run test")
  42. @Test
  43. public void eightCharacterPlaintextResultsInThreeChunksWithATrailingSpace() {
  44. CryptoSquare cryptoSquare = new CryptoSquare("Chill out.");
  45. String expectedOutput = "clu hlt io ";
  46. assertEquals(expectedOutput, cryptoSquare.getCiphertext());
  47. }
  48. @Ignore("Remove to run test")
  49. @Test
  50. public void fiftyFourCharacterPlaintextResultsInSevenChunksWithTrailingSpaces() {
  51. CryptoSquare cryptoSquare = new CryptoSquare("If man was meant to stay on the ground, god would have given us roots.");
  52. String expectedOutput = "imtgdvs fearwer mayoogo anouuio ntnnlvt wttddes aohghn sseoau ";
  53. assertEquals(expectedOutput, cryptoSquare.getCiphertext());
  54. }
  55. }