forked from subosito/twilio
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprice_test.go
45 lines (38 loc) · 924 Bytes
/
price_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
package twilio
import (
"reflect"
"testing"
)
func testPrice(t *testing.T) {
var p Price
err := p.UnmarshalJSON([]byte(`0.74`))
if err != nil {
t.Error("Price.UnmarshalJSON returned an error %q", err)
}
want := 0.74
if !reflect.DeepEqual(p, want) {
t.Errorf("Price.UnmarshalJSON returned %+v, want %+v", p, want)
}
}
func TestPrice_UnmarshalJSON_string(t *testing.T) {
var p Price
err := p.UnmarshalJSON([]byte(`"0.74"`))
if err != nil {
t.Error("Price.UnmarshalJSON returned an error %q", err)
}
want := 0.74
if float64(p) != want {
t.Errorf("Price.UnmarshalJSON returned %+v, want %+v", p, want)
}
}
func TestPrice_UnmarshalJSON_null(t *testing.T) {
var p Price
err := p.UnmarshalJSON([]byte(`null`))
if err != nil {
t.Error("Price.UnmarshalJSON returned an error %q", err)
}
want := 0.0
if float64(p) != want {
t.Errorf("Price.UnmarshalJSON returned %+v, want %+v", p, want)
}
}