|
| 1 | +/* |
| 2 | + This file is part of the iText (R) project. |
| 3 | + Copyright (c) 1998-2020 iText Group NV |
| 4 | + Authors: iText Software. |
| 5 | +
|
| 6 | + This program is offered under a commercial and under the AGPL license. |
| 7 | + For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below. |
| 8 | +
|
| 9 | + AGPL licensing: |
| 10 | + This program is free software: you can redistribute it and/or modify |
| 11 | + it under the terms of the GNU Affero General Public License as published by |
| 12 | + the Free Software Foundation, either version 3 of the License, or |
| 13 | + (at your option) any later version. |
| 14 | +
|
| 15 | + This program is distributed in the hope that it will be useful, |
| 16 | + but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 17 | + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 18 | + GNU Affero General Public License for more details. |
| 19 | +
|
| 20 | + You should have received a copy of the GNU Affero General Public License |
| 21 | + along with this program. If not, see <https://www.gnu.org/licenses/>. |
| 22 | + */ |
| 23 | +package com.itextpdf.html2pdf.attach.impl.tags; |
| 24 | + |
| 25 | +import com.itextpdf.html2pdf.html.AttributeConstants; |
| 26 | +import com.itextpdf.test.ExtendedITextTest; |
| 27 | +import com.itextpdf.test.annotations.type.UnitTest; |
| 28 | + |
| 29 | +import org.junit.Assert; |
| 30 | +import org.junit.Test; |
| 31 | +import org.junit.experimental.categories.Category; |
| 32 | + |
| 33 | +@Category(UnitTest.class) |
| 34 | +public class InputTagWorkerTest extends ExtendedITextTest { |
| 35 | + |
| 36 | + @Test |
| 37 | + public void testNumberInputPreprocessing() { |
| 38 | + Assert.assertEquals("", InputTagWorker.preprocessInputValue("bear", AttributeConstants.NUMBER)); |
| 39 | + Assert.assertEquals("4", InputTagWorker.preprocessInputValue("4", AttributeConstants.NUMBER)); |
| 40 | + Assert.assertEquals("04", InputTagWorker.preprocessInputValue("04", AttributeConstants.NUMBER)); |
| 41 | + Assert.assertEquals("", InputTagWorker.preprocessInputValue("4.", AttributeConstants.NUMBER)); |
| 42 | + Assert.assertEquals("", InputTagWorker.preprocessInputValue(".", AttributeConstants.NUMBER)); |
| 43 | + Assert.assertEquals(".9", InputTagWorker.preprocessInputValue(".9", AttributeConstants.NUMBER)); |
| 44 | + Assert.assertEquals("4.4", InputTagWorker.preprocessInputValue("4.4", AttributeConstants.NUMBER)); |
| 45 | + Assert.assertEquals("-4", InputTagWorker.preprocessInputValue("-4", AttributeConstants.NUMBER)); |
| 46 | + Assert.assertEquals("", InputTagWorker.preprocessInputValue("", AttributeConstants.NUMBER)); |
| 47 | + Assert.assertEquals("", InputTagWorker.preprocessInputValue("-", AttributeConstants.NUMBER)); |
| 48 | + Assert.assertEquals("-.9", InputTagWorker.preprocessInputValue("-.9", AttributeConstants.NUMBER)); |
| 49 | + Assert.assertEquals("", InputTagWorker.preprocessInputValue("0-.9", AttributeConstants.NUMBER)); |
| 50 | + } |
| 51 | +} |
0 commit comments