2018-10-05 21:17:22 +02:00
|
|
|
package values_test
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/MontFerret/ferret/pkg/runtime/values"
|
|
|
|
. "github.com/smartystreets/goconvey/convey"
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestString(t *testing.T) {
|
|
|
|
Convey(".Hash", t, func() {
|
|
|
|
Convey("It should calculate hash", func() {
|
|
|
|
v := values.NewString("a")
|
|
|
|
|
|
|
|
h := v.Hash()
|
|
|
|
|
|
|
|
So(h, ShouldBeGreaterThan, 0)
|
|
|
|
|
|
|
|
v2 := values.NewString("b")
|
|
|
|
|
|
|
|
So(h, ShouldNotEqual, v2.Hash())
|
|
|
|
})
|
|
|
|
|
|
|
|
Convey("Hash sum should be consistent", func() {
|
|
|
|
v := values.NewString("foobar")
|
|
|
|
|
|
|
|
So(v.Hash(), ShouldEqual, v.Hash())
|
|
|
|
})
|
|
|
|
})
|
2019-02-24 20:21:34 +02:00
|
|
|
|
|
|
|
Convey(".Length", t, func() {
|
|
|
|
Convey("Should return unicode length", func() {
|
|
|
|
str := values.NewString("Спутник")
|
|
|
|
|
|
|
|
So(str.Length(), ShouldEqual, 7)
|
|
|
|
})
|
|
|
|
})
|
2018-10-05 21:17:22 +02:00
|
|
|
}
|