1
0
mirror of https://github.com/MontFerret/ferret.git synced 2025-03-05 15:16:07 +02:00

Fixed incorrect String.length (#238)

* Fixed incorrect String.length
This commit is contained in:
Tim Voronov 2019-02-24 13:21:34 -05:00 committed by GitHub
parent eb523f01cc
commit 14dd7ac40b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 1 deletions

View File

@ -106,7 +106,7 @@ func (t String) Copy() core.Value {
}
func (t String) Length() Int {
return Int(len(t))
return Int(len([]rune(string(t))))
}
func (t String) Contains(other String) Boolean {

View File

@ -26,4 +26,12 @@ func TestString(t *testing.T) {
So(v.Hash(), ShouldEqual, v.Hash())
})
})
Convey(".Length", t, func() {
Convey("Should return unicode length", func() {
str := values.NewString("Спутник")
So(str.Length(), ShouldEqual, 7)
})
})
}