File: caption_test.go

package info (click to toggle)
golang-github-gomarkdown-markdown 0.0~git20231115.a660076-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,168 kB
  • sloc: sh: 26; makefile: 5
file content (39 lines) | stat: -rw-r--r-- 739 bytes parent folder | download
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")
	}
}