-
Notifications
You must be signed in to change notification settings - Fork 154
/
char.scala
32 lines (23 loc) · 1020 Bytes
/
char.scala
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package eu.timepit.refined.scalacheck
import eu.timepit.refined.api.RefType
import eu.timepit.refined.char._
import org.scalacheck.{Arbitrary, Gen}
/**
* Module that provides `Arbitrary` instances for `Char` related
* predicates.
*/
object char extends CharInstances
trait CharInstances {
implicit def digitArbitrary[F[_, _]: RefType]: Arbitrary[F[Char, Digit]] =
arbitraryRefType(Gen.numChar)
implicit def letterArbitrary[F[_, _]: RefType]: Arbitrary[F[Char, Letter]] =
arbitraryRefType(Gen.alphaChar)
implicit def lowerCaseArbitrary[F[_, _]: RefType]: Arbitrary[F[Char, LowerCase]] =
arbitraryRefType(Gen.alphaLowerChar)
implicit def upperCaseArbitrary[F[_, _]: RefType]: Arbitrary[F[Char, UpperCase]] =
arbitraryRefType(Gen.alphaUpperChar)
implicit def whitespaceArbitrary[F[_, _]: RefType]: Arbitrary[F[Char, Whitespace]] =
arbitraryRefType(Gen.oneOf(whitespaceChars))
private val whitespaceChars: Seq[Char] =
(Char.MinValue to Char.MaxValue).filter(_.isWhitespace)
}