WriteF writes the string, and ensures it is fully flushed before returning.
(t *testing.T, term MockTerm, str string, args ...any)
| 31 | // WriteF writes the string, and ensures it is fully flushed |
| 32 | // before returning. |
| 33 | func WriteF(t *testing.T, term MockTerm, str string, args ...any) { |
| 34 | t.Helper() |
| 35 | b := fmt.Appendf(nil, str, args...) |
| 36 | for len(b) != 0 { |
| 37 | if n, err := term.Write(b); err != nil { |
| 38 | t.Fatalf("Failed to write: %v", err) |
| 39 | } else { |
| 40 | b = b[n:] |
| 41 | } |
| 42 | } |
| 43 | if err := term.Drain(); err != nil { |
| 44 | t.Fatalf("Failed to flush: %v", err) |
| 45 | } |
| 46 | } |
| 47 | |
| 48 | // ReadF reads content from the term and returns it as a string. |
| 49 | func ReadF(t *testing.T, term MockTerm) string { |
searching dependent graphs…