| 88 | } |
| 89 | |
| 90 | func TestNewBuffer_Empty(t *testing.T) { |
| 91 | data := "" |
| 92 | rb := NewBuffer(data) |
| 93 | if got, want := rb.Len(), utf8.RuneCountInString(data); got != want { |
| 94 | t.Errorf("length mismatch: got %d, want %d", got, want) |
| 95 | } |
| 96 | if got, want := rb.Slice(0, rb.Len()), data; got != want { |
| 97 | t.Errorf("slice mismatch: got %q, want %q", got, want) |
| 98 | } |
| 99 | if _, ok := rb.(*emptyBuffer); !ok { |
| 100 | t.Errorf("type mismatch: got %T, want %T", rb, &emptyBuffer{}) |
| 101 | } |
| 102 | } |
| 103 | |
| 104 | func TestNewBufferAndLineOffsetsWithLimit_Exceeded(t *testing.T) { |
| 105 | _, _, err := NewBufferAndLineOffsetsWithLimit("greetings", 5) |