/*
 * Copyright (c) 2015, Matjaž <dev@matjaz.it> matjaz.it
 *
 * This Source Code Form is part of the project Numerus, a roman numerals
 * library for Java. The library and its source code may be found on:
 * https://github.com/MatjazDev/Numerus and http://matjaz.it/numerus
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/
 */

package it.matjaz.numerus.core;

import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.*;

/**
 * JUnit test of {@link RomanConverter} which is converting roman numerals to
 * integers and vice-versa by using RomanCharMapFactory generated structures.
 *
 * @author Matjaž <a href="mailto:dev@matjaz.it">dev@matjaz.it</a>
 * <a href="http://matjaz.it">www.matjaz.it</a>
 */
public class RomanConverterTest {

    private RomanConverter converter;

    @Before
    public void constructConverter() {
        this.converter = new RomanConverter();
    }

    @Test
    public void whenRomanWithMultipleSameCharsIsGivenThenArabicIsReturned() {
        assertEquals(3212, converter.romanStringToInteger("MMMCCXII"));
    }

    @Test
    public void whenRomanWithSubtractiveFormIsGivenThenArabicIsreturned() {
        assertEquals(1940, converter.romanStringToInteger("MCMXL"));
    }

    @Test
    public void whenCorrectRomanIsGivenThenArabicIsReturned() {
        assertEquals(1100, converter.romanStringToInteger("MC"));
    }
    
    @Test
    public void whenIntegerIsGivenThenRomanStringIsReturned() {
        assertEquals("CXII", converter.integerToRomanString(112));
    }

    @Test
    public void whenIntegerForRomanWithSubtractiveFormIsGivenThenRomanStringIsReturned() {
        assertEquals("XCVI", converter.integerToRomanString(96));
    }

    @Test(expected = IllegalArgumentException.class)
    public void whenNegativeIntegerIsGivenThenExceptionIsThrown() {
        converter.integerToRomanString(-2);
    }

    @Test(expected = IllegalArgumentException.class)
    public void whenTooBigIntegerIsGivenThenExceptionIsThrown() {
        converter.integerToRomanString(4001);
    }
    
    @Test
    public void romanNumeralsMayBeConvertedToIntegers() {
        assertEquals(21, converter.romanNumeralToInteger(new RomanNumeral("XXI")));
    }
    
    @Test
    public void romanNumeralsAreReturnedFromIntConversion() {
        assertEquals(new RomanNumeral("LXI"), converter.integerToRomanNumeral(61));
    }
    
    @Test
    public void whenUninitializedRomanNumeralIsConvertedReturnsZero() {
        assertEquals(0, converter.romanNumeralToInteger(new RomanNumeral()));
    }
    
}

@@ -510,16 +510,42 @@
 .core;%0A%0A
+import java.util.HashMap;%0A
 import o
@@ -2731,10 +2731,789 @@
  %7D%0A    %0A
+    @Test%0A    public void everyIntegerIsConvertedToASyntacticallyCorrectRomanNumeral() %7B%0A        for (int i = 1; i %3C= 3999; i++) %7B%0A            try %7B%0A                converter.integerToRomanNumeral(i);%0A            %7D catch (NumberFormatException ex) %7B%0A                System.out.println(ex.getMessage());%0A                fail(%22Failed to convert %22 + i);%0A            %7D%0A        %7D%0A    %7D%0A    %0A    @Test%0A    public void conversionIsBijective() %7B%0A        HashMap%3CInteger, String%3E allNumerals = new HashMap%3C%3E();%0A        for (int i = 1; i %3C= 3999; i++) %7B%0A           allNumerals.put(i, converter.integerToRomanString(i));%0A        %7D%0A        allNumerals.keySet().stream().forEach((i) -%3E %7B%0A            assertTrue(i == converter.romanStringToInteger(allNumerals.get(i)));%0A        %7D);%0A    %7D%0A    %0A
 %7D%0A

Add conversion test for all numerals