(t *testing.T)
| 6 | ) |
| 7 | |
| 8 | func TestPos(t *testing.T) { |
| 9 | source := `<html> |
| 10 | |
| 11 | <head> |
| 12 | <title>Test</title> |
| 13 | </head> |
| 14 | |
| 15 | <body> |
| 16 | <p>Hello world</p> |
| 17 | </body> |
| 18 | |
| 19 | </html> |
| 20 | ` |
| 21 | tests := []struct { |
| 22 | body string |
| 23 | pos int |
| 24 | expectedLine int |
| 25 | expectedCol int |
| 26 | }{ |
| 27 | { |
| 28 | body: "", |
| 29 | pos: 0, |
| 30 | expectedLine: 1, |
| 31 | expectedCol: 1, |
| 32 | }, |
| 33 | { |
| 34 | body: source, |
| 35 | pos: 0, |
| 36 | expectedLine: 1, |
| 37 | expectedCol: 1, |
| 38 | }, |
| 39 | { |
| 40 | body: source, |
| 41 | pos: 5, |
| 42 | expectedLine: 1, |
| 43 | expectedCol: 6, |
| 44 | }, |
| 45 | { |
| 46 | body: source, |
| 47 | pos: 20, |
| 48 | expectedLine: 4, |
| 49 | expectedCol: 6, |
| 50 | }, |
| 51 | { |
| 52 | body: source, |
| 53 | pos: 30, |
| 54 | expectedLine: 4, |
| 55 | expectedCol: 16, |
| 56 | }, |
| 57 | { |
| 58 | body: source, |
| 59 | pos: 50, |
| 60 | expectedLine: 7, |
| 61 | expectedCol: 3, |
| 62 | }, |
| 63 | } |
| 64 | |
| 65 | for i, tt := range tests { |