forked from cdipaolo/goml
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsanitize_test.go
57 lines (42 loc) · 1.77 KB
/
sanitize_test.go
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
45
46
47
48
49
50
51
52
53
54
55
56
57
package base
import (
"testing"
"golang.org/x/text/transform"
"github.com/stretchr/testify/assert"
)
func TestWordsAndNumbersShouldPass1(t *testing.T) {
s, _, _ := transform.String(transform.RemoveFunc(OnlyWordsAndNumbers), "THIS iz A L337 aNd Un'Sani~~~~tized sentence")
sanitized := []rune(s)
for i := range sanitized {
assert.False(t, OnlyWordsAndNumbers(sanitized[i]), "Letter %v should be sanitized", sanitized[i])
}
}
func TestWordsAndNumbersShouldPass2(t *testing.T) {
s, _, _ := transform.String(transform.RemoveFunc(OnlyWordsAndNumbers), ")(*&^%$@!@#$%^&*(*&^%$#@#$%")
sanitized := []rune(s)
assert.Equal(t, 0, len(sanitized), "Length of string should be 0")
}
func TestWordsShouldPass1(t *testing.T) {
s, _, _ := transform.String(transform.RemoveFunc(OnlyWords), "THIS iz A L337 aNd Un'Sani~~~~tized sentence")
sanitized := []rune(s)
for i := range sanitized {
assert.False(t, OnlyWords(sanitized[i]), "Letter %v should be sanitized", sanitized[i])
}
}
func TestWordsShouldPass2(t *testing.T) {
s, _, _ := transform.String(transform.RemoveFunc(OnlyWords), "08765432123456789)(*&^%$@!@#$%^&*(*&^%$#@#$%")
sanitized := []rune(s)
assert.Equal(t, 0, len(sanitized), "Length of string should be 0")
}
func TestLettersShouldPass1(t *testing.T) {
s, _, _ := transform.String(transform.RemoveFunc(OnlyLetters), "THIS iz A L337 aNd Un'Sani~~~~tized sentence")
sanitized := []rune(s)
for i := range sanitized {
assert.False(t, OnlyLetters(sanitized[i]), "Letter %v should be sanitized", sanitized[i])
}
}
func TestLettersShouldPass2(t *testing.T) {
s, _, _ := transform.String(transform.RemoveFunc(OnlyLetters), "0876543212 3456789)(*&^ %$@!@#$%^& *(*&^%$#@#$%")
sanitized := []rune(s)
assert.Equal(t, 0, len(sanitized), "Length of string should be 0")
}