-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprogressbar_test.go
More file actions
84 lines (71 loc) · 1.9 KB
/
progressbar_test.go
File metadata and controls
84 lines (71 loc) · 1.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
package progressbar
import (
"testing"
)
func TestBase(t *testing.T) {
bar := GetNewProgressBar()
bar.SetSpinner(Spinners[6])
pg, _ := bar.Update(0)
result := len(pg)
expected := 172
if result != expected {
t.Errorf(`expected %d, want %d`, expected, result)
}
}
func TestSpinnerState(t *testing.T) {
bar := GetNewProgressBar()
spinner := Spinners[0]
bar.SetSpinner(spinner)
spinnerLen := len(spinner)
for i := range spinnerLen {
pg, _ := bar.Update(i)
result := string([]rune(pg)[0])
expected := spinner[i]
if result != spinner[i] {
t.Errorf(`expected %s, want %s`, expected, result)
}
}
}
func TestChangeSpinner(t *testing.T) {
bar := GetNewProgressBar()
bar.SetSpinner(Spinners[6])
// Check that baseConfig has not been touched
if baseConfig.spinner[0] != Spinners[0][0] {
t.Errorf(`baseConfig was affected by a change in the derived object, want %s`, baseConfig.spinner)
}
}
func TestChangeFillers(t *testing.T) {}
func TestChangeColors(t *testing.T) {}
func TestChangeEdges(t *testing.T) {}
func TestChangeWithPercent(t *testing.T) {}
func TestChangeWithSpinner(t *testing.T) {}
func TestWithoutColors(t *testing.T) {
bar := GetNewProgressBar()
pg1, _ := bar.Update(0)
result1 := len(pg1)
bar.SetColors([2]string{"", ""})
pg2, _ := bar.Update(0)
result2 := len(pg2)
diff := result1 - 5
if diff != result2 {
t.Errorf(`invalid number of bytes in string when color is missing %d, want %d`, result2, diff)
}
}
func TestZeroLenBar(t *testing.T) {
bar := GetNewProgressBar()
bar.SetColors([2]string{"", ""})
err := bar.SetBarLen(0)
if err != nil {
t.Errorf(`error bar.SetBarLen(0): %v`, err)
}
pg1, _ := bar.Update(0)
err = bar.SetBarLen(1)
if err != nil {
t.Errorf(`error bar.SetBarLen(1): %v`, err)
}
pg2, _ := bar.Update(0)
bytesOneSymbol := 3
if len(pg2) != len(pg1)+bytesOneSymbol {
t.Errorf(`invalid string length %d, want %d`, len(pg2), len(pg1)+bytesOneSymbol)
}
}