| 71 | } |
| 72 | |
| 73 | func TestNewBuffer_All(t *testing.T) { |
| 74 | data := "hell\u04E7 w\U0001F642rld!" |
| 75 | rb := NewBuffer(data) |
| 76 | if got, want := rb.Len(), utf8.RuneCountInString(data); got != want { |
| 77 | t.Errorf("length mismatch: got %d, want %d", got, want) |
| 78 | } |
| 79 | if got, want := rb.Slice(0, rb.Len()), data; got != want { |
| 80 | t.Errorf("slice mismatch: got %q, want %q", got, want) |
| 81 | } |
| 82 | if got, want := rb.Get(8), rune('r'); got != want { |
| 83 | t.Errorf("rune mismatch: got %U, want %U", got, want) |
| 84 | } |
| 85 | if _, ok := rb.(*supplementalBuffer); !ok { |
| 86 | t.Errorf("type mismatch: got %T, want %T", rb, &supplementalBuffer{}) |
| 87 | } |
| 88 | } |
| 89 | |
| 90 | func TestNewBuffer_Empty(t *testing.T) { |
| 91 | data := "" |