You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
48 lines
1.7 KiB
Go
48 lines
1.7 KiB
Go
package when
|
|
|
|
import (
|
|
"fmt"
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
func TestParse(t *testing.T) {
|
|
for k, code := range []string{"一个小时后告诉我事情", "三个小时后爱我", "每两个小时提醒我吃饭",
|
|
"每五个月零二十五天三小时25分15秒告诉我时间", "5月23日上午3点24分12秒打我", "周五上午11点提醒我", "5时25分提醒我",
|
|
"每周一到周五上午8点提醒我吃饭", "每天晚上8点提醒我吃饭", "每月16号晚上8点提醒我吃饭", "晚上8:30提醒我",
|
|
"晚上八点半提醒我", "6分钟后提醒我", "凌晨0点半", "每20秒提醒我", "半小时后提醒我", "半分钟后提醒我", "一分半后提醒我", "00:00提醒我", "凌晨零点提醒我", "今晚九点二十提醒我", "周五九点二十提醒我"} {
|
|
a, err := WhenWithPeriod(code)
|
|
//fmt.Println(a.Repeats()[0])
|
|
if err != nil {
|
|
fmt.Println(err)
|
|
}
|
|
fmt.Println(a.NextTimer(), a.RunCountLimit(), code, k)
|
|
fmt.Println(a.NextTimerAfterDate(time.Now().Add(time.Hour * 72)))
|
|
}
|
|
}
|
|
|
|
func TestSigParse(t *testing.T) {
|
|
for _, code := range []string{"周五九点二十提醒我"} {
|
|
a, err := WhenWithPeriod(code)
|
|
fmt.Println(err)
|
|
fmt.Println(a.NextTimer(), a.RunCountLimit(), code)
|
|
pm := a.NextTimer()
|
|
fmt.Println(pm)
|
|
fmt.Println(a.NextTimerAfterDate(time.Now().Add(time.Hour * 72)))
|
|
}
|
|
}
|
|
|
|
func TestInvalid(t *testing.T) {
|
|
for k, code := range []string{"每周一周二周四中午11点30分提醒我带夹子和雨伞"} {
|
|
a, err := WhenWithPeriod(code)
|
|
if err != nil {
|
|
fmt.Println(err)
|
|
return
|
|
}
|
|
//fmt.Println(a.Repeats()[0])
|
|
fmt.Println(a.ExportRepeats())
|
|
fmt.Println(a.NextTimer(), a.RunCountLimit(), code, k)
|
|
fmt.Println(a.NextTimerAfterDate(time.Now().Add(time.Hour * 72)))
|
|
}
|
|
}
|