github.com/artisanhe/tools@v1.0.1-0.20210607022958-19a8fef2eb04/courier/enumeration/bool_test.go (about) 1 package enumeration 2 3 import ( 4 "encoding/json" 5 "testing" 6 7 "github.com/stretchr/testify/assert" 8 ) 9 10 func TestBool(t *testing.T) { 11 tt := assert.New(t) 12 { 13 bytes, _ := json.Marshal(BOOL__TRUE) 14 tt.Equal("true", string(bytes)) 15 } 16 { 17 bytes, _ := json.Marshal(BOOL__FALSE) 18 tt.Equal("false", string(bytes)) 19 } 20 { 21 bytes, _ := json.Marshal(BOOL_UNKNOWN) 22 tt.Equal("null", string(bytes)) 23 } 24 25 { 26 var b Bool 27 json.Unmarshal([]byte("true"), &b) 28 tt.Equal(BOOL__TRUE, b) 29 } 30 { 31 var b Bool 32 json.Unmarshal([]byte("false"), &b) 33 tt.Equal(BOOL__FALSE, b) 34 } 35 { 36 var b Bool 37 json.Unmarshal([]byte("null"), &b) 38 tt.Equal(BOOL_UNKNOWN, b) 39 } 40 }