@@ -146,21 +146,21 @@ void LIC0_false_with_smaller_distance() {
146146 }
147147
148148 @ Test
149- // Contract: LIC0 is false iff less than two points exist.
150- void LIC0_false_with_too_few_points () {
149+ // Contract: LIC0 throws an IllegelArgumentException if less than two points exist.
150+ void LIC0_throws_with_too_few_points () {
151151 Parameters p = new Parameters ();
152152 p .LENGTH1 = 4 ;
153153 Point [] pts = { new Point (0 , 0 ) };
154- assertFalse ( LIC .LIC0 (pts .length , pts , p ));
154+ assertThrows ( IllegalArgumentException . class , () -> LIC .LIC0 (pts .length , pts , p ));
155155 }
156156
157157 @ Test
158- // Contract: LIC0 is false iff LENGTH1 < 0
159- void LIC0_false_with_length_too_small () {
158+ // Contract: LIC0 throws an IllegelArgumentException if LENGTH1 < 0
159+ void LIC0_throws_with_length_too_small () {
160160 Parameters p = new Parameters ();
161161 p .LENGTH1 = -1 ;
162162 Point [] pts = { new Point (0 , 0 ), new Point (3 , 4 )};
163- assertFalse ( LIC .LIC0 (pts .length , pts , p ));
163+ assertThrows ( IllegalArgumentException . class , () -> LIC .LIC0 (pts .length , pts , p ));
164164 }
165165
166166 @ Test
@@ -494,8 +494,8 @@ public void LIC6_false_with_too_few_points() {
494494 }
495495
496496 @ Test
497- public void LIC6_false_with_DIST_too_small () {
498- // Contract: LIC6 is false iff DIST < 0
497+ public void LIC6_throws_exception_with_DIST_too_small () {
498+ // Contract: LIC6 throws an exception iff DIST < 0
499499 Parameters p = new Parameters ();
500500 p .N_PTS = 3 ;
501501 p .DIST = -1 ;
@@ -511,12 +511,12 @@ public void LIC6_false_with_DIST_too_small() {
511511 new Point (6 , 0 ),
512512 new Point (1 , -1 )
513513 };
514- assertFalse ( LIC .LIC6 (points3 .length , points3 , p ));
514+ assertThrows ( IllegalArgumentException . class , () -> LIC .LIC6 (points3 .length , points3 , p ));
515515 }
516516
517517 @ Test
518- public void LIC6_false_with_too_small_N_PTS () {
519- // Contract: LIC6 is false iff N_PTS < 3
518+ public void LIC6_throws_exception_with_too_small_N_PTS () {
519+ // Contract: LIC6 throws an exception iff N_PTS < 3
520520 Parameters p = new Parameters ();
521521 p .N_PTS = 2 ;
522522 p .DIST = 30 ;
@@ -532,7 +532,28 @@ public void LIC6_false_with_too_small_N_PTS() {
532532 new Point (6 , 0 ),
533533 new Point (1 , -1 )
534534 };
535- assertFalse (LIC .LIC6 (points2 .length , points2 , p ));
535+ assertThrows (IllegalArgumentException .class , () -> LIC .LIC6 (points2 .length , points2 , p ));
536+ }
537+
538+ @ Test
539+ public void LIC6_throws_exception_with_N_PTS_bigger_than_numpoints () {
540+ // Contract: LIC6 throws an exception iff N_PTS > numpoints
541+ Parameters p = new Parameters ();
542+ p .N_PTS = 20 ;
543+ p .DIST = 30 ;
544+ Point [] points2 = new Point [] {
545+ new Point (0 , 0 ),
546+ new Point (1 , 0 ),
547+ new Point (2 , 0 ),
548+ new Point (1 , 1 ),
549+ new Point (2 , 2 ),
550+ new Point (1 , 1 ),
551+ new Point (0 , 3 ),
552+ new Point (1 , 2 ),
553+ new Point (6 , 0 ),
554+ new Point (1 , -1 )
555+ };
556+ assertThrows (IllegalArgumentException .class , () -> LIC .LIC6 (points2 .length , points2 , p ));
536557 }
537558
538559 @ Test
@@ -843,57 +864,87 @@ public void LIC10_false_when_too_few_points() {
843864 }
844865
845866 @ Test
846- public void LIC10_false_when_area_too_small () {
847- // Contract: LIC10 is false if the area is smaller than 0
867+ public void LIC10_throws_exception_when_area_too_small () {
868+ // Contract: LIC10 throws exception if the area is smaller than 0
848869 Point [] points = new Point [] {
849870 new Point (1 , 0 ),
850871 new Point (0 , 0 ),
851- new Point (1 , 0 )
872+ new Point (1 , 0 ),
873+ new Point (1 , 0 ),
874+ new Point (0 , 0 ),
875+ new Point (0 , 0 ),
876+ new Point (1 , 0 ),
877+ new Point (1 , 0 ),
878+ new Point (0 , 0 )
852879 };
853880 Parameters p = new Parameters ();
854881 p .E_PTS = 2 ;
855882 p .F_PTS = 2 ;
856883 p .AREA1 = -1 ;
857- assertFalse ( LIC .LIC10 (3 , points , p ));
884+ assertThrows ( IllegalArgumentException . class , () -> LIC .LIC10 (points . length , points , p ));
858885 }
859886
860- @ Test
861- public void LIC10_false_when_EPTS_plus_FTPS_too_large () {
862- // Contract: LIC10 is false if E_PTS + F_PTS <= numpoints - 3
887+ @ Test
888+ public void LIC10_throws_exception_when_EPTS_too_small () {
889+ // Contract: LIC10 throws exception if the EPTS < 1
863890 Point [] points = new Point [] {
864891 new Point (1 , 0 ),
865892 new Point (0 , 0 ),
866893 new Point (1 , 0 ),
894+ new Point (1 , 0 ),
867895 new Point (0 , 0 ),
868- new Point (1 , 0 )
896+ new Point (0 , 0 ),
897+ new Point (1 , 0 ),
898+ new Point (1 , 0 ),
899+ new Point (0 , 0 )
869900 };
870901 Parameters p = new Parameters ();
871- p .E_PTS = 1 ;
902+ p .E_PTS = 0 ;
872903 p .F_PTS = 2 ;
873- p .AREA1 = 10 ;
874- assertFalse ( LIC .LIC10 (5 , points , p ));
904+ p .AREA1 = 4 ;
905+ assertThrows ( IllegalArgumentException . class , () -> LIC .LIC10 (points . length , points , p ));
875906 }
876907
877908 @ Test
878- public void LIC10_false_with_smaller_area () {
879- /*
880- * Contract: LIC10 is false iff there exists no set of three data points
881- * separated by exactly E PTS and F PTS consecutive intervening points, respectively,
882- * that are the vertices of a triangle with area greater than AREA1.
883- */
909+ public void LIC10_throws_exception_when_FPTS_too_small () {
910+ // Contract: LIC10 throws exception if FPTS < 1
884911 Point [] points = new Point [] {
885912 new Point (1 , 0 ),
886- new Point (0 , 1 ),
887- new Point (2 , 0 ),
888- new Point (0 , 2 ),
889- new Point (1 , 1 ),
890- new Point (1 , 1 )
913+ new Point (0 , 0 ),
914+ new Point (1 , 0 ),
915+ new Point (1 , 0 ),
916+ new Point (0 , 0 ),
917+ new Point (0 , 0 ),
918+ new Point (1 , 0 ),
919+ new Point (1 , 0 ),
920+ new Point (0 , 0 )
891921 };
892922 Parameters p = new Parameters ();
893- p .E_PTS = 1 ;
894- p .F_PTS = 1 ;
895- p .AREA1 = 10 ;
896- assertFalse (LIC .LIC10 (points .length , points , p ));
923+ p .E_PTS = 2 ;
924+ p .F_PTS = 0 ;
925+ p .AREA1 = 4 ;
926+ assertThrows (IllegalArgumentException .class , () -> LIC .LIC10 (points .length , points , p ));
927+ }
928+
929+ @ Test
930+ public void LIC10_throws_exception_when_EPTS_plus_FPTS_too_large () {
931+ // Contract: LIC10 throws exception if EPTS + FPTS > numpoints - 3
932+ Point [] points = new Point [] {
933+ new Point (1 , 0 ),
934+ new Point (0 , 0 ),
935+ new Point (1 , 0 ),
936+ new Point (1 , 0 ),
937+ new Point (0 , 0 ),
938+ new Point (0 , 0 ),
939+ new Point (1 , 0 ),
940+ new Point (1 , 0 ),
941+ new Point (0 , 0 )
942+ };
943+ Parameters p = new Parameters ();
944+ p .E_PTS = 5 ;
945+ p .F_PTS = 5 ;
946+ p .AREA1 = 4 ;
947+ assertThrows (IllegalArgumentException .class , () -> LIC .LIC10 (points .length , points , p ));
897948 }
898949
899950 @ Test
0 commit comments