1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
|
package parser
import "testing"
func TestLinesUntilEmpty(t *testing.T) {
data := `Figure: foo bar bar foo
foo bar
first text after empty line`
l := LinesUntilEmpty([]byte(data))
if l != 33 {
t.Errorf("want %d, got %d", 33, l)
}
data = `Figure: foo bar bar foo
foo bar
`
l = LinesUntilEmpty([]byte(data))
if l != 32 {
t.Errorf("want %d, got %d", 33, l)
}
}
func TestCaptionID(t *testing.T) {
data := `Figure: foo bar bar foo
first text {#no-heading} after empty line`
if id, _ := captionID([]byte(data)); id != "" {
t.Errorf("want nothing, got %s", id)
}
data = `Figure: foo bar bar foo
foo bar {#heading-id}
`
if id, _ := captionID([]byte(data)); id == "" {
t.Errorf("want %s, got nothing", "heading-id")
}
}
|