diff options
| author | Jack Koenig | 2016-08-01 15:58:15 -0700 |
|---|---|---|
| committer | Jack Koenig | 2016-08-01 15:58:15 -0700 |
| commit | 3a3ae041f99f4dd8d87cb76ca4dc8360ec474930 (patch) | |
| tree | 3210ed69f3dbd72e239fb7e7d825779ba3ea2e74 /src/test | |
| parent | 81f631bc87aa22fff8569e96ae5c4e429df9e1d4 (diff) | |
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.
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/scala/firrtlTests/StringSpec.scala | 7 |
1 files changed, 3 insertions, 4 deletions
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) { |
