0f8d33ff1d8cd4980b9e39609ccbb8c95b4970fe
[frank.git] / test / net / jaekl / qd / util / ParseUtilsTest.java
1 package net.jaekl.qd.util;
2
3 import junit.framework.Assert;
4
5 import org.junit.Test;
6
7 public class ParseUtilsTest {
8
9         @Test
10         public void testParseDouble() {
11                 String[] inputs =   { null,  "", "0.0", "27.34", "1234", "3.141592653589793238", "-77.18", "bogus" };
12                 double[] expected = {  0.0, 0.0,   0.0,   27.34,   1234,   3.141592653589793238,   -77.18,     0.0 };  
13                 double actual;
14                 
15                 for (int i = 0; i < inputs.length; ++i) {
16                         actual = ParseUtils.parseDouble(inputs[i]);
17                         Assert.assertEquals(expected[i], actual);
18                 }
19         }
20
21         @Test
22         public void testParseInt() {
23                 String[] inputs = { null, "", "0", "7.1", "1234", "314159265", "-7718", "bogus" };
24                 int[] expected  = {    0,  0,   0,    0,    1234,   314159265,   -7718,       0 };
25                 int actual;
26                 
27                 for (int i = 0; i < inputs.length; ++i) {
28                         actual = ParseUtils.parseInt(inputs[i]);
29                         Assert.assertEquals(expected[i], actual);
30                 }
31         }
32
33 }