diff options
author | Robin Rosenberg <robin.rosenberg@dewire.com> | 2013-04-14 19:15:53 +0200 |
---|---|---|
committer | Robin Rosenberg <robin.rosenberg@dewire.com> | 2013-04-14 19:53:48 +0200 |
commit | 4c638be79fde7c34ca0fcaad13d7c4f1d9c5ddd2 (patch) | |
tree | a07f7436c61292b23b25671edfbbbaed71aeaa00 /org.eclipse.jgit.test/tst | |
parent | a6ed390ea79ad0a29265448a1c294e9a1953eb53 (diff) | |
download | jgit-4c638be79fde7c34ca0fcaad13d7c4f1d9c5ddd2.tar.gz jgit-4c638be79fde7c34ca0fcaad13d7c4f1d9c5ddd2.zip |
Fix boundary conditions in AutoCRLFOutputStream
This fixes some problems with inputs around the size of the internal
buffer in AutoCRLFOutputStream (8000).
Tests supplied by Robin Stocker.
Bug: 405672
Change-Id: I6147897290392b3bfd4040e8006da39c302a3d49
Diffstat (limited to 'org.eclipse.jgit.test/tst')
-rw-r--r-- | org.eclipse.jgit.test/tst/org/eclipse/jgit/util/io/AutoCRLFOutputStreamTest.java | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/io/AutoCRLFOutputStreamTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/io/AutoCRLFOutputStreamTest.java index b370468f6b..df175196fd 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/io/AutoCRLFOutputStreamTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/io/AutoCRLFOutputStreamTest.java @@ -1,5 +1,6 @@ /* - * Copyright (C) 2011, Robin Rosenberg + * Copyright (C) 2011, 2013 Robin Rosenberg + * Copyright (C) 2013 Robin Stocker * and other copyright owners as documented in the project's IP log. * * This program and the accompanying materials are made available @@ -67,6 +68,29 @@ public class AutoCRLFOutputStreamTest { assertNoCrLf("\r\n\r\n\r", "\n\r\n\r"); } + @Test + public void testBoundary() throws IOException { + assertBoundaryCorrect(AutoCRLFOutputStream.BUFFER_SIZE - 5); + assertBoundaryCorrect(AutoCRLFOutputStream.BUFFER_SIZE - 4); + assertBoundaryCorrect(AutoCRLFOutputStream.BUFFER_SIZE - 3); + assertBoundaryCorrect(AutoCRLFOutputStream.BUFFER_SIZE - 2); + assertBoundaryCorrect(AutoCRLFOutputStream.BUFFER_SIZE - 1); + assertBoundaryCorrect(AutoCRLFOutputStream.BUFFER_SIZE); + assertBoundaryCorrect(AutoCRLFOutputStream.BUFFER_SIZE + 1); + assertBoundaryCorrect(AutoCRLFOutputStream.BUFFER_SIZE + 2); + assertBoundaryCorrect(AutoCRLFOutputStream.BUFFER_SIZE + 3); + assertBoundaryCorrect(AutoCRLFOutputStream.BUFFER_SIZE + 4); + assertBoundaryCorrect(AutoCRLFOutputStream.BUFFER_SIZE + 5); + } + + private void assertBoundaryCorrect(int size) throws IOException { + StringBuilder sb = new StringBuilder(size); + for (int i = 0; i < size; i++) + sb.append('a'); + String s = sb.toString(); + assertNoCrLf(s, s); + } + private void assertNoCrLf(String string, String string2) throws IOException { assertNoCrLfHelper(string, string2); // \u00e5 = LATIN SMALL LETTER A WITH RING ABOVE |