From d28fffa4e6d645dfa4c93de6608a99ed669266e4 Mon Sep 17 00:00:00 2001 From: "moandji.ezana" Date: Thu, 12 Feb 2015 22:38:40 +0200 Subject: [PATCH] Added support for Unicode characters in quoted keys --- .../java/com/moandjiezana/toml/QuotedKeysTest.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/test/java/com/moandjiezana/toml/QuotedKeysTest.java b/src/test/java/com/moandjiezana/toml/QuotedKeysTest.java index f030f62..ac331af 100644 --- a/src/test/java/com/moandjiezana/toml/QuotedKeysTest.java +++ b/src/test/java/com/moandjiezana/toml/QuotedKeysTest.java @@ -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");