| 99 | } |
| 100 | |
| 101 | func TestBits(t *testing.T) { |
| 102 | bits := []struct { |
| 103 | min, max, step uint |
| 104 | expected uint64 |
| 105 | }{ |
| 106 | {0, 0, 1, 0x1}, |
| 107 | {1, 1, 1, 0x2}, |
| 108 | {1, 5, 2, 0x2a}, // 101010 |
| 109 | {1, 4, 2, 0xa}, // 1010 |
| 110 | } |
| 111 | |
| 112 | for _, c := range bits { |
| 113 | actual := getBits(c.min, c.max, c.step) |
| 114 | if c.expected != actual { |
| 115 | t.Errorf("%d-%d/%d => expected %b, got %b", |
| 116 | c.min, c.max, c.step, c.expected, actual) |
| 117 | } |
| 118 | } |
| 119 | } |
| 120 | |
| 121 | func TestParseScheduleErrors(t *testing.T) { |
| 122 | var tests = []struct{ expr, err string }{ |