File tree Expand file tree Collapse file tree 4 files changed +16
-7
lines changed
scalacheck/src/main/scala/pathy/scalacheck Expand file tree Collapse file tree 4 files changed +16
-7
lines changed Original file line number Diff line number Diff line change
1
+ - improve coverage of ASCII characters in Path generators
Original file line number Diff line number Diff line change @@ -22,19 +22,24 @@ import org.scalacheck.Gen
22
22
23
23
import scalaz .Show
24
24
25
+ /** Newtype for path segment strings with a generator that produces mostly
26
+ * alphanumeric, then any printable ASCII char, with slightly more `.` and `/`
27
+ * characters (because they tend to be problematic for encoders), and finally
28
+ * an occasional char from anywhere in Unicode. */
25
29
private [scalacheck] final case class RandomSeg (str : String ) extends AnyVal
26
30
27
31
private [scalacheck] object RandomSeg {
28
- implicit val randomSegArbitrary : Arbitrary [RandomSeg ] =
32
+ implicit val arbitrary : Arbitrary [RandomSeg ] =
29
33
Arbitrary {
30
34
Gen .nonEmptyListOf(Gen .frequency(
31
- 100 -> Gen .alphaNumChar,
32
- 10 -> Gen .const('.' ),
33
- 10 -> Gen .const('/' ),
34
- 5 -> Arbitrary .arbitrary[Char ]
35
+ 50 -> Gen .alphaChar,
36
+ 25 -> Gen .choose(MinPrintableASCII , MaxPrintableASCII ),
37
+ 10 -> Gen .const('.' ),
38
+ 10 -> Gen .const('/' ),
39
+ 5 -> Arbitrary .arbitrary[Char ]
35
40
)) map (cs => RandomSeg (cs.mkString))
36
41
}
37
42
38
- implicit val randomSegShow : Show [RandomSeg ] =
43
+ implicit val show : Show [RandomSeg ] =
39
44
Show .shows(_.str)
40
45
}
Original file line number Diff line number Diff line change @@ -57,4 +57,7 @@ package object scalacheck {
57
57
t <- Gen .resize(r, sizeDistributedListOfNonEmpty(g))
58
58
} yield (h :: t)
59
59
}
60
+
61
+ val MinPrintableASCII = '\u0020 '
62
+ val MaxPrintableASCII = '\u007e '
60
63
}
Original file line number Diff line number Diff line change 1
- version in ThisBuild := " 0.2.1 "
1
+ version in ThisBuild := " 0.2.2 "
You can’t perform that action at this time.
0 commit comments