-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain_test.go
58 lines (55 loc) · 1004 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
51
52
53
54
55
56
57
58
package main
import (
"fmt"
"testing"
)
func TestWeatherResponse_ShortString(t *testing.T) {
cases := []struct {
wr WeatherResponse
want string
}{
{
WeatherResponse{
Name: "Berlin",
Main: struct {
Temp float64 `json:"temp"`
FeelsLike float64 `json:"feels_like"`
}{
9.07, 6.24,
},
},
"Berlin, +9°",
},
{
WeatherResponse{
Name: "Berlin",
Main: struct {
Temp float64 `json:"temp"`
FeelsLike float64 `json:"feels_like"`
}{
12.94, 5.81,
},
},
"Berlin, +13°",
},
{
WeatherResponse{
Name: "Berlin",
Main: struct {
Temp float64 `json:"temp"`
FeelsLike float64 `json:"feels_like"`
}{
-5.55, -12.2,
},
},
"Berlin, -6°",
},
}
for n, tc := range cases {
t.Run(fmt.Sprintf("case=%d", n), func(t *testing.T) {
if got := tc.wr.ShortString(); got != tc.want {
t.Errorf("WeatherResponse.ShortString: want %q, got %q", tc.want, got)
}
})
}
}