make the test smaller, because why not.

This commit is contained in:
DN2 2019-01-10 01:35:39 -08:00
parent 7ff41b1eab
commit 26b2f9be57
1 changed files with 4 additions and 6 deletions

View File

@ -10,17 +10,15 @@ import (
func TestFlexInt(t *testing.T) { func TestFlexInt(t *testing.T) {
t.Parallel() t.Parallel()
a := assert.New(t) a := assert.New(t)
five := []byte(`{"channel": "5"}`)
seven := []byte(`{"channel": 7}`)
auto := []byte(`{"channel": "auto"}`)
type reply struct { type reply struct {
Channel FlexInt `json:"channel"` Channel FlexInt `json:"channel"`
} }
var r reply var r reply
a.Nil(json.Unmarshal(five, &r)) a.Nil(json.Unmarshal([]byte(`{"channel": "5"}`), &r))
a.EqualValues(FlexInt(5), r.Channel) a.EqualValues(FlexInt(5), r.Channel)
a.Nil(json.Unmarshal(seven, &r)) a.Nil(json.Unmarshal([]byte(`{"channel": 7}`), &r))
a.EqualValues(FlexInt(7), r.Channel) a.EqualValues(FlexInt(7), r.Channel)
a.Nil(json.Unmarshal(auto, &r), "a regular string must not produce an unmarshal error") a.Nil(json.Unmarshal([]byte(`{"channel": "auto"}`), &r),
"a regular string must not produce an unmarshal error")
a.EqualValues(FlexInt(0), r.Channel) a.EqualValues(FlexInt(0), r.Channel)
} }