Skip to content

Commit

Permalink
fix Gen[java.time.Duration] and increase num of tests
Browse files Browse the repository at this point in the history
  • Loading branch information
melrief committed May 11, 2017
1 parent ef34c6f commit 89c799f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
2 changes: 2 additions & 0 deletions core/src/test/scala/pureconfig/BasicConvertersSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import scala.concurrent.duration.{ Duration, FiniteDuration }

class BasicConvertersSuite extends BaseSuite {

implicit override val generatorDrivenConfig = PropertyCheckConfiguration(minSuccessful = 100)

behavior of "ConfigConvert"

checkArbitrary[Duration]
Expand Down
5 changes: 5 additions & 0 deletions core/src/test/scala/pureconfig/gen/package.scala
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ package object gen {
val genJavaDuration: Gen[JavaDuration] = for {
seconds <- Gen.choose(Long.MinValue + 1, Long.MaxValue)
nanoseconds <- Gen.choose(0L, MaximumNanoseconds)
// JDK Bug: when seconds % 60 == -1 and nanoseconds > 0, Duration.toString produces
// a strange value for the seconds with is -0. followed by 1000_000_000 - nanoseconds
// e.g. Duration.ofSeconds(-1, 1).toString returns PT-0.999999999S
// Duration.parse loads this value as PT0.999999999S instead of the original value
if nanoseconds == 0 || seconds % 60 != -1
} yield JavaDuration.ofSeconds(seconds, nanoseconds)

val genDuration: Gen[Duration] =
Expand Down

0 comments on commit 89c799f

Please sign in to comment.