Package net.emaze.dysfunctional.strings.lexcasts

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

package net.emaze.dysfunctional.strings.lexcasts;

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

/**
*
* @author rferranti
*/
public class DoubleTryParserTest {
   
    @Test(expected = ClassCastException.class)
    public void passingNonStringToErasureYieldsException() {
        Delegate d = new DoubleTryParser();
        d.perform(new Object());
    }       

    @Test
    public void parsingNullStringYieldsNothing() {
        final Maybe<Double> got = new DoubleTryParser().perform(null);
        Assert.assertFalse(got.hasValue());
    }

    @Test
    public void parsingInvalidStringYieldsNothing() {
        final Maybe<Double> got = new DoubleTryParser().perform("A");
        Assert.assertFalse(got.hasValue());
    }

    @Test
    public void parsingValidStringYieldsJustValue() {
        final Maybe<Double> got = new DoubleTryParser().perform("1.");
        Assert.assertEquals(Maybe.just(1d), got);
    }
}
TOP

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

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.