Skip to content

Commit 0ddab26

Browse files
committed
Add unit test and javadocs for Dimensions2D
1 parent 2da93f4 commit 0ddab26

File tree

2 files changed

+81
-0
lines changed

2 files changed

+81
-0
lines changed

pdfocr-onnxtr/src/main/java/com/itextpdf/pdfocr/onnxtr/util/Dimensions2D.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,31 @@ public class Dimensions2D {
3131
private final int width;
3232
private final int height;
3333

34+
/**
35+
* Creates new {@link Dimensions2D} instance.
36+
*
37+
* @param width width dimension
38+
* @param height height dimension
39+
*/
3440
public Dimensions2D(int width, int height) {
3541
this.width = width;
3642
this.height = height;
3743
}
3844

45+
/**
46+
* Gets width of the {@link Dimensions2D} instance.
47+
*
48+
* @return width of the {@link Dimensions2D} instance
49+
*/
3950
public int getWidth() {
4051
return width;
4152
}
4253

54+
/**
55+
* Gets height of the {@link Dimensions2D} instance.
56+
*
57+
* @return height of the {@link Dimensions2D} instance
58+
*/
4359
public int getHeight() {
4460
return height;
4561
}
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
/*
2+
This file is part of the iText (R) project.
3+
Copyright (c) 1998-2025 Apryse Group NV
4+
Authors: Apryse 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.pdfocr.onnxtr.util;
24+
25+
import com.itextpdf.test.ExtendedITextTest;
26+
import org.junit.jupiter.api.Assertions;
27+
import org.junit.jupiter.api.Tag;
28+
import org.junit.jupiter.params.ParameterizedTest;
29+
import org.junit.jupiter.params.provider.MethodSource;
30+
31+
import java.util.Arrays;
32+
33+
@Tag("UnitTest")
34+
public class Dimensions2DUnitTest extends ExtendedITextTest {
35+
36+
public static Iterable<Object[]> equalsFalse() {
37+
return Arrays.asList(new Object[][]{
38+
{new Dimensions2D(100, 20), null},
39+
{new Dimensions2D(100, 20), "different class"},
40+
{new Dimensions2D(100, 700), new Dimensions2D(100, 800)},
41+
{new Dimensions2D(100, 800), new Dimensions2D(200, 800)},
42+
{new Dimensions2D(100, 700), new Dimensions2D(200, 800)},
43+
});
44+
}
45+
46+
public static Iterable<Object[]> equalsTrue() {
47+
Dimensions2D dimensions2D = new Dimensions2D(100, 200);
48+
return Arrays.asList(new Object[][]{
49+
{dimensions2D, new Dimensions2D(100, 200)},
50+
{dimensions2D, dimensions2D},
51+
});
52+
}
53+
54+
@ParameterizedTest(name = "first: {0}, second: {1}")
55+
@MethodSource("equalsFalse")
56+
public void equalsNegativeTest(Dimensions2D first, Object second) {
57+
Assertions.assertNotEquals(first, second);
58+
}
59+
60+
@ParameterizedTest(name = "first: {0}, second: {1}")
61+
@MethodSource("equalsTrue")
62+
public void equalsPositiveTest(Dimensions2D first, Dimensions2D second) {
63+
Assertions.assertEquals(first, second);
64+
}
65+
}

0 commit comments

Comments
 (0)