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:11:20 GMT
juanco      2003/05/06 23:11:20

  Modified:    jrcs     jrcs.jpx
               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 shuffles, which strain the memory usage of Myers' algorithm
  
  Revision  Changes    Path
  1.8       +1 -0      jakarta-commons-sandbox/jrcs/jrcs.jpx
  
  Index: jrcs.jpx
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jrcs/jrcs.jpx,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- jrcs.jpx	6 May 2003 19:07:09 -0000	1.7
  +++ jrcs.jpx	7 May 2003 06:11:19 -0000	1.8
  @@ -12,6 +12,7 @@
     <property category="javaFormatting" name="throwsOnNewLine" value="1"/>
     <property category="javaFormatting" name="wrapAtColumn" value="132"/>
     <property category="javadoc" name="custom.tags.1" value="todo;a;To Do:"/>
  +  <property category="optimize.1" name="OptimizableType" value="com.borland.jbuilder.optimize.IntroOptimizeitProfiler"/>
     <property category="runtime" name="ConfigurationCount" value="2"/>
     <property category="runtime.0" name="BuildTargetOnRun" value="com.borland.jbuilder.build.ProjectBuilder$ProjectBuildAction;make"/>
     <property category="runtime.0" name="ConfigurationName" value="AllTests"/>
  
  
  
  1.12      +36 -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.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- Diff.java	6 May 2003 15:05:11 -0000	1.11
  +++ Diff.java	7 May 2003 06:11:19 -0000	1.12
  @@ -100,11 +100,16 @@
   public class Diff
       extends ToString
   {
  -
  +    /** The standard line separator. */
       public static final String NL = System.getProperty("line.separator");
  +
  +    /** The line separator to use in RCS format output. */
       public static final String RCS_EOL = "\n";
   
  -    protected Object[] orig;
  +    /** The original sequence. */
  +    protected final Object[] orig;
  +
  +    /** The differencing algorithm to use. */
       protected DiffAlgorithm algorithm;
   
       /**
  @@ -286,4 +291,32 @@
           Collections.shuffle(result);
           return result.toArray();
       }
  +
  +    /**
  +     * Generate a random sequence of the given size.
  +     * @param The size of the sequence to generate.
  +     * @return The generated sequence.
  +     */
  +    public static Object[] randomSequence(int size)
  +    {
  +        return randomSequence(size, size);
  +    }
  +
  +    /**
  +     * Generate a random sequence of the given size.
  +     * @param The size of the sequence to generate.
  +     * @param seed A seed value for randomizing the generation.
  +     * @return The generated sequence.
  +     */
  +    public static Object[] randomSequence(int size, long seed)
  +    {
  +        Integer[] result = new Integer[size];
  +        Random r = new Random(seed);
  +        for(int i = 0; i < result.length; i++)
  +        {
  +            result[i] = new Integer(r.nextInt());
  +        }
  +        return result;
  +    }
  +
   }
  
  
  
  1.8       +17 -0     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.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- DiffTest.java	6 May 2003 19:07:14 -0000	1.7
  +++ DiffTest.java	7 May 2003 06:11:20 -0000	1.8
  @@ -356,4 +356,21 @@
                        "[8] eight revised" + Diff.NL,
                        revision.toRCSString());
       }
  +
  +    public void testLargeShuffles()
  +        throws DifferentiationFailedException, PatchFailedException
  +    {
  +        Object[] orig = Diff.randomSequence(1024);
  +        for (int seed = 0; seed < 2; seed++)
  +        {
  +            Object[] rev = Diff.shuffle(orig);
  +            Revision revision = Diff.diff(orig, rev);
  +            Object[] patched = revision.patch(orig);
  +            if (!Diff.compare(patched, rev))
  +            {
  +                fail("iter " + seed + " revisions differ after patch");
  +            }
  +            orig = rev;
  +        }
  +    }
   }
  
  
  

---------------------------------------------------------------------
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