File: esc_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 (22 lines) | stat: -rw-r--r-- 557 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
package parser

import "testing"

func TestIsEscape(t *testing.T) {
	if x := `\a`; !isEscape([]byte(x), 1) {
		t.Errorf("expected escape for %q, got false", x)
	}
	if x := `\\\a`; !isEscape([]byte(x), 3) {
		t.Errorf("expected escape for %q, got false", x)
	}
	if x := `b\\\a`; !isEscape([]byte(x), 4) {
		t.Errorf("expected escape for %q, got false", x)
	}

	if x := `\\a`; isEscape([]byte(x), 2) {
		t.Errorf("expected no escape for %q, got true", x)
	}
	if x := `\\\\a`; isEscape([]byte(x), 4) {
		t.Errorf("expected no escape for %q, got true", x)
	}
}