(t *testing.T)
| 10 | ) |
| 11 | |
| 12 | func TestBuffer(t *testing.T) { |
| 13 | // 0 12 3 4 5 6 7 8 9 01 |
| 14 | s := `<svg><path d="M0 0L1 1z"/>text<tag/>text</svg>` |
| 15 | r := parse.NewInputString(s) |
| 16 | z := NewTokenBuffer(r, xml.NewLexer(r)) |
| 17 | |
| 18 | tok := z.Shift() |
| 19 | test.That(t, tok.Hash == Svg, "first token is <svg>") |
| 20 | test.That(t, z.pos == 0, "shift first token and restore position") |
| 21 | test.That(t, len(z.buf) == 0, "shift first token and restore length") |
| 22 | |
| 23 | test.That(t, z.Peek(2).Hash == D, "third token is d") |
| 24 | test.That(t, z.pos == 0, "don't change position after peeking") |
| 25 | test.That(t, len(z.buf) == 3, "mtwo tokens after peeking") |
| 26 | |
| 27 | test.That(t, z.Peek(8).Hash == Svg, "ninth token is <svg>") |
| 28 | test.That(t, z.pos == 0, "don't change position after peeking") |
| 29 | test.That(t, len(z.buf) == 9, "nine tokens after peeking") |
| 30 | |
| 31 | test.That(t, z.Peek(9).TokenType == xml.ErrorToken, "tenth token is an error") |
| 32 | test.That(t, z.Peek(9) == z.Peek(10), "tenth and eleventh token are EOF") |
| 33 | test.That(t, len(z.buf) == 10, "ten tokens after peeking") |
| 34 | |
| 35 | _ = z.Shift() |
| 36 | tok = z.Shift() |
| 37 | test.That(t, tok.Hash == Path, "third token is <path>") |
| 38 | test.That(t, z.pos == 2, "don't change position after peeking") |
| 39 | } |
| 40 | |
| 41 | func TestAttributes(t *testing.T) { |
| 42 | r := parse.NewInputString(`<rect x="0" y="1" width="2" height="3" rx="4" ry="5"/>`) |
nothing calls this directly
no test coverage detected
searching dependent graphs…