diff options
author | Jesse Wilson <jessewilson@google.com> | 2011-07-20 12:30:38 -0700 |
---|---|---|
committer | Jesse Wilson <jessewilson@google.com> | 2011-07-20 12:30:38 -0700 |
commit | 037fb18dd4ba3f54c5b2fb5386c5673e1db5babf (patch) | |
tree | 0d278c4a80cd5aeae196f74afc23f8617a5e58b1 /json/src/test | |
parent | b1f55cb6f95928be969a8fe5c7447e13f14d0a68 (diff) | |
download | libcore-037fb18dd4ba3f54c5b2fb5386c5673e1db5babf.zip libcore-037fb18dd4ba3f54c5b2fb5386c5673e1db5babf.tar.gz libcore-037fb18dd4ba3f54c5b2fb5386c5673e1db5babf.tar.bz2 |
Skip byte order mark (BOM) in org.json
Bug: http://code.google.com/p/android/issues/detail?id=18508
Change-Id: Ib992a0a4b22e340446abab14e4f32df5efcd0b49
Diffstat (limited to 'json/src/test')
-rw-r--r-- | json/src/test/java/org/json/JSONTokenerTest.java | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/json/src/test/java/org/json/JSONTokenerTest.java b/json/src/test/java/org/json/JSONTokenerTest.java index 528022a..de3a59a 100644 --- a/json/src/test/java/org/json/JSONTokenerTest.java +++ b/json/src/test/java/org/json/JSONTokenerTest.java @@ -574,6 +574,18 @@ public class JSONTokenerTest extends TestCase { assertEquals("skipTo shouldn't stop when it sees '\\0'", 'F', tokener.next()); } + public void testBomIgnoredAsFirstCharacterOfDocument() throws JSONException { + JSONTokener tokener = new JSONTokener("\ufeff[]"); + JSONArray array = (JSONArray) tokener.nextValue(); + assertEquals(0, array.length()); + } + + public void testBomTreatedAsCharacterInRestOfDocument() throws JSONException { + JSONTokener tokener = new JSONTokener("[\ufeff]"); + JSONArray array = (JSONArray) tokener.nextValue(); + assertEquals(1, array.length()); + } + public void testDehexchar() { assertEquals( 0, JSONTokener.dehexchar('0')); assertEquals( 1, JSONTokener.dehexchar('1')); |