File: file_index_test.go

package info (click to toggle)
goiardi 0.11.9-3
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 2,728 kB
  • sloc: sql: 4,994; makefile: 156; sh: 95; python: 30
file content (33 lines) | stat: -rw-r--r-- 724 bytes parent folder | download | duplicates (4)
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
package indexer

import "testing"

func TestUnescapeSpecials(t *testing.T) {
	specials := []string{
		`+`, `-`, `&&`, `||`,
		`!`, `(`, `)`, `{`, `}`,
		`[`, `]`, `^`, `"`, `~`,
		`*`, `?`, `:`, `\`,
	}
	for _, s := range specials {
		in := `\` + s
		if out := unescape(in); out != s {
			t.Errorf("Unescaping %s failed. expected = %s, got = %s", in, s, out)
		}
	}
}

func TestUnescapedStrings(t *testing.T) {
	tests := []struct {
		in, out string
	}{
		{`00\:01\:02`, `00:01:02`},
		{`foo \&& bar`, `foo && bar`},
		{`some\\file\\path`, `some\file\path`},
	}
	for _, tt := range tests {
		if out := unescape(tt.in); out != tt.out {
			t.Errorf("Unescaping %s failed. expected = %s, got = %s", tt.in, tt.out, out)
		}
	}
}