Help at ScalaCheck

I would like to use the ScalaTest Checkers property to use ScalaCheck from ScalaTest cases.

The simple case I'm playing with is:

 test("can create local date UTC from millis") {
     check(localDate.toTimestampUTC.toLocalDateUTC == localDate)
 }

I need to create an arbitrary LocalDate, so I tried this:

object ArbitraryValues {
    implicit def abc(): Arbitrary[LocalDate] = Arbitrary(Gen.choose(new LocalDate(0L), new LocalDate(Long.MaxValue)))
}

It does not compile, saying:

error: could not find the implicit parameter value c: org.scalacheck.Choose [org.joda.time.LocalDate] implicit val abc: Optional [LocalDate] = Optional (Gen.choose (new LocalDate (0L), new LocalDate (Long. MaxValue)))

and

error: not found: value localDate check (localDate.toTimestampUTC.toLocalDateUTC == localDate)

+5
source share
1 answer

. :

object ArbitraryValues {
    implicit val abc: Arbitrary[LocalDate] = Arbitrary(Gen.choose(0L, Long.MaxValue).map(new LocalDate(_)))
}

test("can create local date UTC from millis -and- vice versa") { check((localDate: LocalDate) =>
    localDate.toTimestampUTC.toLocalDateUTC == localDate)
}

[LocalDate], .

+7

All Articles