1
0
mirror of https://github.com/MontFerret/ferret.git synced 2024-12-14 11:23:02 +02:00
ferret/pkg/stdlib/datetime/dayofweek_test.go

44 lines
966 B
Go
Raw Normal View History

2018-11-01 01:26:36 +02:00
package datetime_test
import (
"testing"
"github.com/MontFerret/ferret/pkg/runtime/core"
"github.com/MontFerret/ferret/pkg/runtime/values"
"github.com/MontFerret/ferret/pkg/stdlib/datetime"
)
func TestDateDayOfWeek(t *testing.T) {
tcs := []*testCase{
&testCase{
Name: "When more than 1 arguments",
Expected: values.None,
Args: []core.Value{
values.NewString("string"),
values.NewInt(0),
},
ShouldErr: true,
},
&testCase{
Name: "When 0 arguments",
Expected: values.None,
Args: []core.Value{},
ShouldErr: true,
},
&testCase{
Name: "When Sunday (0th day)",
Expected: values.NewInt(0),
Args: []core.Value{mustDefaultLayoutDt("1999-02-07T15:04:05Z")},
},
&testCase{
Name: "When Monday (1th day)",
Expected: values.NewInt(1),
Args: []core.Value{mustDefaultLayoutDt("1999-02-08T15:04:05Z")},
},
}
for _, tc := range tcs {
tc.Do(t, datetime.DateDayOfWeek)
}
}