commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jua...@apache.org
Subject cvs commit: jakarta-commons-sandbox/jrcs/src/test/org/apache/commons/jrcs/diff DiffTest.java
Date Wed, 07 May 2003 06:34:01 GMT
juanco      2003/05/06 23:34:01

  Modified:    jrcs/src/java/org/apache/commons/jrcs/diff Diff.java
               jrcs/src/test/org/apache/commons/jrcs/diff DiffTest.java
  Log:
  added tests for large edits, and made SimpleDiff be again the default algorithm as it is
fast and consumes little memory, despite producing suboptimal results
  
  Revision  Changes    Path
  1.13      +3 -3      jakarta-commons-sandbox/jrcs/src/java/org/apache/commons/jrcs/diff/Diff.java
  
  Index: Diff.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jrcs/src/java/org/apache/commons/jrcs/diff/Diff.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- Diff.java	7 May 2003 06:11:19 -0000	1.12
  +++ Diff.java	7 May 2003 06:34:00 -0000	1.13
  @@ -144,7 +144,7 @@
   
       protected DiffAlgorithm defaultAlgorithm()
       {
  -        return new MyersDiff();
  +        return new SimpleDiff();
       }
   
       /**
  @@ -314,7 +314,7 @@
           Random r = new Random(seed);
           for(int i = 0; i < result.length; i++)
           {
  -            result[i] = new Integer(r.nextInt());
  +            result[i] = new Integer(r.nextInt(size));
           }
           return result;
       }
  
  
  
  1.9       +19 -2     jakarta-commons-sandbox/jrcs/src/test/org/apache/commons/jrcs/diff/DiffTest.java
  
  Index: DiffTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jrcs/src/test/org/apache/commons/jrcs/diff/DiffTest.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- DiffTest.java	7 May 2003 06:11:20 -0000	1.8
  +++ DiffTest.java	7 May 2003 06:34:00 -0000	1.9
  @@ -62,6 +62,7 @@
   public class DiffTest
       extends TestCase
   {
  +    static final int LARGE=4*1024;
   
       public DiffTest(String testName)
       {
  @@ -360,8 +361,8 @@
       public void testLargeShuffles()
           throws DifferentiationFailedException, PatchFailedException
       {
  -        Object[] orig = Diff.randomSequence(1024);
  -        for (int seed = 0; seed < 2; seed++)
  +        Object[] orig = Diff.randomSequence(LARGE);
  +        for (int seed = 0; seed < 8; seed++)
           {
               Object[] rev = Diff.shuffle(orig);
               Revision revision = Diff.diff(orig, rev);
  @@ -371,6 +372,22 @@
                   fail("iter " + seed + " revisions differ after patch");
               }
               orig = rev;
  +        }
  +    }
  +
  +    public void testLargeShuffleEdits()
  +        throws DifferentiationFailedException, PatchFailedException
  +    {
  +        Object[] orig = Diff.randomSequence(LARGE);
  +        for (int seed = 0; seed < 8; seed++)
  +        {
  +            Object[] rev = Diff.randomEdit(orig, seed);
  +            Revision revision = Diff.diff(orig, rev);
  +            Object[] patched = revision.patch(orig);
  +            if (!Diff.compare(patched, rev))
  +            {
  +                fail("iter " + seed + " revisions differ after patch");
  +            }
           }
       }
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message