| 20 | ) |
| 21 | |
| 22 | func TestNewBuffer_ASCII(t *testing.T) { |
| 23 | data := "hello world!" |
| 24 | rb := NewBuffer(data) |
| 25 | if got, want := rb.Len(), utf8.RuneCountInString(data); got != want { |
| 26 | t.Errorf("length mismatch: got %d, want %d", got, want) |
| 27 | } |
| 28 | if got, want := rb.Slice(0, rb.Len()), data; got != want { |
| 29 | t.Errorf("slice mismatch: got %q, want %q", got, want) |
| 30 | } |
| 31 | if got, want := rb.Get(8), rune('r'); got != want { |
| 32 | t.Errorf("rune mismatch: got %U, want %U", got, want) |
| 33 | } |
| 34 | if _, ok := rb.(*asciiBuffer); !ok { |
| 35 | t.Errorf("type mismatch: got %T, want %T", rb, &asciiBuffer{}) |
| 36 | } |
| 37 | } |
| 38 | |
| 39 | func TestNewBuffer_Basic(t *testing.T) { |
| 40 | data := "hello w\u04E7rld!" |