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

RotationalCipherTest.java 2.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. import org.junit.Assert;
  2. import org.junit.Before;
  3. import org.junit.Ignore;
  4. import org.junit.Test;
  5. public class RotationalCipherTest {
  6. private RotationalCipher rotationalCipher;
  7. @Test
  8. public void rotateSingleCharacterBy1() {
  9. rotationalCipher = new RotationalCipher(1);
  10. Assert.assertEquals("b", rotationalCipher.rotate("a"));
  11. }
  12. @Ignore("Remove to run test")
  13. @Test
  14. public void rotateSingleCharacterBy26() {
  15. rotationalCipher = new RotationalCipher(26);
  16. Assert.assertEquals("a", rotationalCipher.rotate("a"));
  17. }
  18. @Ignore("Remove to run test")
  19. @Test
  20. public void rotateSingleCharacterBy0() {
  21. rotationalCipher = new RotationalCipher(0);
  22. Assert.assertEquals("a", rotationalCipher.rotate("a"));
  23. }
  24. @Ignore("Remove to run test")
  25. @Test
  26. public void rotateSingleCharacterBy13() {
  27. rotationalCipher = new RotationalCipher(13);
  28. Assert.assertEquals("z", rotationalCipher.rotate("m"));
  29. }
  30. @Ignore("Remove to run test")
  31. @Test
  32. public void rotateSingleCharacterWithWrapAround() {
  33. rotationalCipher = new RotationalCipher(13);
  34. Assert.assertEquals("a", rotationalCipher.rotate("n"));
  35. }
  36. @Ignore("Remove to run test")
  37. @Test
  38. public void rotateCapitalLetters() {
  39. rotationalCipher = new RotationalCipher(5);
  40. Assert.assertEquals("TRL", rotationalCipher.rotate("OMG"));
  41. }
  42. @Ignore("Remove to run test")
  43. @Test
  44. public void rotateSpaces() {
  45. rotationalCipher = new RotationalCipher(5);
  46. Assert.assertEquals("T R L", rotationalCipher.rotate("O M G"));
  47. }
  48. @Ignore("Remove to run test")
  49. @Test
  50. public void rotateNumbers() {
  51. rotationalCipher = new RotationalCipher(4);
  52. Assert.assertEquals("Xiwxmrk 1 2 3 xiwxmrk", rotationalCipher.rotate("Testing 1 2 3 testing"));
  53. }
  54. @Ignore("Remove to run test")
  55. @Test
  56. public void rotatePunctuation() {
  57. rotationalCipher = new RotationalCipher(21);
  58. Assert.assertEquals("Gzo'n zvo, Bmviyhv!", rotationalCipher.rotate("Let's eat, Grandma!"));
  59. }
  60. @Ignore("Remove to run test")
  61. @Test
  62. public void rotateAllLetters() {
  63. rotationalCipher = new RotationalCipher(13);
  64. Assert.assertEquals("The quick brown fox jumps over the lazy dog.",
  65. rotationalCipher.rotate("Gur dhvpx oebja sbk whzcf bire gur ynml qbt."));
  66. }
  67. }