@@ -54,7 +54,7 @@ type StringNoNulls = StringNoNulls of string with
54
54
member x.Get = match x with StringNoNulls r -> r
55
55
override x.ToString () = x.Get
56
56
57
- // Represents a string that is not null, empty or consists only of white-space characters and does not contain any null characters ('\000')
57
+ /// Represents a string that is not null, empty or consists only of white-space characters and does not contain any null characters ('\000')
58
58
type NonWhiteSpaceString = NonWhiteSpaceString of string with
59
59
member x.Get = match x with NonWhiteSpaceString s -> s
60
60
override x.ToString () = x.Get
@@ -64,6 +64,16 @@ type XmlEncodedString = XmlEncodedString of string with
64
64
member x.Get = match x with XmlEncodedString v -> v
65
65
override x.ToString () = x.Get
66
66
67
+ ///Represents a unicode char.
68
+ type UnicodeChar = UnicodeChar of char with
69
+ member x.Get = match x with UnicodeChar c -> c
70
+ override x.ToString () = string x.Get
71
+
72
+ ///Represents a string that can contain unicode characters.
73
+ type UnicodeString = UnicodeString of string with
74
+ member x.Get = match x with UnicodeString v -> v
75
+ override x.ToString () = x.Get
76
+
67
77
///Represents an integer interval.
68
78
type Interval = Interval of int * int with
69
79
member x.Left = match x with Interval ( l,_) -> l
@@ -974,6 +984,26 @@ module Arb =
974
984
|> convert XmlEncodedString string
975
985
#endif
976
986
987
+ static member UnicodeChar () : Arbitrary < UnicodeChar > =
988
+ let generator =
989
+ Gen.choose ( int Char.MinValue, int Char.MaxValue)
990
+ |> Gen.map ( char >> UnicodeChar)
991
+
992
+ let shrinker ( UnicodeChar c ) = seq { for c' in [ 'a' ; 'b' ; 'c' ] do if c' < c || not ( Char.IsLower c) then yield UnicodeChar c' }
993
+ fromGenShrink ( generator, shrinker)
994
+
995
+
996
+ static member UnicodeString () : Arbitrary < UnicodeString > =
997
+ let generator =
998
+ generate< UnicodeChar[]>
999
+ |> Gen.map ( fun chars -> String( chars |> Array.map ( fun c -> c.Get)) |> UnicodeString)
1000
+ let shrinker ( UnicodeString s ) =
1001
+ match s with
1002
+ | null -> Seq.empty
1003
+ | _ -> s.ToCharArray() |> shrink |> Seq.map ( String >> UnicodeString)
1004
+ fromGenShrink ( generator, shrinker)
1005
+
1006
+
977
1007
static member Set () =
978
1008
Default.FsList()
979
1009
|> convert Set.ofList Set.toList
0 commit comments