|
| 1 | +/* |
| 2 | + This file is part of the iText (R) project. |
| 3 | + Copyright (c) 1998-2018 iText Group NV |
| 4 | + Authors: iText Software. |
| 5 | +
|
| 6 | + This program is free software; you can redistribute it and/or modify |
| 7 | + it under the terms of the GNU Affero General Public License version 3 |
| 8 | + as published by the Free Software Foundation with the addition of the |
| 9 | + following permission added to Section 15 as permitted in Section 7(a): |
| 10 | + FOR ANY PART OF THE COVERED WORK IN WHICH THE COPYRIGHT IS OWNED BY |
| 11 | + ITEXT GROUP. ITEXT GROUP DISCLAIMS THE WARRANTY OF NON INFRINGEMENT |
| 12 | + OF THIRD PARTY RIGHTS |
| 13 | +
|
| 14 | + This program is distributed in the hope that it will be useful, but |
| 15 | + WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
| 16 | + or FITNESS FOR A PARTICULAR PURPOSE. |
| 17 | + See the GNU Affero General Public License for more details. |
| 18 | + You should have received a copy of the GNU Affero General Public License |
| 19 | + along with this program; if not, see http://www.gnu.org/licenses or write to |
| 20 | + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 21 | + Boston, MA, 02110-1301 USA, or download the license from the following URL: |
| 22 | + http://itextpdf.com/terms-of-use/ |
| 23 | +
|
| 24 | + The interactive user interfaces in modified source and object code versions |
| 25 | + of this program must display Appropriate Legal Notices, as required under |
| 26 | + Section 5 of the GNU Affero General Public License. |
| 27 | +
|
| 28 | + In accordance with Section 7(b) of the GNU Affero General Public License, |
| 29 | + a covered work must retain the producer line in every PDF that is created |
| 30 | + or manipulated using iText. |
| 31 | +
|
| 32 | + You can be released from the requirements of the license by purchasing |
| 33 | + a commercial license. Buying such a license is mandatory as soon as you |
| 34 | + develop commercial activities involving the iText software without |
| 35 | + disclosing the source code of your own applications. |
| 36 | + These activities include: offering paid services to customers as an ASP, |
| 37 | + serving PDFs on the fly in a web application, shipping iText with a closed |
| 38 | + source product. |
| 39 | +
|
| 40 | + For more information, please contact iText Software Corp. at this |
| 41 | + |
| 42 | + */ |
| 43 | +package com.itextpdf.svg.renderers.impl; |
| 44 | + |
| 45 | + |
| 46 | +import com.itextpdf.svg.exceptions.SvgProcessingException; |
| 47 | +import com.itextpdf.svg.renderers.SvgIntegrationTest; |
| 48 | +import com.itextpdf.test.ITextTest; |
| 49 | +import com.itextpdf.test.annotations.type.IntegrationTest; |
| 50 | +import org.junit.Assert; |
| 51 | +import org.junit.BeforeClass; |
| 52 | +import org.junit.Rule; |
| 53 | +import org.junit.Test; |
| 54 | +import org.junit.experimental.categories.Category; |
| 55 | +import org.junit.rules.ExpectedException; |
| 56 | + |
| 57 | +import java.io.IOException; |
| 58 | + |
| 59 | +@Category(IntegrationTest.class) |
| 60 | +public class PathParsingIntegrationTest extends SvgIntegrationTest { |
| 61 | + |
| 62 | + public static final String sourceFolder = "./src/test/resources/com/itextpdf/svg/renderers/impl/PathParsingIntegrationTest/"; |
| 63 | + public static final String destinationFolder = "./target/test/com/itextpdf/svg/renderers/impl/PathParsingIntegrationTest/"; |
| 64 | + |
| 65 | + @Rule |
| 66 | + public ExpectedException junitExpectedException = ExpectedException.none(); |
| 67 | + |
| 68 | + @BeforeClass |
| 69 | + public static void beforeClass() { |
| 70 | + ITextTest.createDestinationFolder(destinationFolder); |
| 71 | + } |
| 72 | + |
| 73 | + @Test |
| 74 | + public void normalTest() throws IOException, InterruptedException { |
| 75 | + convertAndCompareVisually(sourceFolder, destinationFolder, "normal"); |
| 76 | + } |
| 77 | + |
| 78 | + @Test |
| 79 | + public void mixTest() throws IOException, InterruptedException { |
| 80 | + convertAndCompareVisually(sourceFolder, destinationFolder, "mix"); |
| 81 | + } |
| 82 | + |
| 83 | + @Test |
| 84 | + public void noWhitespace() throws IOException, InterruptedException { |
| 85 | + convertAndCompareVisually(sourceFolder, destinationFolder, "noWhitespace"); |
| 86 | + } |
| 87 | + |
| 88 | + @Test |
| 89 | + public void zOperator() throws IOException, InterruptedException { |
| 90 | + convertAndCompareVisually(sourceFolder, destinationFolder, "zOperator"); |
| 91 | + } |
| 92 | + |
| 93 | + @Test |
| 94 | + public void missingOperandArgument() throws IOException, InterruptedException { |
| 95 | + convertAndCompareVisually(sourceFolder, destinationFolder, "missingOperandArgument"); |
| 96 | + } |
| 97 | + |
| 98 | + @Test |
| 99 | + public void decimalPointHandlingTest() throws IOException, InterruptedException { |
| 100 | + convertAndCompareVisually(sourceFolder, destinationFolder, "decimalPointHandling"); |
| 101 | + } |
| 102 | + |
| 103 | + @Test |
| 104 | + public void invalidOperatorTest() throws IOException, InterruptedException { |
| 105 | + junitExpectedException.expect(SvgProcessingException.class); |
| 106 | + convertAndCompareVisually(sourceFolder, destinationFolder, "invalidOperator"); |
| 107 | + } |
| 108 | + |
| 109 | + @Test |
| 110 | + public void invalidOperatorCSensTest() throws IOException, InterruptedException { |
| 111 | + junitExpectedException.expect(SvgProcessingException.class); |
| 112 | + convertAndCompareVisually(sourceFolder, destinationFolder, "invalidOperatorCSens"); |
| 113 | + } |
| 114 | + |
| 115 | + @Test |
| 116 | + public void decimalPointParsingTest(){ |
| 117 | + PathSvgNodeRenderer path = new PathSvgNodeRenderer(); |
| 118 | + String input = "2.35.96"; |
| 119 | + |
| 120 | + String expected = "2.35 .96"; |
| 121 | + String actual = path.separateDecimalPoints(input); |
| 122 | + Assert.assertEquals(expected,actual); |
| 123 | + } |
| 124 | + |
| 125 | + @Test |
| 126 | + public void decimalPointParsingSpaceTest(){ |
| 127 | + PathSvgNodeRenderer path = new PathSvgNodeRenderer(); |
| 128 | + String input = "2.35.96 3.25 .25"; |
| 129 | + |
| 130 | + String expected = "2.35 .96 3.25 .25"; |
| 131 | + String actual = path.separateDecimalPoints(input); |
| 132 | + Assert.assertEquals(expected,actual); |
| 133 | + } |
| 134 | + |
| 135 | + @Test |
| 136 | + public void decimalPointParsingTabTest(){ |
| 137 | + PathSvgNodeRenderer path = new PathSvgNodeRenderer(); |
| 138 | + String input = "2.35.96 3.25\t.25"; |
| 139 | + |
| 140 | + String expected = "2.35 .96 3.25\t.25"; |
| 141 | + String actual = path.separateDecimalPoints(input); |
| 142 | + Assert.assertEquals(expected,actual); |
| 143 | + } |
| 144 | + @Test |
| 145 | + public void decimalPointParsingMinusTest(){ |
| 146 | + PathSvgNodeRenderer path = new PathSvgNodeRenderer(); |
| 147 | + String input = "2.35.96 3.25-.25"; |
| 148 | + |
| 149 | + String expected = "2.35 .96 3.25-.25"; |
| 150 | + String actual = path.separateDecimalPoints(input); |
| 151 | + Assert.assertEquals(expected,actual); |
| 152 | + } |
| 153 | + |
| 154 | +} |
| 155 | + |
0 commit comments