refactor: updated tests to new syntax
ci/woodpecker/pr/lint Pipeline failed
Details
ci/woodpecker/pr/docs Pipeline was successful
Details
ci/woodpecker/pr/build Pipeline was successful
Details
ci/woodpecker/pr/docker Pipeline was successful
Details
ci/woodpecker/pr/man Pipeline was successful
Details
ci/woodpecker/pr/test Pipeline was successful
Details
ci/woodpecker/pr/lint Pipeline failed
Details
ci/woodpecker/pr/docs Pipeline was successful
Details
ci/woodpecker/pr/build Pipeline was successful
Details
ci/woodpecker/pr/docker Pipeline was successful
Details
ci/woodpecker/pr/man Pipeline was successful
Details
ci/woodpecker/pr/test Pipeline was successful
Details
parent
161341a108
commit
96a9798d3f
|
@ -11,88 +11,88 @@ fn parse_range_error(s string, min int, max int) string {
|
|||
}
|
||||
|
||||
// =====parse_range=====
|
||||
fn test_range_star_range() ? {
|
||||
fn test_range_star_range() ! {
|
||||
mut bitv := []bool{len: 6, init: false}
|
||||
parse_range('*', 0, 5, mut bitv)?
|
||||
parse_range('*', 0, 5, mut bitv)!
|
||||
|
||||
assert bitv == [true, true, true, true, true, true]
|
||||
}
|
||||
|
||||
fn test_range_number() ? {
|
||||
fn test_range_number() ! {
|
||||
mut bitv := []bool{len: 6, init: false}
|
||||
parse_range('4', 0, 5, mut bitv)?
|
||||
parse_range('4', 0, 5, mut bitv)!
|
||||
|
||||
assert bitv_to_ints(bitv, 0) == [4]
|
||||
}
|
||||
|
||||
fn test_range_number_too_large() ? {
|
||||
fn test_range_number_too_large() ! {
|
||||
assert parse_range_error('10', 0, 6) == 'Out of range.'
|
||||
}
|
||||
|
||||
fn test_range_number_too_small() ? {
|
||||
fn test_range_number_too_small() ! {
|
||||
assert parse_range_error('0', 2, 6) == 'Out of range.'
|
||||
}
|
||||
|
||||
fn test_range_number_invalid() ? {
|
||||
fn test_range_number_invalid() ! {
|
||||
assert parse_range_error('x', 0, 6) == 'Invalid number.'
|
||||
}
|
||||
|
||||
fn test_range_step_star_1() ? {
|
||||
fn test_range_step_star_1() ! {
|
||||
mut bitv := []bool{len: 21, init: false}
|
||||
parse_range('*/4', 0, 20, mut bitv)?
|
||||
parse_range('*/4', 0, 20, mut bitv)!
|
||||
|
||||
assert bitv_to_ints(bitv, 0) == [0, 4, 8, 12, 16, 20]
|
||||
}
|
||||
|
||||
fn test_range_step_star_2() ? {
|
||||
fn test_range_step_star_2() ! {
|
||||
mut bitv := []bool{len: 8, init: false}
|
||||
parse_range('*/3', 1, 8, mut bitv)?
|
||||
parse_range('*/3', 1, 8, mut bitv)!
|
||||
|
||||
assert bitv_to_ints(bitv, 1) == [1, 4, 7]
|
||||
}
|
||||
|
||||
fn test_range_step_star_too_large() ? {
|
||||
fn test_range_step_star_too_large() ! {
|
||||
assert parse_range_error('*/21', 0, 20) == 'Step size too large.'
|
||||
}
|
||||
|
||||
fn test_range_step_zero() ? {
|
||||
fn test_range_step_zero() ! {
|
||||
assert parse_range_error('*/0', 0, 20) == 'Step size zero not allowed.'
|
||||
}
|
||||
|
||||
fn test_range_step_number() ? {
|
||||
fn test_range_step_number() ! {
|
||||
mut bitv := []bool{len: 21, init: false}
|
||||
parse_range('5/4', 2, 22, mut bitv)?
|
||||
parse_range('5/4', 2, 22, mut bitv)!
|
||||
|
||||
assert bitv_to_ints(bitv, 2) == [5, 9, 13, 17, 21]
|
||||
}
|
||||
|
||||
fn test_range_step_number_too_large() ? {
|
||||
fn test_range_step_number_too_large() ! {
|
||||
assert parse_range_error('10/4', 0, 5) == 'Out of range.'
|
||||
}
|
||||
|
||||
fn test_range_step_number_too_small() ? {
|
||||
fn test_range_step_number_too_small() ! {
|
||||
assert parse_range_error('2/4', 5, 10) == 'Out of range.'
|
||||
}
|
||||
|
||||
fn test_range_dash() ? {
|
||||
fn test_range_dash() ! {
|
||||
mut bitv := []bool{len: 10, init: false}
|
||||
parse_range('4-8', 0, 9, mut bitv)?
|
||||
parse_range('4-8', 0, 9, mut bitv)!
|
||||
|
||||
assert bitv_to_ints(bitv, 0) == [4, 5, 6, 7, 8]
|
||||
}
|
||||
|
||||
fn test_range_dash_step() ? {
|
||||
fn test_range_dash_step() ! {
|
||||
mut bitv := []bool{len: 10, init: false}
|
||||
parse_range('4-8/2', 0, 9, mut bitv)?
|
||||
parse_range('4-8/2', 0, 9, mut bitv)!
|
||||
|
||||
assert bitv_to_ints(bitv, 0) == [4, 6, 8]
|
||||
}
|
||||
|
||||
// =====parse_part=====
|
||||
fn test_part_single() ? {
|
||||
assert parse_part('*', 0, 5)? == [0, 1, 2, 3, 4, 5]
|
||||
fn test_part_single() ! {
|
||||
assert parse_part('*', 0, 5)! == [0, 1, 2, 3, 4, 5]
|
||||
}
|
||||
|
||||
fn test_part_multiple() ? {
|
||||
assert parse_part('*/2,2/3', 1, 8)? == [1, 2, 3, 5, 7, 8]
|
||||
fn test_part_multiple() ! {
|
||||
assert parse_part('*/2,2/3', 1, 8)! == [1, 2, 3, 5, 7, 8]
|
||||
}
|
||||
|
|
|
@ -2,12 +2,12 @@ module expression
|
|||
|
||||
import time { parse }
|
||||
|
||||
fn util_test_time(exp string, t1_str string, t2_str string) ? {
|
||||
ce := parse_expression(exp)?
|
||||
t1 := parse(t1_str)?
|
||||
t2 := parse(t2_str)?
|
||||
fn util_test_time(exp string, t1_str string, t2_str string) ! {
|
||||
ce := parse_expression(exp)!
|
||||
t1 := parse(t1_str)!
|
||||
t2 := parse(t2_str)!
|
||||
|
||||
t3 := ce.next(t1)?
|
||||
t3 := ce.next(t1)!
|
||||
|
||||
assert t2.year == t3.year
|
||||
assert t2.month == t3.month
|
||||
|
@ -16,19 +16,19 @@ fn util_test_time(exp string, t1_str string, t2_str string) ? {
|
|||
assert t2.minute == t3.minute
|
||||
}
|
||||
|
||||
fn test_next_simple() ? {
|
||||
fn test_next_simple() ! {
|
||||
// Very simple
|
||||
util_test_time('0 3', '2002-01-01 00:00:00', '2002-01-01 03:00:00')?
|
||||
util_test_time('0 3', '2002-01-01 00:00:00', '2002-01-01 03:00:00')!
|
||||
|
||||
// Overlap to next day
|
||||
util_test_time('0 3', '2002-01-01 03:00:00', '2002-01-02 03:00:00')?
|
||||
util_test_time('0 3', '2002-01-01 04:00:00', '2002-01-02 03:00:00')?
|
||||
util_test_time('0 3', '2002-01-01 03:00:00', '2002-01-02 03:00:00')!
|
||||
util_test_time('0 3', '2002-01-01 04:00:00', '2002-01-02 03:00:00')!
|
||||
|
||||
util_test_time('0 3/4', '2002-01-01 04:00:00', '2002-01-01 07:00:00')?
|
||||
util_test_time('0 3/4', '2002-01-01 04:00:00', '2002-01-01 07:00:00')!
|
||||
|
||||
// Overlap to next month
|
||||
util_test_time('0 3', '2002-11-31 04:00:00', '2002-12-01 03:00:00')?
|
||||
util_test_time('0 3', '2002-11-31 04:00:00', '2002-12-01 03:00:00')!
|
||||
|
||||
// Overlap to next year
|
||||
util_test_time('0 3', '2002-12-31 04:00:00', '2003-01-01 03:00:00')?
|
||||
util_test_time('0 3', '2002-12-31 04:00:00', '2003-01-01 03:00:00')!
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue