summaryrefslogtreecommitdiffstats
path: root/core/tests
diff options
context:
space:
mode:
authorJesse Wilson <jessewilson@google.com>2011-07-20 12:23:23 -0700
committerJesse Wilson <jessewilson@google.com>2011-07-20 12:23:23 -0700
commit7a2c813d304b910b00046115efb0f462e6431a64 (patch)
tree66c54c59239147c4e4515b88139dd833ed3ed604 /core/tests
parent85111ee50108e66254c6edbda76c7ed9676dc536 (diff)
downloadframeworks_base-7a2c813d304b910b00046115efb0f462e6431a64.zip
frameworks_base-7a2c813d304b910b00046115efb0f462e6431a64.tar.gz
frameworks_base-7a2c813d304b910b00046115efb0f462e6431a64.tar.bz2
Skip byte order mark (BOM) in JsonReader
Bug: http://code.google.com/p/android/issues/detail?id=18508 Change-Id: I7652080d9ab475c75d0a811a6e2ede4975ebe063
Diffstat (limited to 'core/tests')
-rw-r--r--core/tests/coretests/src/android/util/JsonReaderTest.java21
1 files changed, 21 insertions, 0 deletions
diff --git a/core/tests/coretests/src/android/util/JsonReaderTest.java b/core/tests/coretests/src/android/util/JsonReaderTest.java
index 0b50af3..42b7640 100644
--- a/core/tests/coretests/src/android/util/JsonReaderTest.java
+++ b/core/tests/coretests/src/android/util/JsonReaderTest.java
@@ -857,11 +857,32 @@ public final class JsonReaderTest extends TestCase {
}
}
+ public void testBomIgnoredAsFirstCharacterOfDocument() throws IOException {
+ JsonReader reader = new JsonReader(new StringReader("\ufeff[]"));
+ reader.beginArray();
+ reader.endArray();
+ }
+
+ public void testBomForbiddenAsOtherCharacterInDocument() throws IOException {
+ JsonReader reader = new JsonReader(new StringReader("[\ufeff]"));
+ reader.beginArray();
+ try {
+ reader.endArray();
+ fail();
+ } catch (IOException expected) {
+ }
+ }
+
public void testFailWithPosition() throws IOException {
testFailWithPosition("Expected literal value at line 6 column 3",
"[\n\n\n\n\n0,}]");
}
+ public void testFailWithPositionIsOffsetByBom() throws IOException {
+ testFailWithPosition("Expected literal value at line 1 column 4",
+ "\ufeff[0,}]");
+ }
+
public void testFailWithPositionGreaterThanBufferSize() throws IOException {
String spaces = repeat(' ', 8192);
testFailWithPosition("Expected literal value at line 6 column 3",