Codebase list golang-github-vbauerster-mpb / 620e1ec
Refactoring writer_posix_test Vladimir Bauer 8 years ago
1 changed file(s) with 7 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
99 "github.com/vbauerster/mpb/cwriter"
1010 )
1111
12 var clearSequence = fmt.Sprintf("%c[%dA%c[2K\r", 27, 1, 27)
12 var (
13 cursorUp = fmt.Sprintf("%c[%dA", cwriter.ESC, 1)
14 clearLine = fmt.Sprintf("%c[2K\r", cwriter.ESC)
15 clearCursorAndLine = cursorUp + clearLine
16 )
1317
1418 // TestWriterPosix by writing and flushing many times. The output buffer
1519 // must contain the clearCursor and clearLine sequences.
2125 input, expectedOutput string
2226 }{
2327 {input: "foo\n", expectedOutput: "foo\n"},
24 {input: "bar\n", expectedOutput: "foo\n" + clearSequence + "bar\n"},
25 {input: "fizz\n", expectedOutput: "foo\n" + clearSequence + "bar\n" + clearSequence + "fizz\n"},
28 {input: "bar\n", expectedOutput: "foo\n" + clearCursorAndLine + "bar\n"},
29 {input: "fizz\n", expectedOutput: "foo\n" + clearCursorAndLine + "bar\n" + clearCursorAndLine + "fizz\n"},
2630 } {
2731 t.Run(tcase.input, func(t *testing.T) {
2832 w.Write([]byte(tcase.input))