-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfio_test.go
More file actions
71 lines (60 loc) · 1.77 KB
/
fio_test.go
File metadata and controls
71 lines (60 loc) · 1.77 KB
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
60
61
62
63
64
65
66
67
68
69
70
71
package main
import (
"encoding/json"
"os"
"path/filepath"
"testing"
)
func TestFiles(t *testing.T) {
inputFileDirs := []string{
"fio-v3.5.x",
"fio-v4.0.x",
}
for _, dir := range inputFileDirs {
fstPath := filepath.Join("testdata", dir, "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
outPath := filepath.Join("testdata", "output", dir)
if err := os.MkdirAll(outPath, 0777); err != nil {
t.Fatal(err)
}
// Use files structure to recreate input files
if err := files.Write(outPath, ""); 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(outPath, "files.json"), b, 0777); err != nil {
t.Fatal(err)
}
// Check that it parsed the appropriate files
if act, exp := len(files.Main), 1; act != exp {
t.Fatalf("Expected %d Main files, got %d", exp, act)
}
if act, exp := len(files.ElastoDyn), 1; act != exp {
t.Fatalf("Expected %d ElastoDyn files, got %d", exp, act)
}
if act, exp := len(files.BeamDyn), 1; act != exp {
t.Fatalf("Expected %d BeamDyn files, got %d", exp, act)
}
if act, exp := len(files.ServoDyn), 1; act != exp {
t.Fatalf("Expected %d ServoDyn files, got %d", exp, act)
}
if act, exp := len(files.InflowWind), 1; act != exp {
t.Fatalf("Expected %d InflowWind files, got %d", exp, act)
}
if act, exp := len(files.AeroDyn), 1; act != exp {
t.Fatalf("Expected %d AeroDyn files, got %d", exp, act)
}
if act, exp := len(files.Misc), 4; act != exp {
t.Fatalf("Expected %d Misc files, got %d", exp, act)
}
}
}