Skip to content

Commit

Permalink
add org.scalacheck.Arbitrary instances for core geometric types
Browse files Browse the repository at this point in the history
  • Loading branch information
vreuter committed Jul 9, 2024
1 parent 98937c8 commit 52aa280
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
3 changes: 1 addition & 2 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ lazy val cell = defineModule("cell")(project)
.dependsOn(numeric)

lazy val geometry = defineModule("geometry")(project)
.dependsOn(testing % Test)

lazy val io = defineModule("io")(project)
.dependsOn(geometry, syntax)
Expand Down Expand Up @@ -65,7 +64,7 @@ lazy val pan = defineModule("pan")(project)
lazy val syntax = defineModule("syntax")(project)

lazy val testing = defineModule("testing", false)(project)
.dependsOn(imaging, numeric)
.dependsOn(geometry, imaging, numeric)
.settings(libraryDependencies ++= Seq(
scalacheck,
ironScalacheck,
Expand Down
19 changes: 19 additions & 0 deletions modules/testing/src/main/scala/GeometricInstances.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package at.ac.oeaw.imba.gerlich.gerlib.testing

import cats.syntax.all.*
import org.scalacheck.*

import at.ac.oeaw.imba.gerlich.gerlib.geometry.*

trait GeometricInstances extends CatsScalacheckInstances:
given arbitraryForXCoordinate[C](using c: Arbitrary[C]): Arbitrary[XCoordinate[C]] = c.fmap(XCoordinate.apply)

given arbitraryForYCoordinate[C](using c: Arbitrary[C]): Arbitrary[YCoordinate[C]] = c.fmap(YCoordinate.apply)

given arbitraryForZCoordinate[C](using c: Arbitrary[C]): Arbitrary[ZCoordinate[C]] = c.fmap(ZCoordinate.apply)

given arbitraryForPoint3D[C](using
x: Arbitrary[XCoordinate[C]],
y: Arbitrary[YCoordinate[C]],
z: Arbitrary[ZCoordinate[C]],
): Arbitrary[Point3D[C]] = (x, y, z).mapN(Point3D.apply)

0 comments on commit 52aa280

Please sign in to comment.