~ubuntu-branches/debian/squeeze/latexdraw/squeeze

« back to all changes in this revision

Viewing changes to junit/test/svg/TestSVGPathSegCurvetoQuadraticSmooth.java

  • Committer: Bazaar Package Importer
  • Author(s): Stuart Prescott
  • Date: 2009-05-03 23:49:35 UTC
  • Revision ID: james.westby@ubuntu.com-20090503234935-cls7n48x018g0vk2
Tags: upstream-2.0.2+1
ImportĀ upstreamĀ versionĀ 2.0.2+1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
package junit.test.svg;
 
2
 
 
3
import java.text.ParseException;
 
4
 
 
5
import junit.framework.TestCase;
 
6
import latexDraw.parsers.svg.elements.path.SVGPathSeg;
 
7
import latexDraw.parsers.svg.elements.path.SVGPathSegCurvetoQuadraticSmooth;
 
8
import latexDraw.parsers.svg.elements.path.SVGPathSegMoveto;
 
9
import latexDraw.parsers.svg.elements.path.SVGPathSeg.PathSeg;
 
10
import latexDraw.parsers.svg.parsers.SVGPathHandler;
 
11
import latexDraw.parsers.svg.parsers.SVGPathParser;
 
12
 
 
13
import org.junit.Test;
 
14
 
 
15
/** 
 
16
 * This class contains tests for the SVGPathSegCurvetoQuadraticSmooth class.<br>
 
17
 *<br>
 
18
 * This file is part of LaTeXDraw<br>
 
19
 * Copyright (c) 2005-2008 Arnaud BLOUIN<br>
 
20
 *<br>
 
21
 *  LaTeXDraw is free software; you can redistribute it and/or modify
 
22
 *  it under the terms of the GNU General Public License as published by
 
23
 *  the Free Software Foundation; either version 2 of the License, or
 
24
 *  any later version.<br>
 
25
 *<br>
 
26
 *  LaTeXDraw is distributed without any warranty; without even the 
 
27
 *  implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
 
28
 *  PURPOSE. See the GNU General Public License for more details.<br>
 
29
 *<br>
 
30
 * 10/23/07<br>
 
31
 * @author Arnaud BLOUIN<br>
 
32
 * @version 2.0.0<br>
 
33
 */
 
34
@SuppressWarnings("nls")
 
35
public class TestSVGPathSegCurvetoQuadraticSmooth extends TestCase implements SVGPathHandler
 
36
{
 
37
        protected final SVGPathSegCurvetoQuadraticSmooth seg = new SVGPathSegCurvetoQuadraticSmooth(-5.23e-10, 6.5, false);
 
38
        protected int cpt = 0;
 
39
        
 
40
        @Test
 
41
        public void testGetters()
 
42
        {
 
43
                assertEquals(seg.getX(), -5.23e-10);
 
44
                assertEquals(seg.getY(), 6.5);
 
45
                assertFalse(seg.isRelative());
 
46
                assertEquals(seg.getType(), PathSeg.CURVETO_QUADRATIC_SMOOTH_ABS);
 
47
        }
 
48
        
 
49
        
 
50
        @Test
 
51
        public void testToString()
 
52
        {
 
53
                SVGPathSegMoveto m = new SVGPathSegMoveto(0, 0, false);
 
54
                SVGPathParser parser = new SVGPathParser(m.toString() + " " + seg.toString(), this);
 
55
                
 
56
                try { parser.parse(); }
 
57
                catch(ParseException e) { fail(); }
 
58
        }
 
59
 
 
60
 
 
61
        
 
62
        public void onPathSeg(SVGPathSeg pathSeg)
 
63
        {
 
64
                if((pathSeg instanceof SVGPathSegMoveto) && cpt==0)
 
65
                {
 
66
                        cpt++;
 
67
                        return ;
 
68
                }
 
69
                
 
70
                assertTrue(pathSeg instanceof SVGPathSegCurvetoQuadraticSmooth);
 
71
                
 
72
                SVGPathSegCurvetoQuadraticSmooth seg2 = (SVGPathSegCurvetoQuadraticSmooth)pathSeg;              
 
73
                
 
74
                assertEquals(seg.getX(), seg2.getX());
 
75
                assertEquals(seg.getY(), seg2.getY());
 
76
                assertEquals(seg.isRelative(), seg2.isRelative());
 
77
        }
 
78
}