RomanNumbersUtils { public static String toRoman(long toConvert) { if (toConvert <= 0) { throw new IllegalArgumentException(); } long n = toConvert; StringBuilder buf = new StringBuilder(); final Numeral[] values = Numeral.values(); for (int i = values.length - 1; i >= 0; i--) { while (n >= values[i].weight) { buf.append(values[i]); n -= values[i].weight; } } return buf.toString(); } private  RomanNumbersUtils(); static String toRoman(long toConvert);  }
@Test public void testToRomans() { assertEquals("MCMX", RomanNumbersUtils.toRoman(1910)); assertEquals("MCMLIV", RomanNumbersUtils.toRoman(1954)); assertEquals("MCMXC", RomanNumbersUtils.toRoman(1990)); assertEquals("C", RomanNumbersUtils.toRoman(100)); }
@Test(expected = IllegalArgumentException.class) public void testFailingNegative() { RomanNumbersUtils.toRoman(-1); }
@Test(expected = IllegalArgumentException.class) public void testFailingZero() { RomanNumbersUtils.toRoman(0); }