@@ -44,7 +44,6 @@ This file is part of the iText (R) project.
44
44
45
45
import com .itextpdf .kernel .PdfException ;
46
46
import com .itextpdf .kernel .pdf .PdfArray ;
47
- import com .itextpdf .kernel .pdf .PdfNumber ;
48
47
import com .itextpdf .test .ExtendedITextTest ;
49
48
import com .itextpdf .test .annotations .type .UnitTest ;
50
49
import org .junit .Assert ;
@@ -62,7 +61,7 @@ public void rectangleOverlapTest01() {
62
61
//Intersection
63
62
Rectangle one = new Rectangle (0 , 0 , 10 , 10 );
64
63
Rectangle two = new Rectangle (5 , 5 , 5 , 5 );
65
- Boolean result = one .overlaps (two );
64
+ boolean result = one .overlaps (two );
66
65
Assert .assertTrue (result );
67
66
68
67
//envelopment
@@ -85,7 +84,7 @@ public void rectangleOverlapTest02() {
85
84
//Top left
86
85
Rectangle one = new Rectangle (0 , 0 , 10 , 10 );
87
86
Rectangle two = new Rectangle (15 , 15 , 10 , 10 );
88
- Boolean result = one .overlaps (two );
87
+ boolean result = one .overlaps (two );
89
88
Assert .assertFalse (result );
90
89
//Middle left
91
90
one = new Rectangle (0 , 0 , 10 , 10 );
@@ -142,7 +141,7 @@ public void envelopTest01() {
142
141
//one contains two
143
142
Rectangle one = new Rectangle (0 , 0 , 10 , 10 );
144
143
Rectangle two = new Rectangle (5 , 5 , 5 , 5 );
145
- Boolean result = one .contains (two );
144
+ boolean result = one .contains (two );
146
145
Assert .assertTrue (result );
147
146
}
148
147
@@ -151,7 +150,7 @@ public void envelopsTest02() {
151
150
//two identical rectangles
152
151
Rectangle one = new Rectangle (0 , 0 , 10 , 10 );
153
152
Rectangle two = new Rectangle (0 , 0 , 10 , 10 );
154
- Boolean result = one .contains (two );
153
+ boolean result = one .contains (two );
155
154
Assert .assertTrue (result );
156
155
157
156
}
@@ -161,7 +160,7 @@ public void envelopsTest03() {
161
160
//One intersects two but does not envelop
162
161
Rectangle one = new Rectangle (0 , 0 , 10 , 10 );
163
162
Rectangle two = new Rectangle (5 , 5 , 10 , 10 );
164
- Boolean result = one .contains (two );
163
+ boolean result = one .contains (two );
165
164
Assert .assertFalse (result );
166
165
}
167
166
@@ -170,22 +169,22 @@ public void envelopsTest04() {
170
169
//one and two do not
171
170
Rectangle one = new Rectangle (0 , 0 , 10 , 10 );
172
171
Rectangle two = new Rectangle (-15 , -15 , 10 , 10 );
173
- Boolean result = one .contains (two );
172
+ boolean result = one .contains (two );
174
173
Assert .assertFalse (result );
175
174
}
176
175
177
176
@ Test
178
177
public void getIntersectionTest01 () {
179
178
//Cases where there is an intersection rectangle
180
179
Rectangle main , second , actual , expected ;
181
- Boolean areEqual = true ;
180
+ boolean areEqual ;
182
181
main = new Rectangle (2 , 2 , 8 , 8 );
183
182
//A. Main rectangle is greater in both dimension than second rectangle
184
183
second = new Rectangle (4 , 8 , 4 , 4 );
185
184
//1.Middle top
186
185
expected = new Rectangle (4 , 8 , 4 , 2 );
187
186
actual = main .getIntersection (second );
188
- areEqual = areEqual && ( expected .equals (actual ) );
187
+ areEqual = expected .equals (actual );
189
188
//2.Middle Right
190
189
second .moveRight (4 );
191
190
expected = new Rectangle (8 , 8 , 2 , 2 );
@@ -261,13 +260,13 @@ public void getIntersectionTest01() {
261
260
@ Test
262
261
public void getIntersectionTest02 () {
263
262
//Cases where the two rectangles do not intersect
264
- Rectangle main , second , actual , expected ;
265
- Boolean noIntersection = true ;
263
+ Rectangle main , second , actual ;
264
+ boolean noIntersection ;
266
265
main = new Rectangle (2 , 2 , 8 , 8 );
267
266
//Top
268
267
second = new Rectangle (4 , 12 , 4 , 4 );
269
268
actual = main .getIntersection (second );
270
- noIntersection = noIntersection && (( actual ) == null ) ;
269
+ noIntersection = actual == null ;
271
270
//Right
272
271
second = new Rectangle (12 , 4 , 4 , 4 );
273
272
actual = main .getIntersection (second );
@@ -289,12 +288,12 @@ public void getIntersectionTest03() {
289
288
//Edge cases: envelopment
290
289
//A equal rectangles
291
290
Rectangle main , second , actual , expected ;
292
- Boolean areEqual = true ;
291
+ boolean areEqual ;
293
292
main = new Rectangle (2 , 2 , 8 , 8 );
294
293
second = new Rectangle (main );
295
294
expected = new Rectangle (main );
296
295
actual = main .getIntersection (second );
297
- areEqual = areEqual && ( expected .equals (actual ) );
296
+ areEqual = expected .equals (actual );
298
297
//B main contains second
299
298
main = new Rectangle (2 , 2 , 8 , 8 );
300
299
second = new Rectangle (4 , 4 , 4 , 4 );
@@ -315,13 +314,13 @@ public void getIntersectionTest03() {
315
314
public void getIntersectionTest04 () {
316
315
//Edge case: intersections on edges
317
316
Rectangle main , second , actual , expected ;
318
- Boolean areEqual = true ;
317
+ boolean areEqual ;
319
318
main = new Rectangle (2 , 2 , 8 , 8 );
320
319
//Top
321
320
second = new Rectangle (4 , 10 , 4 , 4 );
322
321
expected = new Rectangle (4 , 10 , 4 , 0 );
323
322
actual = main .getIntersection (second );
324
- areEqual = areEqual && ( expected .equals (actual ) );
323
+ areEqual = expected .equals (actual );
325
324
//Right
326
325
second = new Rectangle (10 , 4 , 4 , 4 );
327
326
expected = new Rectangle (10 , 4 , 0 , 4 );
@@ -374,16 +373,19 @@ public void createBoundingRectangleFromQuadPointsTest01() {
374
373
375
374
}
376
375
377
- @ Test ( expected = PdfException . class )
376
+ @ Test
378
377
public void createBoundingRectangleFromQuadPointsTest02 () {
379
- Rectangle actual , expected ;
380
378
float [] points = {0 , 0 , 2 , 1 , 1 , 2 , -2 , 1 , 0 };
381
379
PdfArray quadpoints = new PdfArray (points );
382
380
383
- expected = new Rectangle (-2 , 0 , 4 , 2 );
384
- actual = Rectangle .createBoundingRectangleFromQuadPoint (quadpoints );
381
+ boolean exception = false ;
382
+ try {
383
+ Rectangle .createBoundingRectangleFromQuadPoint (quadpoints );
384
+ } catch (PdfException e ) {
385
+ exception = true ;
386
+ }
385
387
386
- Assert .assertEquals ( expected , actual );
388
+ Assert .assertTrue ( exception );
387
389
}
388
390
389
391
@ Test
@@ -399,18 +401,19 @@ public void createBoundingRectanglesFromQuadPointsTest01() {
399
401
Assert .assertArrayEquals (expected .toArray (), actual .toArray ());
400
402
}
401
403
402
- @ Test ( expected = PdfException . class )
404
+ @ Test
403
405
public void createBoundingRectanglesFromQuadPointsTest02 () {
404
- List <Rectangle > actual , expected ;
405
406
float [] points = {0 , 0 , 2 , 1 , 1 , 2 , -2 , 1 ,
406
407
0 , -1 , 2 , 0 , 1 , 1 , -2 , 0 ,
407
408
1 };
408
409
PdfArray quadpoints = new PdfArray (points );
409
- expected = new ArrayList <Rectangle >();
410
- expected .add (new Rectangle (-2 , 0 , 4 , 2 ));
411
- expected .add (new Rectangle (-2 , -1 , 4 , 2 ));
412
- actual = Rectangle .createBoundingRectanglesFromQuadPoint (quadpoints );
413
- Assert .assertArrayEquals (expected .toArray (), actual .toArray ());
410
+ boolean exception = false ;
411
+ try {
412
+ Rectangle .createBoundingRectanglesFromQuadPoint (quadpoints );
413
+ } catch (PdfException e ) {
414
+ exception = true ;
415
+ }
416
+
417
+ Assert .assertTrue (exception );
414
418
}
415
-
416
419
}
0 commit comments