package Ġtests . coordinate Ċ Ċ import Ġcoordinate . Bound Rect Ċ import Ġcoordinate . Point Ċ import Ġorg . junit . jupiter . api . Assertions . assertEquals Ċ import Ġorg . junit . jupiter . api . Test ĊĊ Ċ internal Ġclass ĠRect Test Ġ{ ĊĠ Ġ/* ĊĠĠ Ġ* ĠLine ĠSegment Ġtests ĊĠĠ Ġ*/ ĊĠ Ġ@ Test ĊĠ Ġfun ĠtestGet Bound Segment () Ġ{ ĊĠĠĠ Ġval Ġr Ġ= ĠBound Rect ( Point ( 0 , Ġ- 1 ), Ġ 5 . 0 , Ġ 5 . 0 ) ĊĠĠĠ ĠassertEquals ( S ( Point . Zero , ĠPoint ( 5 , Ġ 0 )), Ġr . get Bound Segment ( S ( Point . Zero , ĠPoint ( 6 , Ġ 0 )))) ĊĠĠĠ ĠassertEquals ( S ( Point . Zero , ĠPoint ( 5 , Ġ 0 )), Ġr . get Bound Segment ( S ( Point (- 1 , Ġ 0 ), ĠPoint ( 6 , Ġ 0 )))) ĊĠĠĠ ĠassertEquals ( S ( Point ( 0 , Ġ- 1 ), ĠPoint ( 5 , Ġ- 1 )), Ġr . get Bound Segment ( S ( Point (- 1 , Ġ- 1 ), ĠPoint ( 6 , Ġ- 1 )))) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġtest Expand () Ġ{ ĊĠĠĠ Ġval Ġr Ġ= ĠBound Rect ( Point . Zero , Ġ 5 . 0 , Ġ 5 . 0 ) ĊĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠ ĠBound Rect ( Point (- 1 , Ġ- 1 ), Ġ 7 , Ġ 7 ), ĊĠĠĠĠĠ Ġr . expand ( 1 . 0 ), ĊĠĠĠ Ġ) ĊĊĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠ ĠBound Rect ( Point ( 1 , Ġ 1 ), Ġ 3 , Ġ 3 ), ĊĠĠĠĠĠ Ġr . expand (- 1 . 0 ), ĊĠĠĠ Ġ) ĊĊĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠ ĠBound Rect ( Point ( 1 , Ġ- 1 ), Ġ 3 , Ġ 7 ), ĊĠĠĠĠĠ Ġr . expand (- 1 . 0 , Ġ 1 ), ĊĠĠĠ Ġ) ĊĊĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠ ĠBound Rect ( Point (- 2 , Ġ- 1 ), Ġ 9 , Ġ 7 ), ĊĠĠĠĠĠ Ġr . expand ( 2 , Ġ 1 ), ĊĠĠĠ Ġ) ĊĊĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠ ĠBound Rect ( Point (- 2 , Ġ- 1 ), Ġ 9 , Ġ 7 ), ĊĠĠĠĠĠ Ġr . expand ( Point ( 2 , Ġ 1 )), ĊĠĠĠ Ġ) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġtest Shrink () Ġ{ ĊĠĠĠ Ġval Ġr Ġ= ĠBound Rect ( Point . Zero , Ġ 5 . 0 , Ġ 5 . 0 ) ĊĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠ ĠBound Rect ( Point ( 1 , Ġ 1 ), Ġ 3 , Ġ 3 ), ĊĠĠĠĠĠ Ġr . shrink ( 1 . 0 ), ĊĠĠĠ Ġ) ĊĊĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠ ĠBound Rect ( Point (- 1 , Ġ- 1 ), Ġ 7 , Ġ 7 ), ĊĠĠĠĠĠ Ġr . shrink (- 1 . 0 ), ĊĠĠĠ Ġ) ĊĊĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠ ĠBound Rect ( Point (- 1 , Ġ 1 ), Ġ 7 , Ġ 3 ), ĊĠĠĠĠĠ Ġr . shrink (- 1 . 0 , Ġ 1 ), ĊĠĠĠ Ġ) ĊĊĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠ ĠBound Rect ( Point ( 2 , Ġ 1 ), Ġ 1 , Ġ 3 ), ĊĠĠĠĠĠ Ġr . shrink ( 2 , Ġ 1 ), ĊĠĠĠ Ġ) ĊĊĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠ ĠBound Rect ( Point ( 2 , Ġ 1 ), Ġ 1 , Ġ 3 ), ĊĠĠĠĠĠ Ġr . shrink ( Point ( 2 , Ġ 1 )), ĊĠĠĠ Ġ) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġtest Re center () Ġ{ ĊĠĠĠ Ġval Ġr Ġ= ĠBound Rect ( Point . Zero , Ġ 5 . 0 , Ġ 5 . 0 ) ĊĊĠĠĠ ĠassertEquals ( Bound Rect ( Point (- 2 . 5 , Ġ- 2 . 5 ), Ġ 5 , Ġ 5 ), Ġr . re centered ( Point . Zero )) ĊĠĠĠ ĠassertEquals ( r , Ġr . re centered ( Point ( 2 . 5 , Ġ 2 . 5 ))) ĊĊĊĠĠĠ Ġval Ġr 2 Ġ= ĠBound Rect ( Point (- 1 , Ġ- 1 ), Ġ 4 . 0 , Ġ 4 . 0 ) ĊĊĠĠĠ ĠassertEquals ( Bound Rect ( Point (- 2 , Ġ- 2 ), Ġ 4 , Ġ 4 ), Ġr 2 . re centered ( Point . Zero )) ĊĠĠĠ ĠassertEquals ( Bound Rect ( Point ( 1 4 8 , Ġ 9 8 ), Ġ 4 , Ġ 4 ), Ġr 2 . re centered ( Point ( 1 5 0 , Ġ 1 0 0 ))) ĊĊĠĠĠ Ġval Ġr 3 Ġ= ĠBound Rect ( Point (- 1 , Ġ- 1 ), Ġ 4 . 0 , Ġ 1 0 . 0 ) ĊĊĠĠĠ ĠassertEquals ( Bound Rect ( Point (- 2 , Ġ- 5 ), Ġ 4 , Ġ 1 0 ), Ġr 3 . re centered ( Point . Zero )) ĊĠĠĠ ĠassertEquals ( Bound Rect ( Point ( 1 4 8 , Ġ 9 5 ), Ġ 4 , Ġ 1 0 ), Ġr 3 . re centered ( Point ( 1 5 0 , Ġ 1 0 0 ))) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġtest Resize Center ed () Ġ{ ĊĠĠĠ Ġval Ġr Ġ= ĠBound Rect ( Point . Zero , Ġ 5 . 0 , Ġ 5 . 0 ) ĊĊĠĠĠ ĠassertEquals ( r , Ġr . resize Center ed ( Point ( 5 , Ġ 5 ))) ĊĠĠĠ ĠassertEquals ( Bound Rect ( Point (- 2 . 5 , Ġ 0 ), Ġ 1 0 , Ġ 5 ), Ġr . resize Center ed ( Point ( 1 0 , Ġ 5 ))) ĊĠĠĠ ĠassertEquals ( Bound Rect ( Point ( 0 , Ġ- 2 . 5 ), Ġ 5 , Ġ 1 0 ), Ġr . resize Center ed ( Point ( 5 , Ġ 1 0 ))) ĊĠĠĠ ĠassertEquals ( Bound Rect ( Point (- 2 . 5 , Ġ- 2 . 5 ), Ġ 1 0 , Ġ 1 0 ), Ġr . resize Center ed ( Point ( 1 0 , Ġ 1 0 ))) ĊĠĠĠ ĠassertEquals ( Bound Rect ( Point (- 5 , Ġ- 2 . 5 ), Ġ 1 5 , Ġ 1 0 ), Ġr . resize Center ed ( Point ( 1 5 , Ġ 1 0 ))) ĊĠĠĠ ĠassertEquals ( Bound Rect ( Point (- 5 , Ġ 1 ), Ġ 1 5 , Ġ 3 ), Ġr . resize Center ed ( Point ( 1 5 , Ġ 3 ))) ĊĠĠĠ ĠassertEquals ( Bound Rect ( Point ( 2 . 5 , Ġ 1 ), Ġ 0 , Ġ 3 ), Ġr . resize Center ed ( Point ( 0 , Ġ 3 ))) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġtest Bound Intersection () Ġ{ ĊĠĠĠ Ġval Ġr Zero Ġ= ĠBound Rect ( Point . Zero , Ġ 5 , Ġ 5 ) ĊĠĠĠ Ġval Ġr One Ġ= ĠBound Rect ( Point . One , Ġ 4 , Ġ 4 ) ĊĠĠĠ Ġval Ġr Two Ġ= ĠBound Rect ( Point . One , Ġ 5 , Ġ 5 ) ĊĠĠĠ Ġval Ġr Three Ġ= ĠBound Rect ( Point . One , Ġ 3 , Ġ 3 ) ĊĠĠĠ Ġval Ġr Four Ġ= ĠBound Rect ( Point . One , Ġ 3 , Ġ 1 0 ) ĊĠĠĠ Ġval Ġdisconnected Ġ= ĠBound Rect ( Point ( 1 0 , Ġ 1 0 ), Ġ 3 , Ġ 3 ) ĊĠĠĠ Ġval Ġdisconnected X Ġ= ĠBound Rect ( Point ( 1 0 , Ġ 1 ), Ġ 3 , Ġ 3 ) ĊĠĠĠ Ġval Ġdisconnected Y Ġ= ĠBound Rect ( Point ( 1 , Ġ 1 0 ), Ġ 3 , Ġ 3 ) ĊĊĠĠĠ ĠassertEquals ( r Zero , Ġr Zero . bounds Intersection ( r Zero )) ĊĊĠĠĠ ĠassertEquals ( r One , Ġr Zero . bounds Intersection ( r One )) ĊĠĠĠ ĠassertEquals ( r One , Ġr One . bounds Intersection ( r Zero )) ĊĊĠĠĠ ĠassertEquals ( r One , Ġr Two . bounds Intersection ( r Zero )) ĊĠĠĠ ĠassertEquals ( r One , Ġr Zero . bounds Intersection ( r Two )) ĊĊĠĠĠ ĠassertEquals ( r Three , Ġr Three . bounds Intersection ( r Zero )) ĊĠĠĠ ĠassertEquals ( r Three , Ġr Zero . bounds Intersection ( r Three )) ĊĊĠĠĠ ĠassertEquals ( Bound Rect ( Point . One , Ġ 3 , Ġ 4 ), Ġr Four . bounds Intersection ( r Zero )) ĊĠĠĠ ĠassertEquals ( Bound Rect ( Point . One , Ġ 3 , Ġ 4 ), Ġr Zero . bounds Intersection ( r Four )) ĊĊĠĠĠ ĠassertEquals ( null , Ġdisconnected . bounds Intersection ( r Zero )) ĊĠĠĠ ĠassertEquals ( null , Ġr Zero . bounds Intersection ( disconnected )) ĊĠĠĠ ĠassertEquals ( null , Ġdisconnected X . bounds Intersection ( r Zero )) ĊĠĠĠ ĠassertEquals ( null , Ġr Zero . bounds Intersection ( disconnected X )) ĊĠĠĠ ĠassertEquals ( null , Ġdisconnected Y . bounds Intersection ( r Zero )) ĊĠĠĠ ĠassertEquals ( null , Ġr Zero . bounds Intersection ( disconnected Y )) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġtest Scaled () Ġ{ ĊĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠ ĠBound Rect ( Point . Zero , ĠPoint ( 4 )), ĊĠĠĠĠĠ ĠBound Rect ( Point . Zero , ĠPoint . One ). scaled ( Point ( 4 ), ĠPoint . Zero ), ĊĠĠĠ Ġ) ĊĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠ ĠBound Rect ( Point (- 3 ), ĠPoint . One ), ĊĠĠĠĠĠ ĠBound Rect ( Point . Zero , ĠPoint . One ). scaled ( Point ( 4 ), ĠPoint . One ), ĊĠĠĠ Ġ) ĊĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠ ĠBound Rect ( Point (- 1 . 5 ), ĠPoint ( 2 . 5 )), ĊĠĠĠĠĠ ĠBound Rect ( Point . Zero , ĠPoint . One ). scaled ( Point ( 4 ), ĠPoint ( 0 . 5 )), ĊĠĠĠ Ġ) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġtest Expand To Include () Ġ{ ĊĠĠĠ Ġval Ġb 0 Ġ= ĠBound Rect ( Point . Zero , ĠPoint . Zero ) ĊĠĠĠ Ġval Ġb 1 Ġ= ĠBound Rect ( Point . Zero , ĠPoint ( 1 0 , Ġ 2 0 )) ĊĠĠĠ ĠassertEquals ( b 0 , Ġb 0 . expand To Include ( Point . Zero )) ĊĠĠĠ ĠassertEquals ( Bound Rect ( Point . Zero , ĠPoint ( 1 0 , Ġ 2 0 )), Ġb 0 . expand To Include ( Point ( 1 0 , Ġ 2 0 ))) ĊĠĠĠ ĠassertEquals ( Bound Rect ( Point (- 1 , Ġ 0 ), ĠPoint ( 0 , Ġ 2 0 )), Ġb 0 . expand To Include ( Point (- 1 , Ġ 2 0 ))) ĊĠĠĠ ĠassertEquals ( b 1 , Ġb 1 . expand To Include ( Point ( 1 0 , Ġ 2 0 ))) ĊĠĠĠ ĠassertEquals ( Bound Rect ( Point . Zero , ĠPoint ( 1 1 , Ġ 2 0 )), Ġb 1 . expand To Include ( Point ( 1 1 , Ġ 2 0 ))) ĊĠĠĠ ĠassertEquals ( Bound Rect ( Point . Zero , ĠPoint ( 1 1 , Ġ 2 1 )), Ġb 1 . expand To Include ( Point ( 1 1 , Ġ 2 1 ))) ĊĠĠĠ ĠassertEquals ( Bound Rect ( Point . Zero , ĠPoint ( 1 0 , Ġ 2 1 )), Ġb 1 . expand To Include ( Point ( 9 , Ġ 2 1 ))) ĊĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠ ĠBound Rect ( Point ( 0 , Ġ- 2 1 ), ĠPoint ( 1 0 , Ġ 2 0 )), Ġb 1 . expand To Include ( ĊĠĠĠĠĠ ĠPoint ( 9 , Ġ- 2 1 ) ĊĠĠĠĠĠ Ġ)) ĊĠ Ġ} Ċ } Ċ