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

AtbashTest.java 2.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. import org.junit.Test;
  2. import org.junit.Ignore;
  3. import org.junit.experimental.runners.Enclosed;
  4. import org.junit.runner.RunWith;
  5. import org.junit.runners.Parameterized;
  6. import org.junit.runners.Parameterized.Parameters;
  7. import java.util.Arrays;
  8. import java.util.Collection;
  9. import static org.junit.Assert.assertEquals;
  10. @RunWith(Enclosed.class)
  11. public class AtbashTest {
  12. @RunWith(Parameterized.class)
  13. public static class EncodeTest {
  14. private String input;
  15. private String expectedOutput;
  16. @Parameters
  17. public static Collection<Object[]> data() {
  18. return Arrays.asList(new Object[][] {
  19. { "no", "ml" },
  20. { "yes", "bvh" },
  21. { "OMG", "lnt" },
  22. { "mindblowingly", "nrmwy oldrm tob" },
  23. { "Testing, 1 2 3, testing.", "gvhgr mt123 gvhgr mt" },
  24. { "Truth is fiction.", "gifgs rhurx grlm" },
  25. { "The quick brown fox jumps over the lazy dog.", "gsvjf rxpyi ldmul cqfnk hlevi gsvoz abwlt" }
  26. });
  27. }
  28. public EncodeTest(String input, String expectedOutput) {
  29. this.input = input;
  30. this.expectedOutput = expectedOutput;
  31. }
  32. @Test
  33. public void test() {
  34. assertEquals(expectedOutput, Atbash.encode(input));
  35. }
  36. }
  37. @RunWith(Parameterized.class)
  38. public static class DecodeTest {
  39. private String input;
  40. private String expectedOutput;
  41. @Parameters
  42. public static Collection<Object[]> data() {
  43. return Arrays.asList(new Object[][] {
  44. { "vcvix rhn", "exercism" },
  45. { "zmlyh gzxov rhlug vmzhg vkkrm thglm v", "anobstacleisoftenasteppingstone" },
  46. { "gvhgr mt123 gvhgr mt", "testing123testing" }
  47. });
  48. }
  49. public DecodeTest(String input, String expectedOutput) {
  50. this.input = input;
  51. this.expectedOutput = expectedOutput;
  52. }
  53. @Ignore
  54. @Test
  55. public void test() {
  56. assertEquals(expectedOutput, Atbash.decode(input));
  57. }
  58. }
  59. }