@@ -22,6 +22,7 @@ You should have received a copy of the GNU Affero General Public License
2222*/
2323using System . Collections . Generic ;
2424using System . Linq ;
25+ using iText . Commons . Utils ;
2526using iText . Kernel . Geom ;
2627using iText . Kernel . Pdf . Canvas ;
2728using iText . Test ;
@@ -48,11 +49,12 @@ public virtual void SquareClippingTest() {
4849 Path rectanglePath = new Path ( ) ;
4950 rectanglePath . AddSubpath ( rectangleSubpath ) ;
5051 Clipper clipper = new Clipper ( ) ;
51- ClipperBridge . AddPath ( clipper , squarePath , PolyType . SUBJECT ) ;
52- ClipperBridge . AddPath ( clipper , rectanglePath , PolyType . CLIP ) ;
52+ ClipperBridge clipperBridge = new ClipperBridge ( squarePath , rectanglePath ) ;
53+ clipperBridge . AddPath ( clipper , squarePath , PolyType . SUBJECT ) ;
54+ clipperBridge . AddPath ( clipper , rectanglePath , PolyType . CLIP ) ;
5355 PolyTree polyTree = new PolyTree ( ) ;
5456 clipper . Execute ( ClipType . UNION , polyTree ) ;
55- Path result = ClipperBridge . ConvertToPath ( polyTree ) ;
57+ Path result = clipperBridge . ConvertToPath ( polyTree ) ;
5658 NUnit . Framework . Assert . AreEqual ( new Point ( 20 , 40 ) , result . GetCurrentPoint ( ) ) ;
5759 NUnit . Framework . Assert . AreEqual ( 2 , result . GetSubpaths ( ) . Count ) ;
5860 Subpath closedPath = result . GetSubpaths ( ) [ 0 ] ;
@@ -95,14 +97,34 @@ public virtual void GetEndTypeTest() {
9597 public virtual void LongRectWidthTest ( ) {
9698 IntRect longRect = new IntRect ( 14900000000000000L , 21275000000000000L , 71065802001953128L , 71075000000000000L
9799 ) ;
98- NUnit . Framework . Assert . AreEqual ( 561.658 , ClipperBridge . LongRectCalculateWidth ( longRect ) , 0.001f ) ;
100+ NUnit . Framework . Assert . AreEqual ( 561.658 , new ClipperBridge ( ) . LongRectCalculateWidth ( longRect ) , 0.001f ) ;
99101 }
100102
101103 [ NUnit . Framework . Test ]
102104 public virtual void LongRectHeightTest ( ) {
103105 IntRect longRect = new IntRect ( 14900000000000000L , 21275000000000000L , 71065802001953128L , 71075000000000000L
104106 ) ;
105- NUnit . Framework . Assert . AreEqual ( 498 , ClipperBridge . LongRectCalculateHeight ( longRect ) , 0.001f ) ;
107+ NUnit . Framework . Assert . AreEqual ( 498 , new ClipperBridge ( ) . LongRectCalculateHeight ( longRect ) , 0.001f ) ;
108+ }
109+
110+ [ NUnit . Framework . Test ]
111+ public virtual void DynamicFloatMultiplierCalculationsSmallValuesTest ( ) {
112+ Point [ ] points = new Point [ ] { new Point ( 1e-10 , 0 ) , new Point ( 0 , 1e-13 ) } ;
113+ NUnit . Framework . Assert . AreEqual ( 1.8014398509481984e26 , new ClipperBridge ( points ) . GetFloatMultiplier ( ) , 0e+10
114+ ) ;
115+ }
116+
117+ [ NUnit . Framework . Test ]
118+ public virtual void DynamicFloatMultiplierCalculationsBigValuesTest ( ) {
119+ Point [ ] points = new Point [ ] { new Point ( 1e+11 , 10 ) , new Point ( 10 , 1e+10 ) } ;
120+ NUnit . Framework . Assert . AreEqual ( 180143 , new ClipperBridge ( points ) . GetFloatMultiplier ( ) , 0.001f ) ;
121+ }
122+
123+ [ NUnit . Framework . Test ]
124+ public virtual void SmallFloatMultiplierCoefficientTest ( ) {
125+ Point [ ] points = new Point [ ] { new Point ( 1e-10 , 1e+10 ) } ;
126+ NUnit . Framework . Assert . AreEqual ( new IntPoint ( 0 , 18014390000000000L ) , new ClipperBridge ( points ) . ConvertToLongPoints
127+ ( JavaUtil . ArraysAsList ( points ) ) [ 0 ] ) ;
106128 }
107129
108130 private bool AreShapesEqual ( IShape expected , IShape actual ) {
0 commit comments