(t *testing.T)
| 204 | } |
| 205 | |
| 206 | func TestNormalizeFields(t *testing.T) { |
| 207 | tests := []struct { |
| 208 | name string |
| 209 | input []string |
| 210 | options ParseOption |
| 211 | expected []string |
| 212 | }{ |
| 213 | { |
| 214 | "AllFields_NoOptional", |
| 215 | []string{"0", "5", "*", "*", "*", "*"}, |
| 216 | Second | Minute | Hour | Dom | Month | Dow | Descriptor, |
| 217 | []string{"0", "5", "*", "*", "*", "*"}, |
| 218 | }, |
| 219 | { |
| 220 | "AllFields_SecondOptional_Provided", |
| 221 | []string{"0", "5", "*", "*", "*", "*"}, |
| 222 | SecondOptional | Minute | Hour | Dom | Month | Dow | Descriptor, |
| 223 | []string{"0", "5", "*", "*", "*", "*"}, |
| 224 | }, |
| 225 | { |
| 226 | "AllFields_SecondOptional_NotProvided", |
| 227 | []string{"5", "*", "*", "*", "*"}, |
| 228 | SecondOptional | Minute | Hour | Dom | Month | Dow | Descriptor, |
| 229 | []string{"0", "5", "*", "*", "*", "*"}, |
| 230 | }, |
| 231 | { |
| 232 | "SubsetFields_NoOptional", |
| 233 | []string{"5", "15", "*"}, |
| 234 | Hour | Dom | Month, |
| 235 | []string{"0", "0", "5", "15", "*", "*"}, |
| 236 | }, |
| 237 | { |
| 238 | "SubsetFields_DowOptional_Provided", |
| 239 | []string{"5", "15", "*", "4"}, |
| 240 | Hour | Dom | Month | DowOptional, |
| 241 | []string{"0", "0", "5", "15", "*", "4"}, |
| 242 | }, |
| 243 | { |
| 244 | "SubsetFields_DowOptional_NotProvided", |
| 245 | []string{"5", "15", "*"}, |
| 246 | Hour | Dom | Month | DowOptional, |
| 247 | []string{"0", "0", "5", "15", "*", "*"}, |
| 248 | }, |
| 249 | { |
| 250 | "SubsetFields_SecondOptional_NotProvided", |
| 251 | []string{"5", "15", "*"}, |
| 252 | SecondOptional | Hour | Dom | Month, |
| 253 | []string{"0", "0", "5", "15", "*", "*"}, |
| 254 | }, |
| 255 | } |
| 256 | |
| 257 | for _, test := range tests { |
| 258 | t.Run(test.name, func(t *testing.T) { |
| 259 | actual, err := normalizeFields(test.input, test.options) |
| 260 | if err != nil { |
| 261 | t.Errorf("unexpected error: %v", err) |
| 262 | } |
| 263 | if !reflect.DeepEqual(actual, test.expected) { |
nothing calls this directly
no test coverage detected