File: callout_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 (30 lines) | stat: -rw-r--r-- 524 bytes parent folder | download | duplicates (2)
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
package parser

import (
	"strconv"
	"testing"
)

func TestIsCallout(t *testing.T) {
	tests := []struct {
		data   []byte
		number int
	}{
		// ok
		{[]byte("<<4>>"), 4},
		// fail
		{[]byte("<<5a5>>"), 0},
	}

	for i, test := range tests {
		bnum, read := IsCallout(test.data)
		num, _ := strconv.Atoi(string(bnum))

		if num != test.number {
			t.Errorf("test %d, want %d, got %d", i, test.number, num)
		}
		if num > 0 && read != len(test.data) {
			t.Errorf("test %d, want %d, got %d", i, len(test.data), read)
		}
	}
}