forked from monochromegane/the_platinum_searcher
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathencoding_test.go
More file actions
33 lines (29 loc) · 706 Bytes
/
Copy pathencoding_test.go
File metadata and controls
33 lines (29 loc) · 706 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
package the_platinum_searcher
import (
"io/ioutil"
"path/filepath"
"testing"
)
type Assert struct {
path string
fileType int
}
var Asserts = []Assert{
Assert{"ascii.txt", ASCII},
Assert{"binary/binary.bin", BINARY},
Assert{"ja/euc-jp.txt", EUCJP},
Assert{"ja/shift_jis.txt", SHIFTJIS},
Assert{"ja/utf8.txt", UTF8},
Assert{"ja/broken_euc-jp.txt", EUCJP},
Assert{"ja/broken_shift_jis.txt", SHIFTJIS},
Assert{"ja/broken_utf8.txt", UTF8},
}
func TestIdentifyType(t *testing.T) {
for _, f := range Asserts {
b, _ := ioutil.ReadFile(filepath.Join("files", f.path))
fileType := detectEncoding(b)
if fileType != f.fileType {
t.Errorf("%s should be %d.", f.path, f.fileType)
}
}
}