Skip to content

Commit 44367b8

Browse files
add a test case that run midi file parser on all files in data
1 parent c5106f6 commit 44367b8

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

tests/zmidi-fs-core.Tests/Tests.fs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,38 @@
11
module ZMidi.Tests
2+
open System.IO
23
open Expecto
34
open ZMidi.Internal.ParserMonad
45
open ZMidi.ReadFile
56
open ZMidi.DataTypes
67

78
[<Tests>]
89
let tests =
10+
testList "unit" [
11+
12+
test "parse all files" {
13+
let dir = DirectoryInfo(Path.Combine(__SOURCE_DIRECTORY__, "..", "..", "data"))
14+
let files =
15+
[|
16+
yield! dir.GetFiles("*.midi", SearchOption.AllDirectories)
17+
yield! dir.GetFiles("*.mid", SearchOption.AllDirectories)
18+
|]
19+
let okFiles, errorFiles =
20+
[|
21+
for f in files do
22+
let bytes = File.ReadAllBytes f.FullName
23+
f,runParser
24+
midiFile
25+
bytes
26+
State.initial
27+
|]
28+
|> Array.partition (function (_,Ok _) -> true | (_,Error _) -> false)
29+
printfn "%i files OK, %i files not OK" okFiles.Length errorFiles.Length
30+
for f, error in errorFiles do
31+
printfn "file %s had error: %A" f.FullName error
32+
if errorFiles.Length > 0 then
33+
failtest "failed files present"
34+
}
35+
936
test "parseVarlen" {
1037
let cases =
1138
[|
@@ -54,6 +81,7 @@ let tests =
5481
failwithf "%s" message
5582
}
5683

84+
]
5785

5886
[<EntryPoint>]
5987
let main args =

0 commit comments

Comments
 (0)