xmlgraphics-batik-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hill...@apache.org
Subject cvs commit: xml-batik/test-sources/org/apache/batik/parser PathParserTest.java
Date Thu, 08 Nov 2001 15:05:20 GMT
hillion     01/11/08 07:05:20

  Modified:    test-resources/org/apache/batik/test regard.xml
  Added:       test-resources/org/apache/batik/parser unitTesting.xml
               test-sources/org/apache/batik/parser PathParserTest.java
  Log:
  Commited tests for the path parser.
  
  Revision  Changes    Path
  1.1                  xml-batik/test-resources/org/apache/batik/parser/unitTesting.xml
  
  Index: unitTesting.xml
  ===================================================================
  <!-- ========================================================================= -->
  <!-- Copyright (C) The Apache Software Foundation. All rights reserved.        -->
  <!--                                                                           -->
  <!-- This software is published under the terms of the Apache Software License -->
  <!-- version 1.1, a copy of which has been included with this distribution in  -->
  <!-- the LICENSE file.                                                         -->
  <!-- ========================================================================= -->
  
  <!-- ========================================================================= -->
  <!-- @author stephane@hillion.org                                              -->
  <!-- @version $Id: unitTesting.xml,v 1.1 2001/11/08 15:05:20 hillion Exp $  -->
  <!-- ========================================================================= -->
  <testSuite id="parser.unitTesting" name="org.apache.batik.parser package - Unit Testing">
  
      <!-- ========================================================================== -->
      <!-- PathParser tests                                                           -->
      <!-- ========================================================================== -->
  
      <test id="pathParser1" class="org.apache.batik.parser.PathParserTest" >
          <arg class="java.lang.String" value="M1 2" />
          <arg class="java.lang.String" value="M1.0 2.0" />
      </test>
  
      <test id="pathParser2" class="org.apache.batik.parser.PathParserTest" >
          <arg class="java.lang.String" value="m1.1 2.0" />
          <arg class="java.lang.String" value="m1.1 2.0" />
      </test>
  
      <test id="pathParser3" class="org.apache.batik.parser.PathParserTest" >
          <arg class="java.lang.String" value="M1 2z" />
          <arg class="java.lang.String" value="M1.0 2.0Z" />
      </test>
  
      <test id="pathParser4" class="org.apache.batik.parser.PathParserTest" >
          <arg class="java.lang.String" value="M1 2e3Z" />
          <arg class="java.lang.String" value="M1.0 2000.0Z" />
      </test>
  
      <test id="pathParser5" class="org.apache.batik.parser.PathParserTest" >
          <arg class="java.lang.String" value="M1 2L 3,4" />
          <arg class="java.lang.String" value="M1.0 2.0L3.0 4.0" />
      </test>
  
      <test id="pathParser6" class="org.apache.batik.parser.PathParserTest" >
          <arg class="java.lang.String" value="M1 2H3.1" />
          <arg class="java.lang.String" value="M1.0 2.0H3.1" />
      </test>
  
      <test id="pathParser7" class="org.apache.batik.parser.PathParserTest" >
          <arg class="java.lang.String" value="M1 2h 3.1" />
          <arg class="java.lang.String" value="M1.0 2.0h3.1" />
      </test>
  
      <test id="pathParser8" class="org.apache.batik.parser.PathParserTest" >
          <arg class="java.lang.String" value="M1 2H 3.1,4" />
          <arg class="java.lang.String" value="M1.0 2.0H3.1H4.0" />
      </test>
  
      <test id="pathParser9" class="org.apache.batik.parser.PathParserTest" >
          <arg class="java.lang.String" value="M1 2h 3.1-4" />
          <arg class="java.lang.String" value="M1.0 2.0h3.1h-4.0" />
      </test>
  
      <test id="pathParser10" class="org.apache.batik.parser.PathParserTest" >
          <arg class="java.lang.String" value="M1 2V3.1e-3" />
          <arg class="java.lang.String" value="M1.0 2.0V0.0031" />
      </test>
  
      <test id="pathParser11" class="org.apache.batik.parser.PathParserTest" >
          <arg class="java.lang.String" value="M1 2V3.1" />
          <arg class="java.lang.String" value="M1.0 2.0V3.1" />
      </test>
  
      <test id="pathParser12" class="org.apache.batik.parser.PathParserTest" >
          <arg class="java.lang.String" value="M1 2v3.1,.4" />
          <arg class="java.lang.String" value="M1.0 2.0v3.1v0.4" />
      </test>
  
      <test id="pathParser13" class="org.apache.batik.parser.PathParserTest" >
          <arg class="java.lang.String" value="M1 2v3.1-.4" />
          <arg class="java.lang.String" value="M1.0 2.0v3.1v-0.4" />
      </test>
  
      <test id="pathParser14" class="org.apache.batik.parser.PathParserTest" >
          <arg class="java.lang.String" value="M1 2C3 4 5 6 7 8" />
          <arg class="java.lang.String" value="M1.0 2.0C3.0 4.0 5.0 6.0 7.0 8.0" />
      </test>
  
      <test id="pathParser15" class="org.apache.batik.parser.PathParserTest" >
          <arg class="java.lang.String" value="M1 2c.3.4.5.6.7.8" />
          <arg class="java.lang.String" value="M1.0 2.0c0.3 0.4 0.5 0.6 0.7 0.8" />
      </test>
  
      <test id="pathParser16" class="org.apache.batik.parser.PathParserTest" >
          <arg class="java.lang.String" value="M1 2S3+4+5+6" />
          <arg class="java.lang.String" value="M1.0 2.0S3.0 4.0 5.0 6.0" />
      </test>
  
      <test id="pathParser17" class="org.apache.batik.parser.PathParserTest" >
          <arg class="java.lang.String" value="M1 2s.3+.4+.5-.6" />
          <arg class="java.lang.String" value="M1.0 2.0s0.3 0.4 0.5 -0.6" />
      </test>
  
      <test id="pathParser18" class="org.apache.batik.parser.PathParserTest" >
          <arg class="java.lang.String" value="M1 2q3. 4.+5 6" />
          <arg class="java.lang.String" value="M1.0 2.0q3.0 4.0 5.0 6.0" />
      </test>
  
      <test id="pathParser19" class="org.apache.batik.parser.PathParserTest" >
          <arg class="java.lang.String" value="M1 2Q.3e0.4.5.6" />
          <arg class="java.lang.String" value="M1.0 2.0Q0.3 0.4 0.5 0.6" />
      </test>
  
      <test id="pathParser20" class="org.apache.batik.parser.PathParserTest" >
          <arg class="java.lang.String" value="M1 2t+.3-.4" />
          <arg class="java.lang.String" value="M1.0 2.0t0.3 -0.4" />
      </test>
  
      <test id="pathParser21" class="org.apache.batik.parser.PathParserTest" >
          <arg class="java.lang.String" value="M1 2T -.3+4" />
          <arg class="java.lang.String" value="M1.0 2.0T-0.3 4.0" />
      </test>
  
      <test id="pathParser22" class="org.apache.batik.parser.PathParserTest" >
          <arg class="java.lang.String" value="M1 2a3 4 5 0,1 6 7" />
          <arg class="java.lang.String" value="M1.0 2.0a3.0 4.0 5.0 0 1 6.0 7.0" />
      </test>
  
      <test id="pathParser23" class="org.apache.batik.parser.PathParserTest" >
          <arg class="java.lang.String" value="M1 2A3 4 5 0,1 6 7" />
          <arg class="java.lang.String" value="M1.0 2.0A3.0 4.0 5.0 0 1 6.0 7.0" />
      </test>
  
      <test id="pathParser24" class="org.apache.batik.parser.PathParserTest" >
          <arg class="java.lang.String" value="M1 2t+.3-.4,5,6" />
          <arg class="java.lang.String" value="M1.0 2.0t0.3 -0.4t5.0 6.0" />
      </test>
  
      <test id="pathParser25" class="org.apache.batik.parser.PathParserTest" >
          <arg class="java.lang.String" value="M1 2T -.3+4 5-6" />
          <arg class="java.lang.String" value="M1.0 2.0T-0.3 4.0T5.0 -6.0" />
      </test>
  
  </testSuite>
  
  
  
  1.17      +2 -1      xml-batik/test-resources/org/apache/batik/test/regard.xml
  
  Index: regard.xml
  ===================================================================
  RCS file: /home/cvs/xml-batik/test-resources/org/apache/batik/test/regard.xml,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- regard.xml	2001/10/30 14:15:33	1.16
  +++ regard.xml	2001/11/08 15:05:20	1.17
  @@ -11,7 +11,7 @@
   <!-- regression testing.                                                       -->
   <!--                                                                           -->
   <!-- @author vincent.hardy@eng.sun.com                                         -->
  -<!-- @version $Id: regard.xml,v 1.16 2001/10/30 14:15:33 tkormann Exp $  -->
  +<!-- @version $Id: regard.xml,v 1.17 2001/11/08 15:05:20 hillion Exp $  -->
   <!-- ========================================================================= -->
   <testRun id="regard" name="Batik Standard Regression Test Run">
       <testReportProcessor class="org.apache.batik.test.xml.XMLTestReportProcessor" >

  @@ -55,6 +55,7 @@
       <testSuite href="file:test-resources/org/apache/batik/util/unitTesting.xml" />
       <testSuite href="file:test-resources/org/apache/batik/dom/unitTesting.xml" />

       <testSuite href="file:test-resources/org/apache/batik/gvt/unitTesting.xml" />

  +    <testSuite href="file:test-resources/org/apache/batik/parser/unitTesting.xml" />

       <testSuite href="file:test-resources/org/apache/batik/transcoder/image/unitTesting.xml"
/> 
   
   </testRun>
  
  
  
  1.1                  xml-batik/test-sources/org/apache/batik/parser/PathParserTest.java
  
  Index: PathParserTest.java
  ===================================================================
  /*****************************************************************************
   * Copyright (C) The Apache Software Foundation. All rights reserved.        *
   * ------------------------------------------------------------------------- *
   * This software is published under the terms of the Apache Software License *
   * version 1.1, a copy of which has been included with this distribution in  *
   * the LICENSE file.                                                         *
   *****************************************************************************/
  
  package org.apache.batik.parser;
  
  import java.io.*;
  
  import org.apache.batik.test.*;
  
  /**
   * To test the path parser.
   *
   * @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
   * @version $Id: PathParserTest.java,v 1.1 2001/11/08 15:05:20 hillion Exp $
   */
  public class PathParserTest extends AbstractTest {
  
      protected String sourcePath;
      protected String destinationPath;
  
      protected StringBuffer buffer;
      protected String resultPath;
  
      /**
       * Creates a new PathParserTest.
       * @param spath The path to parse.
       * @param dpath The path after serialization.
       */
      public PathParserTest(String spath, String dpath) {
          sourcePath = spath;
          destinationPath = dpath;
      }
  
      public TestReport runImpl() throws Exception {
          PathParser pp = new PathParser();
          pp.setPathHandler(new TestHandler());
  
          try {
              pp.parse(new StringReader(sourcePath));
          } catch (ParseException e) {
              DefaultTestReport report = new DefaultTestReport(this);
              report.setErrorCode("parse.error");
              report.addDescriptionEntry("exception.text", e.getMessage());
              report.setPassed(false);
              return report;
          }
  
          if (!destinationPath.equals(resultPath)) {
              DefaultTestReport report = new DefaultTestReport(this);
              report.setErrorCode("invalid.parsing.events");
              report.addDescriptionEntry("expected.text", destinationPath);
              report.addDescriptionEntry("generated.text", resultPath);
              report.setPassed(false);
              return report;
          }
  
          return reportSuccess();
      }
  
      class TestHandler extends DefaultPathHandler {
          public TestHandler() {}
  
          public void startPath() throws ParseException {
              buffer = new StringBuffer();
          }
          
          public void movetoRel(float x, float y) throws ParseException {
              buffer.append('m');
              buffer.append(x);
              buffer.append(' ');
              buffer.append(y);
          }
  
          public void movetoAbs(float x, float y) throws ParseException {
              buffer.append('M');
              buffer.append(x);
              buffer.append(' ');
              buffer.append(y);
          }
  
          public void endPath() throws ParseException {
              resultPath = buffer.toString();
          }
  
          public void closePath() throws ParseException {
              buffer.append('Z');
          }
  
          public void linetoRel(float x, float y) throws ParseException {
              buffer.append('l');
              buffer.append(x);
              buffer.append(' ');
              buffer.append(y);
          }
  
          public void linetoAbs(float x, float y) throws ParseException {
              buffer.append('L');
              buffer.append(x);
              buffer.append(' ');
              buffer.append(y);
          }
  
          public void linetoHorizontalRel(float x) throws ParseException {
              buffer.append('h');
              buffer.append(x);
          }
  
          public void linetoHorizontalAbs(float x) throws ParseException {
              buffer.append('H');
              buffer.append(x);
          }
  
          public void linetoVerticalRel(float y) throws ParseException {
              buffer.append('v');
              buffer.append(y);
          }
  
          public void linetoVerticalAbs(float y) throws ParseException {
              buffer.append('V');
              buffer.append(y);
          }
  
          public void curvetoCubicRel(float x1, float y1, 
                                      float x2, float y2, 
                                      float x, float y) throws ParseException {
              buffer.append('c');
              buffer.append(x1);
              buffer.append(' ');
              buffer.append(y1);
              buffer.append(' ');
              buffer.append(x2);
              buffer.append(' ');
              buffer.append(y2);
              buffer.append(' ');
              buffer.append(x);
              buffer.append(' ');
              buffer.append(y);
          }
  
          public void curvetoCubicAbs(float x1, float y1, 
                                      float x2, float y2, 
                                      float x, float y) throws ParseException {
              buffer.append('C');
              buffer.append(x1);
              buffer.append(' ');
              buffer.append(y1);
              buffer.append(' ');
              buffer.append(x2);
              buffer.append(' ');
              buffer.append(y2);
              buffer.append(' ');
              buffer.append(x);
              buffer.append(' ');
              buffer.append(y);
          }
  
          public void curvetoCubicSmoothRel(float x2, float y2, 
                                            float x, float y) throws ParseException {
              buffer.append('s');
              buffer.append(x2);
              buffer.append(' ');
              buffer.append(y2);
              buffer.append(' ');
              buffer.append(x);
              buffer.append(' ');
              buffer.append(y);
          }
  
          public void curvetoCubicSmoothAbs(float x2, float y2, 
                                            float x, float y) throws ParseException {
              buffer.append('S');
              buffer.append(x2);
              buffer.append(' ');
              buffer.append(y2);
              buffer.append(' ');
              buffer.append(x);
              buffer.append(' ');
              buffer.append(y);
          }
  
          public void curvetoQuadraticRel(float x1, float y1, 
                                          float x, float y) throws ParseException {
              buffer.append('q');
              buffer.append(x1);
              buffer.append(' ');
              buffer.append(y1);
              buffer.append(' ');
              buffer.append(x);
              buffer.append(' ');
              buffer.append(y);
          }
  
          public void curvetoQuadraticAbs(float x1, float y1, 
                                          float x, float y) throws ParseException {
              buffer.append('Q');
              buffer.append(x1);
              buffer.append(' ');
              buffer.append(y1);
              buffer.append(' ');
              buffer.append(x);
              buffer.append(' ');
              buffer.append(y);
          }
  
          public void curvetoQuadraticSmoothRel(float x, float y)
              throws ParseException {
              buffer.append('t');
              buffer.append(x);
              buffer.append(' ');
              buffer.append(y);
          }
  
          public void curvetoQuadraticSmoothAbs(float x, float y)
              throws ParseException {
              buffer.append('T');
              buffer.append(x);
              buffer.append(' ');
              buffer.append(y);
          }
  
          public void arcRel(float rx, float ry, 
                             float xAxisRotation, 
                             boolean largeArcFlag, boolean sweepFlag, 
                             float x, float y) throws ParseException {
              buffer.append('a');
              buffer.append(rx);
              buffer.append(' ');
              buffer.append(ry);
              buffer.append(' ');
              buffer.append(xAxisRotation);
              buffer.append(' ');
              buffer.append(largeArcFlag ? '1' : '0');
              buffer.append(' ');
              buffer.append(sweepFlag ? '1' : '0');
              buffer.append(' ');
              buffer.append(x);
              buffer.append(' ');
              buffer.append(y);
          }
  
          public void arcAbs(float rx, float ry, 
                             float xAxisRotation, 
                             boolean largeArcFlag, boolean sweepFlag, 
                             float x, float y) throws ParseException {
              buffer.append('A');
              buffer.append(rx);
              buffer.append(' ');
              buffer.append(ry);
              buffer.append(' ');
              buffer.append(xAxisRotation);
              buffer.append(' ');
              buffer.append(largeArcFlag ? '1' : '0');
              buffer.append(' ');
              buffer.append(sweepFlag ? '1' : '0');
              buffer.append(' ');
              buffer.append(x);
              buffer.append(' ');
              buffer.append(y);
          }
      }
  }
  
  
  

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


Mime
View raw message