-
Notifications
You must be signed in to change notification settings - Fork 2
/
fio_test.go
59 lines (51 loc) · 1.26 KB
/
fio_test.go
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package main
import (
"encoding/json"
"os"
"path/filepath"
"testing"
)
func TestFiles(t *testing.T) {
const fstPath = "testdata/fio/NREL_5MW.fst"
// Parse main file and associated files
files, err := ParseFiles(fstPath)
if err != nil {
t.Fatalf("error parsing '%s': %s", fstPath, err)
}
// Create output directory to write files to
path := filepath.Join("testdata", "output", "fio")
if err := os.MkdirAll(path, 0777); err != nil {
t.Fatal(err)
}
// Use files structure to recreate input files
if err := files.Write(path, ""); err != nil {
t.Fatal(err)
}
// Write file data as JSON file
b, err := json.MarshalIndent(files, "", "\t")
if err != nil {
t.Fatal(err)
}
if err := os.WriteFile(filepath.Join(path, "files.json"), b, 0777); err != nil {
t.Fatal(err)
}
// Check that it parsed the appropriate files
if len(files.Main) != 1 {
t.Fatal("Failed to read fst file")
}
if len(files.ElastoDyn) != 1 {
t.Fatal("Failed to read ElastoDyn file")
}
if len(files.BeamDyn) != 1 {
t.Fatal("Failed to read BeamDyn file")
}
if len(files.ServoDyn) != 1 {
t.Fatal("Failed to read ServoDyn file")
}
if len(files.AeroDyn) != 1 {
t.Fatal("Failed to read AeroDyn file")
}
if len(files.Misc) != 4 {
t.Fatal("Failed to read all Misc files")
}
}