@@ -170,6 +170,7 @@ func TestIsWithinRange(t *testing.T) {
170
170
spec string
171
171
at time.Time
172
172
expectedWithinRange bool
173
+ expectedError string
173
174
}{
174
175
// "* 9-18 * * 1-5" should be interpreted as a continuous time range from 08:59:00 to 18:58:59, Monday through Friday
175
176
{
@@ -238,13 +239,30 @@ func TestIsWithinRange(t *testing.T) {
238
239
at :mustParseTime (t ,time .RFC1123 ,"Sun, 08 Jun 2025 14:00:00 UTC" ),
239
240
expectedWithinRange :false ,
240
241
},
242
+ {
243
+ name :"Check that Sunday is supported with value 0" ,
244
+ spec :"* 9-18 * * 0" ,
245
+ at :mustParseTime (t ,time .RFC1123 ,"Sun, 08 Jun 2025 14:00:00 UTC" ),
246
+ expectedWithinRange :true ,
247
+ },
248
+ {
249
+ name :"Check that value 7 is rejected as out of range" ,
250
+ spec :"* 9-18 * * 7" ,
251
+ at :mustParseTime (t ,time .RFC1123 ,"Sun, 08 Jun 2025 14:00:00 UTC" ),
252
+ expectedError :"end of range (7) above maximum (6): 7" ,
253
+ },
241
254
}
242
255
243
256
for _ ,testCase := range testCases {
244
257
testCase := testCase
245
258
t .Run (testCase .name ,func (t * testing.T ) {
246
259
t .Parallel ()
247
260
sched ,err := cron .Weekly (testCase .spec )
261
+ if testCase .expectedError != "" {
262
+ require .Error (t ,err )
263
+ require .Contains (t ,err .Error (),testCase .expectedError )
264
+ return
265
+ }
248
266
require .NoError (t ,err )
249
267
withinRange := sched .IsWithinRange (testCase .at )
250
268
require .Equal (t ,testCase .expectedWithinRange ,withinRange )