aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.test/tst/org/eclipse/jgit/diff
diff options
context:
space:
mode:
authorGit Development Community <git@vger.kernel.org>2009-09-29 16:47:03 -0700
committerShawn O. Pearce <spearce@spearce.org>2009-09-29 16:47:03 -0700
commit1a6964c8274c50f0253db75f010d78ef0e739343 (patch)
treeca833cc7cf6fc8c7b9850dee258f3a356c790ffc /org.eclipse.jgit.test/tst/org/eclipse/jgit/diff
downloadjgit-1a6964c8274c50f0253db75f010d78ef0e739343.tar.gz
jgit-1a6964c8274c50f0253db75f010d78ef0e739343.zip
Initial JGit contribution to eclipse.org
Per CQ 3448 this is the initial contribution of the JGit project to eclipse.org. It is derived from the historical JGit repository at commit 3a2dd9921c8a08740a9e02c421469e5b1a9e47cb. Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Diffstat (limited to 'org.eclipse.jgit.test/tst/org/eclipse/jgit/diff')
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/diff/DiffFormatterReflowTest.java183
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/diff/EditListTest.java127
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/diff/EditTest.java146
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/diff/RawTextTest.java100
4 files changed, 556 insertions, 0 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/diff/DiffFormatterReflowTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/diff/DiffFormatterReflowTest.java
new file mode 100644
index 0000000000..d9e50d20af
--- /dev/null
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/diff/DiffFormatterReflowTest.java
@@ -0,0 +1,183 @@
+/*
+ * Copyright (C) 2009, Google Inc.
+ * Copyright (C) 2009, Johannes E. Schindelin <johannes.schindelin@gmx.de>
+ * and other copyright owners as documented in the project's IP log.
+ *
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Distribution License v1.0 which
+ * accompanies this distribution, is reproduced below, and is
+ * available at http://www.eclipse.org/org/documents/edl-v10.php
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ *
+ * - Neither the name of the Eclipse Foundation, Inc. nor the
+ * names of its contributors may be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package org.eclipse.jgit.diff;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+import junit.framework.TestCase;
+
+import org.eclipse.jgit.patch.FileHeader;
+import org.eclipse.jgit.patch.Patch;
+import org.eclipse.jgit.util.RawParseUtils;
+
+public class DiffFormatterReflowTest extends TestCase {
+ private RawText a;
+
+ private RawText b;
+
+ private FileHeader file;
+
+ private ByteArrayOutputStream out;
+
+ private DiffFormatter fmt;
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ out = new ByteArrayOutputStream();
+ fmt = new DiffFormatter();
+ }
+
+ public void testNegativeContextFails() throws IOException {
+ init("X");
+ try {
+ fmt.setContext(-1);
+ fail("accepted negative context");
+ } catch (IllegalArgumentException e) {
+ // pass
+ }
+ }
+
+ public void testContext0() throws IOException {
+ init("X");
+ fmt.setContext(0);
+ assertFormatted();
+ }
+
+ public void testContext1() throws IOException {
+ init("X");
+ fmt.setContext(1);
+ assertFormatted();
+ }
+
+ public void testContext3() throws IOException {
+ init("X");
+ fmt.setContext(3);
+ assertFormatted();
+ }
+
+ public void testContext5() throws IOException {
+ init("X");
+ fmt.setContext(5);
+ assertFormatted();
+ }
+
+ public void testContext10() throws IOException {
+ init("X");
+ fmt.setContext(10);
+ assertFormatted();
+ }
+
+ public void testContext100() throws IOException {
+ init("X");
+ fmt.setContext(100);
+ assertFormatted();
+ }
+
+ public void testEmpty1() throws IOException {
+ init("E");
+ assertFormatted("E.patch");
+ }
+
+ public void testNoNewLine1() throws IOException {
+ init("Y");
+ assertFormatted("Y.patch");
+ }
+
+ public void testNoNewLine2() throws IOException {
+ init("Z");
+ assertFormatted("Z.patch");
+ }
+
+ private void init(final String name) throws IOException {
+ a = new RawText(readFile(name + "_PreImage"));
+ b = new RawText(readFile(name + "_PostImage"));
+ file = parseTestPatchFile(name + ".patch").getFiles().get(0);
+ }
+
+ private void assertFormatted() throws IOException {
+ assertFormatted(getName() + ".out");
+ }
+
+ private void assertFormatted(final String name) throws IOException {
+ fmt.format(out, file, a, b);
+ final String exp = RawParseUtils.decode(readFile(name));
+ assertEquals(exp, RawParseUtils.decode(out.toByteArray()));
+ }
+
+ private byte[] readFile(final String patchFile) throws IOException {
+ final InputStream in = getClass().getResourceAsStream(patchFile);
+ if (in == null) {
+ fail("No " + patchFile + " test vector");
+ return null; // Never happens
+ }
+ try {
+ final byte[] buf = new byte[1024];
+ final ByteArrayOutputStream temp = new ByteArrayOutputStream();
+ int n;
+ while ((n = in.read(buf)) > 0)
+ temp.write(buf, 0, n);
+ return temp.toByteArray();
+ } finally {
+ in.close();
+ }
+ }
+
+ private Patch parseTestPatchFile(final String patchFile) throws IOException {
+ final InputStream in = getClass().getResourceAsStream(patchFile);
+ if (in == null) {
+ fail("No " + patchFile + " test vector");
+ return null; // Never happens
+ }
+ try {
+ final Patch p = new Patch();
+ p.parse(in);
+ return p;
+ } finally {
+ in.close();
+ }
+ }
+}
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/diff/EditListTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/diff/EditListTest.java
new file mode 100644
index 0000000000..5c2c3d0a22
--- /dev/null
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/diff/EditListTest.java
@@ -0,0 +1,127 @@
+/*
+ * Copyright (C) 2009, Google Inc.
+ * and other copyright owners as documented in the project's IP log.
+ *
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Distribution License v1.0 which
+ * accompanies this distribution, is reproduced below, and is
+ * available at http://www.eclipse.org/org/documents/edl-v10.php
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ *
+ * - Neither the name of the Eclipse Foundation, Inc. nor the
+ * names of its contributors may be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package org.eclipse.jgit.diff;
+
+import java.util.Iterator;
+
+import junit.framework.TestCase;
+
+public class EditListTest extends TestCase {
+ public void testEmpty() {
+ final EditList l = new EditList();
+ assertEquals(0, l.size());
+ assertTrue(l.isEmpty());
+ assertEquals("EditList[]", l.toString());
+
+ assertTrue(l.equals(l));
+ assertTrue(l.equals(new EditList()));
+ assertFalse(l.equals(""));
+ assertEquals(l.hashCode(), new EditList().hashCode());
+ }
+
+ public void testAddOne() {
+ final Edit e = new Edit(1, 2, 1, 1);
+ final EditList l = new EditList();
+ l.add(e);
+ assertEquals(1, l.size());
+ assertFalse(l.isEmpty());
+ assertSame(e, l.get(0));
+ assertSame(e, l.iterator().next());
+
+ assertTrue(l.equals(l));
+ assertFalse(l.equals(new EditList()));
+
+ final EditList l2 = new EditList();
+ l2.add(e);
+ assertTrue(l.equals(l2));
+ assertTrue(l2.equals(l));
+ assertEquals(l.hashCode(), l2.hashCode());
+ }
+
+ public void testAddTwo() {
+ final Edit e1 = new Edit(1, 2, 1, 1);
+ final Edit e2 = new Edit(8, 8, 8, 12);
+ final EditList l = new EditList();
+ l.add(e1);
+ l.add(e2);
+ assertEquals(2, l.size());
+ assertSame(e1, l.get(0));
+ assertSame(e2, l.get(1));
+
+ final Iterator<Edit> i = l.iterator();
+ assertSame(e1, i.next());
+ assertSame(e2, i.next());
+
+ assertTrue(l.equals(l));
+ assertFalse(l.equals(new EditList()));
+
+ final EditList l2 = new EditList();
+ l2.add(e1);
+ l2.add(e2);
+ assertTrue(l.equals(l2));
+ assertTrue(l2.equals(l));
+ assertEquals(l.hashCode(), l2.hashCode());
+ }
+
+ public void testSet() {
+ final Edit e1 = new Edit(1, 2, 1, 1);
+ final Edit e2 = new Edit(3, 4, 3, 3);
+ final EditList l = new EditList();
+ l.add(e1);
+ assertSame(e1, l.get(0));
+ assertSame(e1, l.set(0, e2));
+ assertSame(e2, l.get(0));
+ }
+
+ public void testRemove() {
+ final Edit e1 = new Edit(1, 2, 1, 1);
+ final Edit e2 = new Edit(8, 8, 8, 12);
+ final EditList l = new EditList();
+ l.add(e1);
+ l.add(e2);
+ l.remove(e1);
+ assertEquals(1, l.size());
+ assertSame(e2, l.get(0));
+ }
+}
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/diff/EditTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/diff/EditTest.java
new file mode 100644
index 0000000000..6f3d21e558
--- /dev/null
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/diff/EditTest.java
@@ -0,0 +1,146 @@
+/*
+ * Copyright (C) 2009, Google Inc.
+ * Copyright (C) 2009, Johannes E. Schindelin <johannes.schindelin@gmx.de>
+ * and other copyright owners as documented in the project's IP log.
+ *
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Distribution License v1.0 which
+ * accompanies this distribution, is reproduced below, and is
+ * available at http://www.eclipse.org/org/documents/edl-v10.php
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ *
+ * - Neither the name of the Eclipse Foundation, Inc. nor the
+ * names of its contributors may be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package org.eclipse.jgit.diff;
+
+import junit.framework.TestCase;
+
+public class EditTest extends TestCase {
+ public void testCreate() {
+ final Edit e = new Edit(1, 2, 3, 4);
+ assertEquals(1, e.getBeginA());
+ assertEquals(2, e.getEndA());
+ assertEquals(3, e.getBeginB());
+ assertEquals(4, e.getEndB());
+ }
+
+ public void testCreateEmpty() {
+ final Edit e = new Edit(1, 3);
+ assertEquals(1, e.getBeginA());
+ assertEquals(1, e.getEndA());
+ assertEquals(3, e.getBeginB());
+ assertEquals(3, e.getEndB());
+ }
+
+ public void testSwap() {
+ final Edit e = new Edit(1, 2, 3, 4);
+ e.swap();
+ assertEquals(3, e.getBeginA());
+ assertEquals(4, e.getEndA());
+ assertEquals(1, e.getBeginB());
+ assertEquals(2, e.getEndB());
+ }
+
+ public void testType_Insert() {
+ final Edit e = new Edit(1, 1, 1, 2);
+ assertSame(Edit.Type.INSERT, e.getType());
+ }
+
+ public void testType_Delete() {
+ final Edit e = new Edit(1, 2, 1, 1);
+ assertSame(Edit.Type.DELETE, e.getType());
+ }
+
+ public void testType_Replace() {
+ final Edit e = new Edit(1, 2, 1, 4);
+ assertSame(Edit.Type.REPLACE, e.getType());
+ }
+
+ public void testType_Empty() {
+ assertSame(Edit.Type.EMPTY, new Edit(1, 1, 2, 2).getType());
+ assertSame(Edit.Type.EMPTY, new Edit(1, 2).getType());
+ }
+
+ public void testToString() {
+ final Edit e = new Edit(1, 2, 1, 4);
+ assertEquals("REPLACE(1-2,1-4)", e.toString());
+ }
+
+ public void testEquals1() {
+ final Edit e1 = new Edit(1, 2, 3, 4);
+ final Edit e2 = new Edit(1, 2, 3, 4);
+
+ assertTrue(e1.equals(e1));
+ assertTrue(e1.equals(e2));
+ assertTrue(e2.equals(e1));
+ assertEquals(e1.hashCode(), e2.hashCode());
+ assertFalse(e1.equals(""));
+ }
+
+ public void testNotEquals1() {
+ assertFalse(new Edit(1, 2, 3, 4).equals(new Edit(0, 2, 3, 4)));
+ }
+
+ public void testNotEquals2() {
+ assertFalse(new Edit(1, 2, 3, 4).equals(new Edit(1, 0, 3, 4)));
+ }
+
+ public void testNotEquals3() {
+ assertFalse(new Edit(1, 2, 3, 4).equals(new Edit(1, 2, 0, 4)));
+ }
+
+ public void testNotEquals4() {
+ assertFalse(new Edit(1, 2, 3, 4).equals(new Edit(1, 2, 3, 0)));
+ }
+
+ public void testExtendA() {
+ final Edit e = new Edit(1, 2, 1, 1);
+
+ e.extendA();
+ assertEquals(new Edit(1, 3, 1, 1), e);
+
+ e.extendA();
+ assertEquals(new Edit(1, 4, 1, 1), e);
+ }
+
+ public void testExtendB() {
+ final Edit e = new Edit(1, 2, 1, 1);
+
+ e.extendB();
+ assertEquals(new Edit(1, 2, 1, 2), e);
+
+ e.extendB();
+ assertEquals(new Edit(1, 2, 1, 3), e);
+ }
+}
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/diff/RawTextTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/diff/RawTextTest.java
new file mode 100644
index 0000000000..5cb8bc3945
--- /dev/null
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/diff/RawTextTest.java
@@ -0,0 +1,100 @@
+/*
+ * Copyright (C) 2009, Google Inc.
+ * Copyright (C) 2009, Johannes E. Schindelin <johannes.schindelin@gmx.de>
+ * and other copyright owners as documented in the project's IP log.
+ *
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Distribution License v1.0 which
+ * accompanies this distribution, is reproduced below, and is
+ * available at http://www.eclipse.org/org/documents/edl-v10.php
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ *
+ * - Neither the name of the Eclipse Foundation, Inc. nor the
+ * names of its contributors may be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package org.eclipse.jgit.diff;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.eclipse.jgit.lib.Constants;
+import org.eclipse.jgit.util.RawParseUtils;
+
+public class RawTextTest extends TestCase {
+ public void testEmpty() {
+ final RawText r = new RawText(new byte[0]);
+ assertEquals(0, r.size());
+ }
+
+ public void testEquals() {
+ final RawText a = new RawText(Constants.encodeASCII("foo-a\nfoo-b\n"));
+ final RawText b = new RawText(Constants.encodeASCII("foo-b\nfoo-c\n"));
+
+ assertEquals(2, a.size());
+ assertEquals(2, b.size());
+
+ // foo-a != foo-b
+ assertFalse(a.equals(0, b, 0));
+ assertFalse(b.equals(0, a, 0));
+
+ // foo-b == foo-b
+ assertTrue(a.equals(1, b, 0));
+ assertTrue(b.equals(0, a, 1));
+ }
+
+ public void testWriteLine1() throws IOException {
+ final RawText a = new RawText(Constants.encodeASCII("foo-a\nfoo-b\n"));
+ final ByteArrayOutputStream o = new ByteArrayOutputStream();
+ a.writeLine(o, 0);
+ final byte[] r = o.toByteArray();
+ assertEquals("foo-a", RawParseUtils.decode(r));
+ }
+
+ public void testWriteLine2() throws IOException {
+ final RawText a = new RawText(Constants.encodeASCII("foo-a\nfoo-b"));
+ final ByteArrayOutputStream o = new ByteArrayOutputStream();
+ a.writeLine(o, 1);
+ final byte[] r = o.toByteArray();
+ assertEquals("foo-b", RawParseUtils.decode(r));
+ }
+
+ public void testWriteLine3() throws IOException {
+ final RawText a = new RawText(Constants.encodeASCII("a\n\nb\n"));
+ final ByteArrayOutputStream o = new ByteArrayOutputStream();
+ a.writeLine(o, 1);
+ final byte[] r = o.toByteArray();
+ assertEquals("", RawParseUtils.decode(r));
+ }
+}