| 1 | package ansi |
| 2 | |
| 3 | import "testing" |
| 4 | |
| 5 | func TestSetProgress(t *testing.T) { |
| 6 | expect := "\x1b]9;4;1;50\x07" |
| 7 | got := SetProgressBar(50) |
| 8 | if expect != got { |
| 9 | t.Errorf("SetProgress(50) = %q, want %q", got, expect) |
| 10 | } |
| 11 | } |
| 12 | |
| 13 | func TestSetProgressNegative(t *testing.T) { |
| 14 | expect := "\x1b]9;4;1;0\x07" |
| 15 | got := SetProgressBar(-2) |
| 16 | if expect != got { |
| 17 | t.Errorf("SetProgress(-2) = %q, want %q", got, expect) |
| 18 | } |
| 19 | } |
| 20 | |
| 21 | func TestSetProgressAbove100(t *testing.T) { |
| 22 | expect := "\x1b]9;4;1;100\x07" |
| 23 | got := SetProgressBar(200) |
| 24 | if expect != got { |
| 25 | t.Errorf("SetProgress(200) = %q, want %q", got, expect) |
| 26 | } |
| 27 | } |
| 28 | |
| 29 | func TestSetErrorProgress(t *testing.T) { |
| 30 | expect := "\x1b]9;4;2;50\x07" |
| 31 | got := SetErrorProgressBar(50) |
| 32 | if expect != got { |
| 33 | t.Errorf("SetProgress(50) = %q, want %q", got, expect) |
| 34 | } |
| 35 | } |
| 36 | |
| 37 | func TestSetErrorProgressNegative(t *testing.T) { |
| 38 | expect := "\x1b]9;4;2;0\x07" |
| 39 | got := SetErrorProgressBar(-2) |
| 40 | if expect != got { |
| 41 | t.Errorf("SetErrorProgress(-2) = %q, want %q", got, expect) |
| 42 | } |
| 43 | } |
| 44 | |
| 45 | func TestSetErrorProgressAbove100(t *testing.T) { |
| 46 | expect := "\x1b]9;4;2;100\x07" |
| 47 | got := SetErrorProgressBar(200) |
| 48 | if expect != got { |
| 49 | t.Errorf("SetErrorProgress(200) = %q, want %q", got, expect) |
| 50 | } |
| 51 | } |
| 52 | |
| 53 | func TestSetWarningProgress(t *testing.T) { |
| 54 | expect := "\x1b]9;4;4;50\x07" |
| 55 | got := SetWarningProgressBar(50) |
| 56 | if expect != got { |
| 57 | t.Errorf("SetProgress(50) = %q, want %q", got, expect) |
| 58 | } |
| 59 | } |
| 60 | |
| 61 | func TestSetWarningProgressNegative(t *testing.T) { |
| 62 | expect := "\x1b]9;4;4;0\x07" |
| 63 | got := SetWarningProgressBar(-2) |
| 64 | if expect != got { |
| 65 | t.Errorf("SetWarningProgress(-2) = %q, want %q", got, expect) |
| 66 | } |
| 67 | } |
| 68 | |
| 69 | func TestSetWarningProgressAbove100(t *testing.T) { |
| 70 | expect := "\x1b]9;4;4;100\x07" |
| 71 | got := SetWarningProgressBar(200) |
| 72 | if expect != got { |
| 73 | t.Errorf("SetWarningProgress(200) = %q, want %q", got, expect) |
| 74 | } |
| 75 | } |