-
Notifications
You must be signed in to change notification settings - Fork 267
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a white space after prefix and before suffix
- Loading branch information
Showing
2 changed files
with
33 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package pb | ||
|
||
import ( | ||
"strings" | ||
"testing" | ||
) | ||
|
||
func TestPreset(t *testing.T) { | ||
prefix := "Prefix" | ||
suffix := "Suffix" | ||
|
||
for _, preset := range []ProgressBarTemplate{Full, Default, Simple} { | ||
bar := preset.New(100). | ||
SetCurrent(20). | ||
Set("prefix", prefix). | ||
Set("suffix", suffix). | ||
SetWidth(50) | ||
|
||
// initialize the internal state | ||
_, _ = bar.render() | ||
s := bar.String() | ||
if !strings.HasPrefix(s, prefix+" ") { | ||
t.Error("prefix not found:", s) | ||
} | ||
if !strings.HasSuffix(s, " "+suffix) { | ||
t.Error("suffix not found:", s) | ||
} | ||
} | ||
} |