-
Notifications
You must be signed in to change notification settings - Fork 0
/
input_test.go
47 lines (38 loc) · 1.03 KB
/
input_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
package RefET
import (
"math"
"testing"
)
func Test_ConvertTemp(t *testing.T) {
i := Input{Value: 0, Units: "C"}
i2 := Input{Value: 32, Units: "F"}
i3 := Input{Value: 100, Units: "F"}
testGots := []Input{i, i2, i3}
want := []float64{0.0, 0.0, 37.77778}
for j := 0; j < len(testGots); j++ {
got, err := testGots[j].convertTemp()
if err != nil {
t.Fatal("Error in getting conversions for temp values")
}
if math.Abs(want[j]-got) > tolerance {
t.Errorf("want %f, got %f", want[j], got)
}
}
}
func Test_CovertRA(t *testing.T) {
i := Input{Value: 1, Units: "Langley"}
i2 := Input{Value: 1, Units: "w / m-2"}
i3 := Input{Value: 1.0, Units: "w/m2"}
i4 := Input{Value: 1.0, Units: "MJ/m2/d"}
testGots := []Input{i, i2, i3, i4}
want := []float64{0.04184, 0.0864, 0.0864, 1.0}
for j := 0; j < len(testGots); j++ {
got, err := testGots[j].convertRS()
if err != nil {
t.Fatal("Error in getting conversions for ea values")
}
if math.Abs(want[j]-got) > tolerance {
t.Errorf("want %f, got %f", want[j], got)
}
}
}