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 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
|
package parser
import (
"testing"
"github.com/gomarkdown/markdown/ast"
)
func TestCitation(t *testing.T) {
data := []byte(`[@!RFC1035]`)
p := New()
p.extensions |= Mmark
_, node := citation(p, data, 0)
dest := string(node.(*ast.Citation).Destination[0])
if dest != "RFC1035" {
t.Errorf("failed to find citation, want %s, got %s", "RFC1035", dest)
}
tp := node.(*ast.Citation).Type[0]
if tp != ast.CitationTypeNormative {
t.Errorf("failed to find citation type, want %d, got %d", ast.CitationTypeNormative, tp)
}
}
func TestCitationSuffix(t *testing.T) {
data := []byte(`[@!RFC1035, p. 144]`)
p := New()
p.extensions |= Mmark
_, node := citation(p, data, 0)
if dest := string(node.(*ast.Citation).Destination[0]); dest != "RFC1035" {
t.Errorf("failed to find citation, want %s, got %s", "RFC1035", dest)
}
tp := node.(*ast.Citation).Type[0]
if tp != ast.CitationTypeNormative {
t.Errorf("failed to find citation type, want %d, got %d", ast.CitationTypeNormative, tp)
}
suff := string(node.(*ast.Citation).Suffix[0])
if suff != "p. 144" {
t.Errorf("failed to find citation suffix, want %s, got %s", "p. 144", suff)
}
}
func TestCitationSuffixMultiple(t *testing.T) {
data := []byte(`[@?RFC1034; @!RFC1035, p. 144, more]`)
p := New()
p.extensions |= Mmark
_, node := citation(p, data, 0)
if dest := string(node.(*ast.Citation).Destination[0]); dest != "RFC1034" {
t.Errorf("failed to find citation, want %s, got %s", "RFC1034", dest)
}
tp := node.(*ast.Citation).Type[0]
if tp != ast.CitationTypeInformative {
t.Errorf("failed to find citation type, want %d, got %d", ast.CitationTypeInformative, tp)
}
if dest := string(node.(*ast.Citation).Destination[1]); dest != "RFC1035" {
t.Errorf("failed to find citation, want %s, got %s", "RFC1035", dest)
}
suff := string(node.(*ast.Citation).Suffix[1])
if suff != "p. 144, more" {
t.Errorf("failed to find citation suffix, want %s, got %s", "p. 144, more", suff)
}
}
|