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

RotationalCipherTest.java 2.4KB

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