-
Notifications
You must be signed in to change notification settings - Fork 0
/
main_test.go
50 lines (39 loc) · 995 Bytes
/
main_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
package main
import (
"testing"
"github.com/nilsmagnus/grib/griblib"
)
func Test_tocoord(t *testing.T) {
const di = 2500000
const la1 = 90000000
section3 := griblib.Section3{Definition: &griblib.Grid0{
Di: di,
Dj: di,
Lo1: 0,
Lo2: 357500000,
La1: la1,
Nj: 144,
Ni: 73,
}}
coordse := toCoords(45, section3)
if coordse.Lon != (45 * di) {
t.Errorf("Expected lon %d, got %d", 45*di, coordse.Lon)
}
count2 := 144*3 + 45
coords2 := toCoords(count2, section3)
if coords2.Lon != (45 * di) {
t.Errorf("Expected lon2 %d, got %d, index %v", 45*di, coords2.Lon, coords2.Lon/di)
}
if coords2.Lat != la1+(3*di) {
t.Errorf("Expected lat2 %d, got %d", la1+3*di, coords2.Lat)
}
}
func Test_offset_from_filename(t *testing.T) {
offset, err := forecastHourFromFileName("aftenpoften101")
if err != nil {
t.Errorf("Should be valid format with three trailing digits, %v", err)
}
if offset != 101 {
t.Errorf("Offset should have been 101, was %d", offset)
}
}