diff options
author | Shawn O. Pearce <spearce@spearce.org> | 2010-09-21 14:47:33 -0700 |
---|---|---|
committer | Shawn O. Pearce <spearce@spearce.org> | 2010-09-24 19:09:51 -0700 |
commit | e7a3e590edabee731e68d5f19d8af14d7b9a83e4 (patch) | |
tree | 015d8b7517df6cc575063c0d1ddc88cc013f76b7 /org.eclipse.jgit.test/tst/org/eclipse/jgit/diff | |
parent | 9bcf391355ce8772e934a8e865e148525f8a0cbd (diff) | |
download | jgit-e7a3e590edabee731e68d5f19d8af14d7b9a83e4.tar.gz jgit-e7a3e590edabee731e68d5f19d8af14d7b9a83e4.zip |
Reuse DiffPerformanceTest support code to validate algorithms
Each algorithm should produce a particular number of results
given one of the standard inputs used during the performance
tests. To help ensure those tests are accurate, assert that
the edit list length is correct.
Change-Id: I292f8fde0cec6a60a75ce09e70814a00ca47cb99
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/DiffPerformanceTest.java (renamed from org.eclipse.jgit.test/tst/org/eclipse/jgit/diff/MyersDiffPerformanceTest.java) | 6 | ||||
-rw-r--r-- | org.eclipse.jgit.test/tst/org/eclipse/jgit/diff/MyersDiffTest.java | 12 | ||||
-rw-r--r-- | org.eclipse.jgit.test/tst/org/eclipse/jgit/diff/PatienceDiffTest.java | 28 |
3 files changed, 18 insertions, 28 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/diff/MyersDiffPerformanceTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/diff/DiffPerformanceTest.java index a3f9c22e31..17c586f1e0 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/diff/MyersDiffPerformanceTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/diff/DiffPerformanceTest.java @@ -62,7 +62,7 @@ import org.eclipse.jgit.util.CPUTimeStopWatch; * diffs between chunks of different length, measure the needed time and check * that time/(N*D) does not differ more than a certain factor. */ -public class MyersDiffPerformanceTest extends TestCase { +public class DiffPerformanceTest extends TestCase { private static final long longTaskBoundary = 5000000000L; private static final int minCPUTimerTicks = 10; @@ -186,7 +186,7 @@ public class MyersDiffPerformanceTest extends TestCase { return ret; } - private static class CharArray extends Sequence { + static class CharArray extends Sequence { final char[] array; public CharArray(String s) { @@ -199,7 +199,7 @@ public class MyersDiffPerformanceTest extends TestCase { } } - private static class CharCmp extends SequenceComparator<CharArray> { + static class CharCmp extends SequenceComparator<CharArray> { @Override public boolean equals(CharArray a, int ai, CharArray b, int bi) { return a.array[ai] == b.array[bi]; diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/diff/MyersDiffTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/diff/MyersDiffTest.java index 4df2c5a407..896b0fbccb 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/diff/MyersDiffTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/diff/MyersDiffTest.java @@ -43,9 +43,21 @@ package org.eclipse.jgit.diff; +import org.eclipse.jgit.diff.DiffPerformanceTest.CharArray; +import org.eclipse.jgit.diff.DiffPerformanceTest.CharCmp; + public class MyersDiffTest extends AbstractDiffTestCase { @Override protected DiffAlgorithm algorithm() { return MyersDiff.INSTANCE; } + + public void testPerformanceTestDeltaLength() { + String a = DiffTestDataGenerator.generateSequence(40000, 971, 3); + String b = DiffTestDataGenerator.generateSequence(40000, 1621, 5); + CharArray ac = new CharArray(a); + CharArray bc = new CharArray(b); + EditList r = algorithm().diff(new CharCmp(), ac, bc); + assertEquals(131, r.size()); + } } diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/diff/PatienceDiffTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/diff/PatienceDiffTest.java index 67a4904c6d..de88c2f878 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/diff/PatienceDiffTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/diff/PatienceDiffTest.java @@ -43,6 +43,9 @@ package org.eclipse.jgit.diff; +import org.eclipse.jgit.diff.DiffPerformanceTest.CharArray; +import org.eclipse.jgit.diff.DiffPerformanceTest.CharCmp; + public class PatienceDiffTest extends AbstractDiffTestCase { @Override protected DiffAlgorithm algorithm() { @@ -71,29 +74,4 @@ public class PatienceDiffTest extends AbstractDiffTestCase { EditList r = algorithm().diff(new CharCmp(), ac, bc); assertEquals(25, r.size()); } - - private static class CharArray extends Sequence { - final char[] array; - - public CharArray(String s) { - array = s.toCharArray(); - } - - @Override - public int size() { - return array.length; - } - } - - private static class CharCmp extends SequenceComparator<CharArray> { - @Override - public boolean equals(CharArray a, int ai, CharArray b, int bi) { - return a.array[ai] == b.array[bi]; - } - - @Override - public int hash(CharArray seq, int ptr) { - return seq.array[ptr]; - } - } } |