From b9a07b104a5f19331741525039e6324fe347cab4 Mon Sep 17 00:00:00 2001 From: kingeasternsun Date: Thu, 26 Aug 2021 10:58:54 +0800 Subject: [PATCH] Update gcron_schedule_test.go add test to slash template parse --- os/gcron/gcron_schedule_test.go | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/os/gcron/gcron_schedule_test.go b/os/gcron/gcron_schedule_test.go index 1404ba74d..cfb4c5ffd 100644 --- a/os/gcron/gcron_schedule_test.go +++ b/os/gcron/gcron_schedule_test.go @@ -4,8 +4,33 @@ import ( "strings" "testing" "time" + + "github.com/gogf/gf/test/gtest" ) +func TestSlash(t *testing.T) { + + runs := []struct { + spec string + expected map[int]struct{} + }{ + {"0 0 0 * Feb Mon/2", map[int]struct{}{1: struct{}{}, 3: struct{}{}, 5: struct{}{}}}, + {"0 0 0 * Feb *", map[int]struct{}{1: struct{}{}, 2: struct{}{}, 3: struct{}{}, 4: struct{}{}, 5: struct{}{}, 6: struct{}{}, 0: struct{}{}}}, + } + + gtest.C(t, func(t *gtest.T) { + for _, c := range runs { + sched, err := newSchedule(c.spec) + if err != nil { + t.Fatal(err) + + } + t.AssertEQ(sched.week, c.expected) + } + }) + +} + func TestNext(t *testing.T) { runs := []struct { time, spec string