package com.qinxiandiqi.easyandroid.base;

import android.test.InstrumentationTestCase;

import org.junit.Test;

/**
 * Created by Jianan on 10/28/15.
 */
public class EasyParserTest extends InstrumentationTestCase {

    @Test
    public void testParseLongFromStr(){
        assertEquals(EasyParser.parseLongFromStr("123", 321L), 123L);
        assertEquals(EasyParser.parseLongFromStr("drafad", 321L), 321L);
        assertEquals(EasyParser.parseLongFromStr("-123", 321L), -123L);
        assertEquals(EasyParser.parseLongFromStr("123", 321L), 123);
    }

    @Test
    public void testParseIntFromStr(){
        assertEquals(EasyParser.parseIntFromStr("213", 123), 213);
        assertEquals(EasyParser.parseIntFromStr("asdfa", 123), 123);
        assertEquals(EasyParser.parseIntFromStr("-34", 123), -34);
        assertEquals(EasyParser.parseIntFromStr("23.3", 123), 123);
        assertEquals(EasyParser.parseIntFromStr("23.00", 123), 123);
    }

    @Test
    public void testParseDoubleFromStr(){
        assertEquals(EasyParser.parseDoubleFromStr("23.232323", 0.11), 23.232323);
        assertEquals(EasyParser.parseDoubleFromStr("sdfas", 2), 2D);
        assertEquals(EasyParser.parseDoubleFromStr("-23.55", 0), -23.55);
        assertEquals(EasyParser.parseDoubleFromStr("23.00", 0), 23.00);
    }
}

@@ -1303,11 +1303,346 @@
 );%0A    %7D
+%0A%0A    @Test%0A    public void testParseFloatFromStr()%7B%0A        assertEquals(EasyParser.parseFloatFromStr(%220.12%22, 0), 0.12);%0A        assertEquals(EasyParser.parseFloatFromStr(%22-0.12%22, 0), -0.12);%0A        assertEquals(EasyParser.parseFloatFromStr(%22sdfas%22, 0), 0);%0A        assertEquals(EasyParser.parseFloatFromStr(%2223.00%22, 0), 23.0);%0A    %7D
 %0A%7D%0A

add JUnit test for EasyParser.