From: "Shawn O. Pearce" <spearce@spearce.org>
To: Robin Rosenberg <robin.rosenberg@dewire.com>
Cc: git@vger.kernel.org
Subject: [JGIT PATCH 4/5] Increase JUnit coverage on CanonicalTreeParser
Date: Thu, 28 Aug 2008 08:27:45 -0700 [thread overview]
Message-ID: <1219937266-24903-4-git-send-email-spearce@spearce.org> (raw)
In-Reply-To: <1219937266-24903-3-git-send-email-spearce@spearce.org>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
---
.../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
next prev parent reply other threads:[~2008-08-28 15:29 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-08-28 15:27 [JGIT PATCH 1/5] JUnit test for EmptyTreeIterator Shawn O. Pearce
2008-08-28 15:27 ` [JGIT PATCH 2/5] JUnit tests for some TreeFilter implementations Shawn O. Pearce
2008-08-28 15:27 ` [JGIT PATCH 3/5] JUnit test for FileTreeIterator, WorkingTreeIterator Shawn O. Pearce
2008-08-28 15:27 ` Shawn O. Pearce [this message]
2008-08-28 15:27 ` [JGIT PATCH 5/5] Restore IContainer.INCLUDE_HIDDEN within ContainerTreeIterator Shawn O. Pearce
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1219937266-24903-4-git-send-email-spearce@spearce.org \
--to=spearce@spearce.org \
--cc=git@vger.kernel.org \
--cc=robin.rosenberg@dewire.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).