Last active
April 3, 2016 17:44
-
-
Save dabd/1c550c8d394e5422622afe04b73f0994 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package models | |
import org.scalacheck.Arbitrary._ | |
import org.scalacheck.Shapeless._ | |
import org.scalacheck._ | |
import shapeless.tag | |
import shapeless.tag.{apply => _, _} | |
object ArbitraryModelsSpecification extends Properties("ArbitraryModelsSpecification") { | |
import Prop.forAll | |
// implicit val bigDecimalGen = arbBigDecimal.arbitrary.suchThat(d => d >= 0 && d <= BigDecimal("999999999999.99")) | |
implicit val bigDecimalGen = for { | |
i <- arbBigInt.arbitrary.suchThat(x => x >= 0 && x <= BigInt("999999999999")) | |
d <- Gen.chooseNum(0, 99) | |
} yield BigDecimal(s"$i.$d") | |
implicit val moneyGen: Gen[String @@ Money] = for(m <- bigDecimalGen) yield tag[Money](m.toString()) | |
implicit val arbMoney: Arbitrary[String @@ Money] = Arbitrary(moneyGen) | |
property("someProp") = forAll { m: (String @@ Money) => | |
println(m) | |
true | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment