Writing test for VII
authorGustavo Martin Morcuende <gu.martinm@gmail.com>
Sun, 27 Nov 2016 16:49:42 +0000 (17:49 +0100)
committerGustavo Martin Morcuende <gu.martinm@gmail.com>
Sun, 27 Nov 2016 16:49:42 +0000 (17:49 +0100)
TDD/sandromancuso/romannumerals/src/main/java/org/craftedsw/romannumerals/RomanNumeralGenerator.java
TDD/sandromancuso/romannumerals/src/test/java/org/craftedsw/romannumerals/RomanNumeralsGeneratorShould.java

index 0dabe1f..17bc8f3 100644 (file)
@@ -4,8 +4,9 @@ public class RomanNumeralGenerator {
 
        public static String romanFor(int decimal) {
                String roman = "";
-               if (decimal == 5) {
-                       return "V";
+               if (decimal >= 5) {
+                       roman += "V";
+                       decimal -= 5;
                }
                for (int i = 0; i < decimal; i++) {
                        roman  += "I";
index c741117..ed9e0d8 100644 (file)
@@ -22,6 +22,7 @@ public class RomanNumeralsGeneratorShould {
                // going to be more complicated and we do not already have
                // the pattern to extract the algorithm for the IV number.
                assertThat(romanFor(5), is("V"));
+               assertThat(romanFor(7), is("VII"));
        }
 
 }