| 24 | ) |
| 25 | |
| 26 | func TestFormatterWrite(t *testing.T) { |
| 27 | buf := bytes.Buffer{} |
| 28 | f := Formatter{ |
| 29 | Writer: &buf, |
| 30 | } |
| 31 | |
| 32 | f.Write("Lorem ipsum dolor sit amet, consectetur adipiscing elit.") |
| 33 | // Indent creates a new Formatter |
| 34 | f.Indent(5).Write("Morbi at turpis faucibus, gravida dolor ut, fringilla velit.") |
| 35 | // So Indent(2) doesn't indent to 7 here. |
| 36 | f.Indent(2).Write("Etiam maximus urna at tellus faucibus mattis.") |
| 37 | |
| 38 | want := `Lorem ipsum dolor sit amet, consectetur adipiscing elit. |
| 39 | Morbi at turpis faucibus, gravida dolor ut, fringilla velit. |
| 40 | Etiam maximus urna at tellus faucibus mattis. |
| 41 | ` |
| 42 | |
| 43 | if buf.String() != want { |
| 44 | t.Errorf("Got:\n%v\nWant:\n%v\n", buf.String(), want) |
| 45 | } |
| 46 | } |
| 47 | |
| 48 | func TestFormatterWrappedWrite(t *testing.T) { |
| 49 | buf := bytes.Buffer{} |