Skip to content

Commit 7d19db3

Browse files
committed
test updates
removed getImgInfo() & loadImage()
1 parent d012e6d commit 7d19db3

File tree

3 files changed

+19
-29
lines changed

3 files changed

+19
-29
lines changed

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ module github.com/BourgeoisBear/rasterm
22

33
go 1.16
44

5-
require golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d
5+
require golang.org/x/term v0.18.0

go.sum

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68 h1:nxC68pudNYkKU6jWhgrqdreuFiOQWj1Fs7T3VrH4Pjw=
2-
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
3-
golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d h1:SZxvLBoTP5yHO3Frd4z4vrF+DBX9vMVanchswa69toE=
4-
golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
1+
golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4=
2+
golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
3+
golang.org/x/term v0.18.0 h1:FcHjZXDMxI8mM3nwhX9HlKop4C0YQvCVCdwYl2wOtE8=
4+
golang.org/x/term v0.18.0/go.mod h1:ILwASektA3OnRv7amZ1xhE/KTR+u50pbXfZ03+6Nx58=

rasterm_test.go

+14-24
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,6 @@ func init() {
3232
os.Stdout.Write([]byte(ESC_ERASE_DISPLAY))
3333
}
3434

35-
func loadImage(path string) (iImg image.Image, imgFmt string, E error) {
36-
37-
pF, E := os.Open(path)
38-
if E != nil {
39-
return
40-
}
41-
defer pF.Close()
42-
43-
return image.Decode(pF)
44-
}
45-
4635
func getFile(fpath string) (*os.File, int64, error) {
4736

4837
pF, E := os.Open(fpath)
@@ -59,17 +48,6 @@ func getFile(fpath string) (*os.File, int64, error) {
5948
return pF, fInf.Size(), nil
6049
}
6150

62-
func getImgInfo(pF *os.File) (imgCfg image.Config, fmtName string, E error) {
63-
64-
if imgCfg, fmtName, E = image.DecodeConfig(pF); E != nil {
65-
return
66-
}
67-
68-
// REWIND FILE
69-
_, E = pF.Seek(0, 0)
70-
return
71-
}
72-
7351
type TestLogger interface {
7452
Log(...interface{})
7553
Logf(string, ...interface{})
@@ -106,13 +84,25 @@ func testEx(iLog TestLogger, out io.Writer, mode string, testFiles []string) err
10684

10785
fmt.Println(fpath)
10886

109-
imgCfg, fmtName, e2 := getImgInfo(fIn)
87+
imgCfg, fmtName, e2 := image.DecodeConfig(fIn)
88+
if e2 != nil {
89+
iLog.Log(e2)
90+
continue
91+
}
92+
93+
_, e2 = fIn.Seek(0, 0)
94+
if e2 != nil {
95+
iLog.Log(e2)
96+
continue
97+
}
98+
99+
iImg, _, e2 := image.Decode(fIn)
110100
if e2 != nil {
111101
iLog.Log(e2)
112102
continue
113103
}
114104

115-
iImg, _, e2 := loadImage(fpath)
105+
_, e2 = fIn.Seek(0, 0)
116106
if e2 != nil {
117107
iLog.Log(e2)
118108
continue

0 commit comments

Comments
 (0)