(t *testing.T)
| 6 | ) |
| 7 | |
| 8 | func TestMultiPrinterGetString(t *testing.T) { |
| 9 | t.Parallel() |
| 10 | |
| 11 | for _, test := range []struct { |
| 12 | name string |
| 13 | buf string |
| 14 | want string |
| 15 | }{ |
| 16 | { |
| 17 | name: "test1", |
| 18 | buf: "test\rtest2\rtest3", |
| 19 | want: "test3\n", |
| 20 | }, |
| 21 | { |
| 22 | name: "test2", |
| 23 | buf: "\r\n", |
| 24 | want: "", |
| 25 | }, |
| 26 | { |
| 27 | name: "test3", |
| 28 | buf: "test", |
| 29 | want: "test\n", |
| 30 | }, |
| 31 | { |
| 32 | name: "test4", |
| 33 | buf: "", |
| 34 | want: "", |
| 35 | }, |
| 36 | } { |
| 37 | test := test // pin for pre-go1.22 versions |
| 38 | t.Run(test.name, func(t *testing.T) { |
| 39 | t.Parallel() |
| 40 | |
| 41 | p := DefaultMultiPrinter |
| 42 | p.buffers = []*bytes.Buffer{ |
| 43 | bytes.NewBufferString(test.buf), |
| 44 | } |
| 45 | |
| 46 | if test.want != p.getString() { |
| 47 | t.Errorf("got %v, want %v", p.getString(), test.want) |
| 48 | } |
| 49 | }) |
| 50 | } |
| 51 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…