1
0
mirror of https://github.com/MontFerret/ferret.git synced 2025-02-03 13:11:45 +02:00
ferret/pkg/runtime/values/int_test.go
Tim Voronov 2baac62d1e
Bugfix/#559 html escaping (#573)
Added jettison for json encoding
2020-11-23 20:12:04 -05:00

45 lines
830 B
Go

package values_test
import (
"encoding/json"
"github.com/MontFerret/ferret/pkg/runtime/values"
. "github.com/smartystreets/goconvey/convey"
"testing"
)
func TestInt(t *testing.T) {
Convey(".Hash", t, func() {
Convey("It should calculate hash", func() {
v := values.NewInt(1)
h := v.Hash()
So(h, ShouldBeGreaterThan, 0)
v2 := values.NewInt(2)
So(h, ShouldNotEqual, v2.Hash())
})
Convey("Hash sum should be consistent", func() {
v := values.NewInt(1)
So(v.Hash(), ShouldEqual, v.Hash())
})
})
Convey(".MarshalJSON", t, func() {
Convey("It should correctly serialize value", func() {
value := 10
json1, err := json.Marshal(value)
So(err, ShouldBeNil)
json2, err := values.NewInt(value).MarshalJSON()
So(err, ShouldBeNil)
So(json1, ShouldResemble, json2)
})
})
}