github.com/MontFerret/ferret@v0.18.0/pkg/runtime/values/int_test.go (about) 1 package values_test 2 3 import ( 4 "encoding/json" 5 "testing" 6 7 . "github.com/smartystreets/goconvey/convey" 8 9 "github.com/MontFerret/ferret/pkg/runtime/values" 10 ) 11 12 func TestInt(t *testing.T) { 13 Convey(".Hash", t, func() { 14 Convey("It should calculate hash", func() { 15 v := values.NewInt(1) 16 17 h := v.Hash() 18 19 So(h, ShouldBeGreaterThan, 0) 20 21 v2 := values.NewInt(2) 22 23 So(h, ShouldNotEqual, v2.Hash()) 24 }) 25 26 Convey("Hash sum should be consistent", func() { 27 v := values.NewInt(1) 28 29 So(v.Hash(), ShouldEqual, v.Hash()) 30 }) 31 }) 32 33 Convey(".MarshalJSON", t, func() { 34 Convey("It should correctly serialize value", func() { 35 value := 10 36 37 json1, err := json.Marshal(value) 38 So(err, ShouldBeNil) 39 40 json2, err := values.NewInt(value).MarshalJSON() 41 So(err, ShouldBeNil) 42 43 So(json1, ShouldResemble, json2) 44 }) 45 }) 46 }