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

RomanNumeralsTest.java 1.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. import org.junit.Test;
  2. import org.junit.runner.RunWith;
  3. import org.junit.runners.Parameterized;
  4. import org.junit.runners.Parameterized.Parameters;
  5. import java.util.Arrays;
  6. import java.util.Collection;
  7. import static org.junit.Assert.assertEquals;
  8. @RunWith(Parameterized.class)
  9. public class RomanNumeralsTest {
  10. private int input;
  11. private String expectedOutput;
  12. @Parameters
  13. public static Collection<Object[]> data() {
  14. return Arrays.asList(new Object[][]{
  15. {0, ""},
  16. {1, "I"},
  17. {2, "II"},
  18. {3, "III"},
  19. {4, "IV"},
  20. {5, "V"},
  21. {6, "VI"},
  22. {9, "IX"},
  23. {27, "XXVII"},
  24. {48, "XLVIII"},
  25. {59, "LIX"},
  26. {93, "XCIII"},
  27. {141, "CXLI"},
  28. {163, "CLXIII"},
  29. {402, "CDII"},
  30. {575, "DLXXV"},
  31. {911, "CMXI"},
  32. {1024, "MXXIV"},
  33. {3000, "MMM"}
  34. });
  35. }
  36. public RomanNumeralsTest(int input, String expectedOutput) {
  37. this.input = input;
  38. this.expectedOutput = expectedOutput;
  39. }
  40. @Test
  41. public void convertArabicNumberalToRomanNumeral() {
  42. RomanNumeral romanNumeral = new RomanNumeral(input);
  43. assertEquals(romanNumeral.getRomanNumeral(), expectedOutput);
  44. }
  45. }