@@ -22,6 +22,7 @@ import org.scalatest.matchers.should.Matchers
22
22
import org .scalatest .wordspec .AnyWordSpecLike
23
23
import tech .units .indriya .quantity .Quantities
24
24
import tech .units .indriya .unit .Units .METRE
25
+ import org .scalatest .prop .TableDrivenPropertyChecks ._
25
26
26
27
import scala .util .{Failure , Success }
27
28
@@ -42,24 +43,67 @@ class RichGeometriesSpec extends Matchers with AnyWordSpecLike {
42
43
}
43
44
44
45
" check if a coordinate is between two others" in {
45
- val coordinateA = buildCoordinate(10 , 5 )
46
- val coordinateB = buildCoordinate(20 , 5 )
47
- val coordinateBetween = buildCoordinate(15 , 5 )
48
- val coordinateNotExactlyBetween = buildCoordinate(16 , 5.005 )
49
- val coordinateNotBetween = buildCoordinate(15 , 6 )
50
-
51
- coordinateBetween.isBetween(coordinateA, coordinateB) shouldBe true
52
- coordinateBetween.isBetween(coordinateB, coordinateA) shouldBe true
53
- coordinateNotExactlyBetween.isBetween(
54
- coordinateA,
55
- coordinateB
56
- ) shouldBe false
57
- coordinateNotExactlyBetween.isBetween(
58
- coordinateA,
59
- coordinateB,
60
- 1e-5
61
- ) shouldBe true
62
- coordinateNotBetween.isBetween(coordinateB, coordinateA) shouldBe false
46
+ val coordinates = Table (
47
+ (
48
+ " coordinateA" ,
49
+ " coordinateB" ,
50
+ " maybeCoordinateBetween" ,
51
+ " epsilon" ,
52
+ " isBetween"
53
+ ),
54
+ (
55
+ buildCoordinate(10 , 5 ),
56
+ buildCoordinate(20 , 5 ),
57
+ buildCoordinate(15 , 5 ),
58
+ 1e-12 ,
59
+ true
60
+ ),
61
+ (
62
+ buildCoordinate(20 , 5 ),
63
+ buildCoordinate(10 , 5 ),
64
+ buildCoordinate(15 , 5 ),
65
+ 1e-12 ,
66
+ true
67
+ ),
68
+ (
69
+ buildCoordinate(10 , 5 ),
70
+ buildCoordinate(20 , 5 ),
71
+ buildCoordinate(16 , 5.005 ),
72
+ 1e-12 ,
73
+ false
74
+ ),
75
+ (
76
+ buildCoordinate(7.4065 , 51.538 ),
77
+ buildCoordinate(7.4265 , 51.578 ),
78
+ buildCoordinate(7.423473617185907 , 51.57194723437181 ),
79
+ 1e-12 ,
80
+ false
81
+ ),
82
+ (
83
+ buildCoordinate(7.4065 , 51.538 ),
84
+ buildCoordinate(7.4265 , 51.578 ),
85
+ buildCoordinate(7.423473617185907 , 51.57194723437181 ),
86
+ 1e-8 ,
87
+ true
88
+ )
89
+ )
90
+
91
+ forAll(coordinates) {
92
+ (
93
+ coordinateA : Coordinate ,
94
+ coordinateB : Coordinate ,
95
+ maybeCoordinateBetwee : Coordinate ,
96
+ epsilon : Double ,
97
+ isBetween : Boolean
98
+ ) =>
99
+ {
100
+ maybeCoordinateBetwee.isBetween(
101
+ coordinateA,
102
+ coordinateB,
103
+ epsilon
104
+ ) shouldBe isBetween
105
+ }
106
+ }
63
107
}
64
108
65
109
" transform to a point correctly" in {
0 commit comments