[JGIT PATCH 4/5] Increase JUnit coverage on CanonicalTreeParser

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Shawn O. Pearce <spearce@xxxxxxxxxxx>
---
 .../jgit/treewalk/CanonicalTreeParserTest.java     |   18 ++++++++++++++++++
 .../jgit/treewalk/AbstractTreeIterator.java        |    2 +-
 2 files changed, 19 insertions(+), 1 deletions(-)

diff --git a/org.spearce.jgit.test/tst/org/spearce/jgit/treewalk/CanonicalTreeParserTest.java b/org.spearce.jgit.test/tst/org/spearce/jgit/treewalk/CanonicalTreeParserTest.java
index fd92844..ed3478c 100644
--- a/org.spearce.jgit.test/tst/org/spearce/jgit/treewalk/CanonicalTreeParserTest.java
+++ b/org.spearce.jgit.test/tst/org/spearce/jgit/treewalk/CanonicalTreeParserTest.java
@@ -108,18 +108,21 @@ public void testEmptyTree_AtEOF() throws Exception {
 	public void testOneEntry_Forward() throws Exception {
 		ctp.reset(tree1);
 
+		assertTrue(ctp.first());
 		assertFalse(ctp.eof());
 		assertEquals(m644.getBits(), ctp.mode);
 		assertEquals("a", path());
 		assertEquals(hash_a, ctp.getEntryObjectId());
 
 		ctp.next(1);
+		assertFalse(ctp.first());
 		assertTrue(ctp.eof());
 	}
 
 	public void testTwoEntries_ForwardOneAtATime() throws Exception {
 		ctp.reset(tree2);
 
+		assertTrue(ctp.first());
 		assertFalse(ctp.eof());
 		assertEquals(m644.getBits(), ctp.mode);
 		assertEquals("a", path());
@@ -132,6 +135,7 @@ public void testTwoEntries_ForwardOneAtATime() throws Exception {
 		assertEquals(hash_foo, ctp.getEntryObjectId());
 
 		ctp.next(1);
+		assertFalse(ctp.first());
 		assertTrue(ctp.eof());
 	}
 
@@ -170,9 +174,11 @@ public void testThreeEntries_Seek2() throws Exception {
 	public void testOneEntry_Backwards() throws Exception {
 		ctp.reset(tree1);
 		ctp.next(1);
+		assertFalse(ctp.first());
 		assertTrue(ctp.eof());
 
 		ctp.back(1);
+		assertTrue(ctp.first());
 		assertFalse(ctp.eof());
 		assertEquals(m644.getBits(), ctp.mode);
 		assertEquals("a", path());
@@ -258,4 +264,16 @@ public void testBackwards_ConfusingPathName() throws Exception {
 		assertEquals("a", path());
 		assertEquals(hash_a, ctp.getEntryObjectId());
 	}
+
+	public void testFreakingHugePathName() throws Exception {
+		final int n = AbstractTreeIterator.DEFAULT_PATH_SIZE * 4;
+		final StringBuilder b = new StringBuilder(n);
+		for (int i = 0; i < n; i++)
+			b.append('q');
+		final String name = b.toString();
+		ctp.reset(entry(m644, name, hash_a));
+		assertFalse(ctp.eof());
+		assertEquals(name, RawParseUtils.decode(Constants.CHARSET, ctp.path,
+				ctp.pathOffset, ctp.pathLen));
+	}
 }
diff --git a/org.spearce.jgit/src/org/spearce/jgit/treewalk/AbstractTreeIterator.java b/org.spearce.jgit/src/org/spearce/jgit/treewalk/AbstractTreeIterator.java
index 3227fab..5226ab6 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/treewalk/AbstractTreeIterator.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/treewalk/AbstractTreeIterator.java
@@ -71,7 +71,7 @@
  * @see CanonicalTreeParser
  */
 public abstract class AbstractTreeIterator {
-	private static final int DEFAULT_PATH_SIZE = 128;
+	static final int DEFAULT_PATH_SIZE = 128;
 
 	/** A dummy object id buffer that matches the zero ObjectId. */
 	protected static final byte[] zeroid = new byte[Constants.OBJECT_ID_LENGTH];
-- 
1.6.0.174.gd789c

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux