diff options
author | Jeff Sharkey <jsharkey@android.com> | 2013-01-30 10:58:40 -0800 |
---|---|---|
committer | Jeff Sharkey <jsharkey@android.com> | 2013-01-30 11:01:12 -0800 |
commit | 3029bf225cfa2c4b5b6e76303b0eba0d91c21026 (patch) | |
tree | fdcb568a93ac690b10518ba553915e0858a8a5c5 /core/tests/coretests | |
parent | 647abce570f3afdd667e06e9ad71738efff0e8a8 (diff) | |
download | frameworks_base-3029bf225cfa2c4b5b6e76303b0eba0d91c21026.zip frameworks_base-3029bf225cfa2c4b5b6e76303b0eba0d91c21026.tar.gz frameworks_base-3029bf225cfa2c4b5b6e76303b0eba0d91c21026.tar.bz2 |
Check text length when testing for newline.
Also add tests to verify.
Bug: 8102140
Change-Id: I7e5dbff53caeb50bfa0fb4ea5dce73e3c742986a
Diffstat (limited to 'core/tests/coretests')
-rw-r--r-- | core/tests/coretests/src/com/android/internal/util/FastXmlSerializerTest.java | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/core/tests/coretests/src/com/android/internal/util/FastXmlSerializerTest.java b/core/tests/coretests/src/com/android/internal/util/FastXmlSerializerTest.java new file mode 100644 index 0000000..be7116d --- /dev/null +++ b/core/tests/coretests/src/com/android/internal/util/FastXmlSerializerTest.java @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2013 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.internal.util; + +import junit.framework.TestCase; + +import org.xmlpull.v1.XmlSerializer; + +import java.io.ByteArrayOutputStream; + +/** + * Tests for {@link FastXmlSerializer} + */ +public class FastXmlSerializerTest extends TestCase { + public void testEmptyText() throws Exception { + final ByteArrayOutputStream stream = new ByteArrayOutputStream(); + + final XmlSerializer out = new FastXmlSerializer(); + out.setOutput(stream, "utf-8"); + out.startDocument(null, true); + out.setFeature("http://xmlpull.org/v1/doc/features.html#indent-output", true); + + out.startTag(null, "string"); + out.attribute(null, "name", "meow"); + out.text(""); + out.endTag(null, "string"); + + out.endDocument(); + + assertEquals("<?xml version='1.0' encoding='utf-8' standalone='yes' ?>\n" + + "<string name=\"meow\"></string>", stream.toString()); + } +} |