Package net.emaze.dysfunctional.strings.lexcasts

Source Code of net.emaze.dysfunctional.strings.lexcasts.IntegerParserTest

package net.emaze.dysfunctional.strings.lexcasts;

import net.emaze.dysfunctional.dispatching.delegates.Delegate;
import org.junit.Assert;
import org.junit.Test;

/**
*
* @author rferranti
*/
public class IntegerParserTest {

    @Test(expected = IllegalArgumentException.class)
    public void excedingMaxRadixYieldsException() {
        new IntegerParser(Character.MAX_RADIX + 1);
    }

    @Test(expected = IllegalArgumentException.class)
    public void lessThanMinRadixYieldsException() {
        new IntegerParser(Character.MIN_RADIX - 1);
    }
   
    @Test(expected=IllegalArgumentException.class)
    public void parsingNullStringYieldsException() {
        new IntegerParser(10).perform(null);
    }
   
    @Test(expected=NumberFormatException.class)
    public void parsingInvalidStringYieldsException() {
        new IntegerParser(10).perform("A");
    }
   
    @Test(expected = ClassCastException.class)
    public void passingNonStringToErasureYieldsException() {
        Delegate d = new IntegerParser(10);
        d.perform(new Object());
    }       
   
    @Test
    public void parsingValidStringYieldsValue() {
        final int got = new IntegerParser(10).perform("1");
        Assert.assertEquals(1, got);
    }
}
TOP

Related Classes of net.emaze.dysfunctional.strings.lexcasts.IntegerParserTest

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.