Tested that TOML array can be converted to Java array

This commit is contained in:
moandji.ezana 2014-04-09 15:08:57 +02:00
parent 35c76d85a0
commit 6329f9cd62
3 changed files with 7 additions and 3 deletions

View file

@ -1,6 +1,9 @@
package com.moandjiezana.toml; package com.moandjiezana.toml;
import static org.hamcrest.Matchers.arrayContaining;
import static org.hamcrest.Matchers.contains;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import java.io.File; import java.io.File;
@ -9,9 +12,7 @@ import java.math.BigDecimal;
import java.math.BigInteger; import java.math.BigInteger;
import java.net.URI; import java.net.URI;
import java.net.URL; import java.net.URL;
import java.util.Arrays;
import java.util.Calendar; import java.util.Calendar;
import java.util.HashSet;
import java.util.TimeZone; import java.util.TimeZone;
import org.junit.Test; import org.junit.Test;
@ -55,7 +56,8 @@ public class TomlToClassTest {
assertEquals("Did not convert string to Character", Character.valueOf('u'), extraPrimitives.character); assertEquals("Did not convert string to Character", Character.valueOf('u'), extraPrimitives.character);
assertEquals("Did not convert string to URL", new URL("http://www.example.com").toString(), extraPrimitives.url.toString()); assertEquals("Did not convert string to URL", new URL("http://www.example.com").toString(), extraPrimitives.url.toString());
assertEquals("Did not convert string to URI", new URI("http://www.test.com").toString(), extraPrimitives.uri.toString()); assertEquals("Did not convert string to URI", new URI("http://www.test.com").toString(), extraPrimitives.uri.toString());
assertEquals("Did not convert list to Set", new HashSet<String>(Arrays.asList("a", "b")), extraPrimitives.set); assertThat(extraPrimitives.set, contains("a", "b"));
assertThat(extraPrimitives.strings, arrayContaining("c", "d"));
assertEquals("Did not convert string to enum", ElementType.CONSTRUCTOR, extraPrimitives.elementType); assertEquals("Did not convert string to enum", ElementType.CONSTRUCTOR, extraPrimitives.elementType);
} }

View file

@ -20,4 +20,5 @@ public class ExtraPrimitives {
public URL url; public URL url;
public URI uri; public URI uri;
public Set<String> set; public Set<String> set;
public String[] strings;
} }

View file

@ -7,5 +7,6 @@ elementType="CONSTRUCTOR"
url="http://www.example.com" url="http://www.example.com"
uri="http://www.test.com" uri="http://www.test.com"
set=["a", "b"] set=["a", "b"]
strings=["c", "d"]
[group] [group]
key="value" key="value"