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

RomanNumeralsTest.java 1.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. import org.junit.Test;
  2. import org.junit.Ignore;
  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(Parameterized.class)
  10. public class RomanNumeralsTest {
  11. private int arabicNumeral;
  12. private String romanNumeral;
  13. @Parameters(name = "{index}: expected arabic numeral {0} to be converted to roman numeral \"{1}\".")
  14. public static Collection<Object[]> data() {
  15. return Arrays.asList(new Object[][]{
  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 arabicNumeral, String romanNumeral) {
  37. this.arabicNumeral = arabicNumeral;
  38. this.romanNumeral = romanNumeral;
  39. }
  40. @Test
  41. public void convertArabicNumberalToRomanNumeral() {
  42. RomanNumeral romanNumeral = new RomanNumeral(arabicNumeral);
  43. assertEquals(this.romanNumeral, romanNumeral.getRomanNumeral());
  44. }
  45. }