File: strings_test.go

package info (click to toggle)
golang-github-kurin-blazer 0.5.3-2
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 580 kB
  • sloc: makefile: 4
file content (34 lines) | stat: -rw-r--r-- 623 bytes parent folder | download | duplicates (3)
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
package base

import (
	"testing"
)

func TestEncodeDecode(t *testing.T) {
	// crashes identified by go-fuzz
	origs := []string{
		"&\x020000",
		"&\x020000\x9c",
		"&\x020\x9c0",
		"&\x0230j",
		"&\x02\x98000",
		"&\x02\x983\xc8j00",
		"00\x000",
		"00\x0000",
		"00\x0000000000000",
		"\x11\x030",
	}

	for _, orig := range origs {
		escaped := escape(orig)
		unescaped, err := unescape(escaped)
		if err != nil {
			t.Errorf("%s: orig: %#v, escaped: %#v, unescaped: %#v\n", err.Error(), orig, escaped, unescaped)
			continue
		}

		if unescaped != orig {
			t.Errorf("expected: %#v, got: %#v", orig, unescaped)
		}
	}
}