Added support for Unicode characters in quoted keys

This commit is contained in:
moandji.ezana 2015-02-12 22:38:40 +02:00
parent 1c87a9e85a
commit d28fffa4e6

View file

@ -1,7 +1,9 @@
package com.moandjiezana.toml;
import static org.hamcrest.Matchers.hasSize;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertThat;
import java.util.Map;
@ -102,6 +104,15 @@ public class QuotedKeysTest {
assertEquals("type0", toml.getString("dog.\"type\".breed.name"));
}
@Test
public void should_support_unicode() throws Exception {
Toml toml = new Toml().parse("[[\"\\u00B1\"]]\n \"\\u00B1\" = \"a\"\n [\"\\u00B11\"]\n \"±\" = 1");
assertThat(toml.getTables("\"±\""), hasSize(1));
assertEquals("a", toml.getTables("\"±\"").get(0).getString("\"±\""));
assertEquals(1, toml.getTable("\"±1\"").getLong("\"±\"").intValue());
}
@Test(expected = IllegalStateException.class)
public void should_fail_on_malformed_quoted_key() throws Exception {
new Toml().parse("k\"ey\" = 1");