-
Notifications
You must be signed in to change notification settings - Fork 2
/
to_utf8_test.go
86 lines (63 loc) · 1.27 KB
/
to_utf8_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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
package ansiart2utf8
import (
"bufio"
"io/ioutil"
"os"
"testing"
)
//const TEST_DIR = "./test_data"
const TEST_DIR = "./test_data/artwork"
func TestToUTF8(t *testing.T) {
// BUFFER OUTPUT
pWriter := bufio.NewWriter(os.Stdout)
UM := UTF8Marshaller{
Width: 80,
MaxBytes: 0,
Writer: pWriter,
Translate2Xterm256: true,
FakeEsc: false,
}
// DEBUG LOGGING
UM.Debug = func(v ...interface{}) (int, error) {
t.Log(v...)
return 0, nil
}
sFI, oE := ioutil.ReadDir(TEST_DIR)
if oE != nil {
t.Fatal(oE.Error())
}
for _, FI := range sFI {
if FI.IsDir() {
continue
}
/*
TODO: PROBLEMS
textfiles/holiday
wwans53.ans - missing bottom & bag
vday.ans - missing ll corner
FIXED: thanks3.ans - missing line
*/
if FI.Name() != "fruit.ans" {
// continue
}
szFile := TEST_DIR + "/" + FI.Name()
pWriter.WriteString("FILE: " + szFile + "\n")
if oE := testFile(&UM, szFile); oE != nil {
t.Fatal(oE.Error())
return
}
pWriter.WriteByte(CHR_LF)
pWriter.Flush()
}
}
func testFile(pUM *UTF8Marshaller, szFile string) error {
pFile, oE := os.Open(szFile)
if oE != nil {
return oE
}
defer pFile.Close()
if oE = pUM.Encode(pFile); oE != nil {
return oE
}
return nil
}