Skip to content

Commit

Permalink
Merge pull request #214 from twitter/ianoc/fixFlakyScroogeTest
Browse files Browse the repository at this point in the history
Fixes flaky test
  • Loading branch information
ianoc committed May 13, 2015
2 parents 34d5d79 + 174d6f7 commit a428acd
Showing 1 changed file with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,17 @@ import com.twitter.bijection.{ CheckProperties, BaseProperties, Bijection, Injec
import org.scalatest.{ PropSpec, MustMatchers }
import org.scalatest.prop.PropertyChecks

import org.scalacheck.Arbitrary
import org.scalacheck.{ Gen, Arbitrary }

class ScroogeCodecLaws extends CheckProperties with BaseProperties {
def buildScrooge(i: (Int, String)) =
TestStruct(i._1, Some(i._2))

implicit val testScrooge = arbitraryViaFn { is: (Int, String) => buildScrooge(is) }
implicit val testScrooge: Arbitrary[TestStruct] = Arbitrary {
for {
l <- Gen.oneOf('a' to 'z')
u <- Gen.oneOf('A' to 'Z')
s <- Gen.listOf(Gen.oneOf(l, u, Gen.numChar)).map(_.mkString)
i <- Arbitrary.arbitrary[Int]
} yield TestStruct(i, Some(s))
}

// Code generator for thrift instances.
def roundTripsScrooge[B](bijection: Injection[TestStruct, B]) = {
Expand Down

0 comments on commit a428acd

Please sign in to comment.