Skip to content

Instantly share code, notes, and snippets.

@danielvaughan
Created October 10, 2014 08:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danielvaughan/af99f17cf48390cb6b29 to your computer and use it in GitHub Desktop.
Save danielvaughan/af99f17cf48390cb6b29 to your computer and use it in GitHub Desktop.
package com.example.roman;
import com.example.roman.Roman;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
/**
* Created by danielvaughan on 09/10/2014.
*/
public class RomanTest {
private Roman roman;
@Before
public void setup()
{
roman = new Roman();
}
@Test
public void return_I_for_1()
{
String romanStr = roman.fromArabic(1);
assertEquals("I", romanStr);
}
@Test
public void return_II_for_2()
{
String romanStr = roman.fromArabic(2);
assertEquals("II", romanStr);
}
@Test (expected = IllegalArgumentException.class)
public void return_error_for_0()
{
String romanStr = roman.fromArabic(0);
}
@Test
public void return_VII_for_7()
{
String romanStr = roman.fromArabic(7);
assertEquals("VII", romanStr);
}
@Test
public void return_XII_for_12()
{
return_correct_roman_value(12, "XII");
}
private void return_correct_roman_value(int arabic, String expectedRoman) {
String romanStr = roman.fromArabic(arabic);
assertEquals(expectedRoman, romanStr);
}
@Test
public void return_LXVI_for_66() {
return_correct_roman_value(66, "LXVI");
}
@Test
public void return_MMM_for_3000() {
return_correct_roman_value(3000, "MMM");
}
@Test
public void return_DC_for_600() {
return_correct_roman_value(600, "DC");
}
@Test
public void return_DC_for_888() {
return_correct_roman_value(888, "DCCCLXXXVIII");
}
@Test
public void return_DC_for_444() {
return_correct_roman_value(444, "CDXLIV");
}
@Test
public void return_DC_for_256() {
return_correct_roman_value(256, "CCLVI");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment