I new to property-based and unit testing, and in my project I want to to use this technique, but unfortunately it is easy to say... I watched a talk about FsCheck.XUnit library, but the guy was testing numeric function (modulus)... And I want to test functions that use strings, lists and arrays.. Maybe you guys could give a hint or a source where I can look through? P.S. every where I was looking there were only numerical example, which looked like pretty easy to test.
There are some functions I wish to test:
let wordSplit (text:string) =
text.Split([|' ';'\n';'\r';'\t';'!';',';'.';'?';';';':'; '/'
;'\\';'-';'+'; '*'; '#';'(';')';'^';'"';'\'';'`'; '@';'~';'|'|]
,StringSplitOptions.RemoveEmptyEntries)
|> Array.toList
let rec matchTails (tail1 : string list) (tail2 : string list) =
match tail1, tail2 with
| h1::t1 , h2::t2 ->
if (h1=h2) then
matchTails t1 t2
else
false
| [], _ -> false
| _, [] -> true
let rec phraseProcessor (textH: string) (textT: string list) (phrases: string list list) (n:int) =
match phrases with
|[] -> n
| h :: t ->
match h with
|x when x.Head = textH && (matchTails (textT) (x.Tail)) ->
phraseProcessor (textH) (textT) (t) (n+1)
| _ ->
phraseProcessor (textH) (textT) (t) (n)
let rec wordChanger (phrases : string list list) (text:string list) (n:int)=
match text with
| [] -> n
| h :: t ->
wordChanger phrases t (phraseProcessor (h) (t) (phrases) (n))