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

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