-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathlib_test.go
More file actions
39 lines (33 loc) · 911 Bytes
/
lib_test.go
File metadata and controls
39 lines (33 loc) · 911 Bytes
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
package fopa_test
import (
"testing"
"github.com/kendfss/fopa"
)
func TestClean(t *testing.T) {
arg := "file#with@bad*chars.txt"
have := fopa.Clean(arg)
want := "file_with_bad_chars.txt"
if have != want {
t.Errorf("have %q (%d), want %q %d", have, len(have), want, len(want))
}
arg = "file#with@bad*chars.txt"
have = fopa.Cleanf(arg, "-")
want = "file-with-bad-chars.txt"
if have != want {
t.Errorf("have %q (%d), want %q %d", have, len(have), want, len(want))
}
}
func TestSanitize(t *testing.T) {
have := fopa.Sanitize("file#with@bad*chars.txt") // Replace forbidden chars
want := "file_with_bad_chars.txt"
if have != want {
t.Errorf("have %q, want %q", have, want)
}
}
func TestRedux(t *testing.T) {
have := fopa.Redux("file___with___chars.txt") // Remove consecutive replacements
want := "file_with_chars.txt"
if have != want {
t.Errorf("have %q, want %q", have, want)
}
}