forked from hashicorp/cap
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconn_test.go
More file actions
44 lines (39 loc) · 1.16 KB
/
conn_test.go
File metadata and controls
44 lines (39 loc) · 1.16 KB
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
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
package ldap
import (
"testing"
)
var testcases = map[string]string{
"#test": "\\#test",
"test,hello": "test\\,hello",
"test,hel+lo": "test\\,hel\\+lo",
"test\\hello": "test\\\\hello",
" test ": "\\ test \\ ",
"": "",
`\`: `\\`,
"trailing\000": `trailing\00`,
"mid\000dle": `mid\00dle`,
"\000": `\00`,
"multiple\000\000": `multiple\00\00`,
"backlash-before-null\\\000": `backlash-before-null\\\00`,
"trailing\\": `trailing\\`,
"double-escaping\\>": `double-escaping\\\>`,
}
func Test_EscapeValue(t *testing.T) {
for test, answer := range testcases {
res := escapeValue(test)
if res != answer {
t.Errorf("Failed to escape %q: %q != %q\n", test, res, answer)
}
}
}
// Fuzz_EscapeValue is only focused on finding panics
func Fuzz_EscapeValue(f *testing.F) {
for tc := range testcases {
f.Add(tc)
}
f.Fuzz(func(t *testing.T, s string) {
_ = escapeValue(s)
})
}