19 lines
495 B
Go
19 lines
495 B
Go
package system
|
|
|
|
import "testing"
|
|
|
|
func TestWhenRe(t *testing.T) {
|
|
valid := []string{"now", "+0", "+5", "+120", "0:00", "9:30", "23:59", "07:05"}
|
|
for _, w := range valid {
|
|
if !whenRe.MatchString(w) {
|
|
t.Errorf("whenRe.MatchString(%q) = false, want true", w)
|
|
}
|
|
}
|
|
invalid := []string{"", "-r", "-h", "--help", "24:00", "9:60", "+5; reboot", "now ", "5", "1:2"}
|
|
for _, w := range invalid {
|
|
if whenRe.MatchString(w) {
|
|
t.Errorf("whenRe.MatchString(%q) = true, want false", w)
|
|
}
|
|
}
|
|
}
|