From 3a3ae041f99f4dd8d87cb76ca4dc8360ec474930 Mon Sep 17 00:00:00 2001 From: Jack Koenig Date: Mon, 1 Aug 2016 15:58:15 -0700 Subject: Fix StringSpec generators to only choose from valid values. The old almost equivalent syntax gives the same result but can cause the test to fail if too many invalid values are thrown away. --- src/test/scala/firrtlTests/StringSpec.scala | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/test/scala/firrtlTests/StringSpec.scala b/src/test/scala/firrtlTests/StringSpec.scala index 04bc663e..62634c44 100644 --- a/src/test/scala/firrtlTests/StringSpec.scala +++ b/src/test/scala/firrtlTests/StringSpec.scala @@ -109,13 +109,12 @@ class StringSpec extends FirrtlPropSpec { } // Generators for random testing - val validChar = for (c <- Gen.choose(0x20.toChar, 0x7e.toChar) if c != '\\') yield c + val validChar = Gen.oneOf((0x20.toChar to 0x5b.toChar).toSeq ++ + (0x5e.toChar to 0x7e.toChar).toSeq) // exclude '\\' val validCharSeq = Gen.containerOf[Seq, Char](validChar) val invalidChar = Gen.oneOf(Gen.choose(0x00.toChar, 0x1f.toChar), Gen.choose(0x7f.toChar, 0xff.toChar)) - val invalidEsc = for ( - c <- Gen.choose(0x00.toChar, 0xff.toChar - ) if (!validEsc.contains(c))) yield c + val invalidEsc = Gen.oneOf((0x00.toChar to 0xff.toChar).toSeq diff validEsc) property("Random invalid strings should fail") { forAll(validCharSeq, invalidChar, validCharSeq) { -- cgit v1.2.3