forked from janiskomuls/scala-bootcamp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathClassesAndTraitsSpec.scala
38 lines (33 loc) · 1.05 KB
/
ClassesAndTraitsSpec.scala
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package com.evolutiongaming.bootcamp.basics
import ClassesAndTraits._
import com.evolutiongaming.bootcamp.basics.ClassesAndTraits.Circle
import org.scalatest.matchers.should.Matchers._
import org.scalacheck.Gen._
import org.scalatest.flatspec.AnyFlatSpec
import org.scalatestplus.scalacheck.ScalaCheckDrivenPropertyChecks
import cats.implicits._
class ClassesAndTraitsSpec extends AnyFlatSpec with ScalaCheckDrivenPropertyChecks {
"Circle" should "be correct" in {
val intervalGen = choose(1.0, 10)
forAll(intervalGen, intervalGen, intervalGen) { (x, y, r) =>
val circle = Circle(x, y, r)
circle.minX shouldEqual x - r
circle.maxX shouldEqual x + r
circle.minY shouldEqual y - r
circle.maxY shouldEqual y + r
}
}
"minimumBoundingRectangle" should "be correct" in {
val mbr = minimumBoundingRectangle(
Set(
Point(-12, -3),
Point(-3, 7),
Circle(0, 0, 5),
)
)
mbr.minX shouldEqual -12
mbr.maxX shouldEqual 5
mbr.minY shouldEqual -5
mbr.maxY shouldEqual 7
}
}