1
0
mirror of https://github.com/MontFerret/ferret.git synced 2025-01-18 03:22:02 +02:00

values.Parse does not parse int64 (#621)

This commit is contained in:
Tim Voronov 2021-05-04 15:20:40 -04:00 committed by GitHub
parent ff5af6f739
commit 833330e73c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 30 additions and 0 deletions

View File

@ -114,6 +114,14 @@ func Parse(input interface{}) core.Value {
return NewBoolean(value)
case string:
return NewString(value)
case int64:
return NewInt(int(value))
case int32:
return NewInt(int(value))
case int16:
return NewInt(int(value))
case int8:
return NewInt(int(value))
case int:
return NewInt(value)
case float64:

View File

@ -159,6 +159,28 @@ func TestHelpers(t *testing.T) {
})
})
Convey("Parse", func() {
Convey("It should parse values", func() {
inputs := []struct {
Parsed core.Value
Raw interface{}
}{
{Parsed: values.NewInt(1), Raw: int(1)},
{Parsed: values.NewInt(1), Raw: int8(1)},
{Parsed: values.NewInt(1), Raw: int16(1)},
{Parsed: values.NewInt(1), Raw: int32(1)},
{Parsed: values.NewInt(1), Raw: int64(1)},
}
for _, input := range inputs {
out := values.Parse(input.Raw)
So(out.Type().ID(), ShouldEqual, input.Parsed.Type().ID())
So(out.Unwrap(), ShouldEqual, input.Parsed.Unwrap())
}
})
})
Convey("ToBoolean", func() {
Convey("Should convert values", func() {
inputs := [][]core.Value{