031280baf2697de72f59c2de988258c20048551c
[JavaForFun] /
1 package org.craftedsw.romannumerals;
2
3 import static org.craftedsw.romannumerals.RomanNumeralGenerator.romanFor;
4 import static org.hamcrest.core.Is.is;
5 import static org.junit.Assert.assertThat;
6
7 import org.junit.Test;
8
9 public class RomanNumeralsGeneratorShould {
10
11         @Test public void
12         generate_roman_numeral_for_a_given_decimal_number() {
13                 
14                 
15                 
16                 // You must always start from the assert!!!
17                 // Method's name must describe what the assert is doing!!!
18                 assertThat(romanFor(1), is("I"));
19                 assertThat(romanFor(2), is("II"));
20                 assertThat(romanFor(3), is("III"));
21                 // We jump to five because IV is an exception, it is
22                 // going to be more complicated and we do not already have
23                 // the pattern to extract the algorithm for the IV number.
24                 assertThat(romanFor(5), is("V"));
25                 assertThat(romanFor(7), is("VII"));
26                 assertThat(romanFor(10), is("X"));
27                 assertThat(romanFor(18), is("XVIII"));
28                 assertThat(romanFor(30), is("XXX"));
29         }
30
31 }