Created
March 2, 2016 00:20
-
-
Save gilles-leblanc/003b1b9857f082b6c297 to your computer and use it in GitHub Desktop.
fsharp tests
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Tests | |
// modules under test | |
open HeightMap | |
open MidpointDisplacement | |
// assert functions | |
let assertAreEqual expected actual = | |
if expected <> actual then | |
sprintf "Test failed, expected %A, actual %A" expected, actual | |
else | |
"Test passed" | |
// tests included in run | |
let testsToRun = | |
[ | |
"test newHeightMap will return a 0 initialized height map", | |
fun() -> | |
let hm = newHeightMap 5 | |
let result = hm.Map |> Array.sum | |
assertAreEqual 0.0 result | |
] | |
// test runner | |
let runSingleTest (testName, testFunction) = | |
sprintf "%s... %s" testName, testFunction() | |
let runTests testList = | |
testList |> List.map runSingleTest | |
printfn "%s" "Ran all tests." | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment