package system

import "testing"

func TestWhenRe(t *testing.T) {
	for _, tt := range []struct {
		name  string
		value string
		want  bool
	}{
		{name: "now", value: "now", want: true},
		{name: "plus zero", value: "+0", want: true},
		{name: "plus five", value: "+5", want: true},
		{name: "plus 120", value: "+120", want: true},
		{name: "0:00", value: "0:00", want: true},
		{name: "9:30", value: "9:30", want: true},
		{name: "23:59", value: "23:59", want: true},
		{name: "07:05", value: "07:05", want: true},
		{name: "empty", value: "", want: false},
		{name: "flag r", value: "-r", want: false},
		{name: "flag h", value: "-h", want: false},
		{name: "help", value: "--help", want: false},
		{name: "24:00", value: "24:00", want: false},
		{name: "9:60", value: "9:60", want: false},
		{name: "injected command", value: "+5; reboot", want: false},
		{name: "trailing space", value: "now ", want: false},
		{name: "just digit", value: "5", want: false},
		{name: "single colon", value: "1:2", want: false},
	} {
		t.Run(tt.name, func(t *testing.T) {
			if got := whenRe.MatchString(tt.value); got != tt.want {
				t.Errorf("whenRe.MatchString(%q) = %v, want %v", tt.value, got, tt.want)
			}
		})
	}
}
