Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xuri
excelize
提交
7f78464f
excelize
项目概览
xuri
/
excelize
通知
13
Star
2
Fork
4
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
excelize
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
已验证
提交
7f78464f
编写于
5月 23, 2020
作者:
xurime
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add test for ReadZipReader, close #642
上级
82bb1153
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
24 addition
and
12 deletion
+24
-12
excelize_test.go
excelize_test.go
+16
-0
lib.go
lib.go
+2
-12
lib_test.go
lib_test.go
+6
-0
未找到文件。
excelize_test.go
浏览文件 @
7f78464f
...
...
@@ -220,6 +220,22 @@ func TestOpenReader(t *testing.T) {
_
,
err
=
OpenReader
(
r
)
assert
.
EqualError
(
t
,
err
,
"unexpected EOF"
)
_
,
err
=
OpenReader
(
bytes
.
NewReader
([]
byte
{
0x50
,
0x4b
,
0x03
,
0x04
,
0x0a
,
0x00
,
0x09
,
0x00
,
0x63
,
0x00
,
0x47
,
0xa3
,
0xb6
,
0x50
,
0x00
,
0x00
,
0x00
,
0x00
,
0x1c
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x08
,
0x00
,
0x0b
,
0x00
,
0x70
,
0x61
,
0x73
,
0x73
,
0x77
,
0x6f
,
0x72
,
0x64
,
0x01
,
0x99
,
0x07
,
0x00
,
0x02
,
0x00
,
0x41
,
0x45
,
0x03
,
0x00
,
0x00
,
0x21
,
0x06
,
0x59
,
0xc0
,
0x12
,
0xf3
,
0x19
,
0xc7
,
0x51
,
0xd1
,
0xc9
,
0x31
,
0xcb
,
0xcc
,
0x8a
,
0xe1
,
0x44
,
0xe1
,
0x56
,
0x20
,
0x24
,
0x1f
,
0xba
,
0x09
,
0xda
,
0x53
,
0xd5
,
0xef
,
0x50
,
0x4b
,
0x07
,
0x08
,
0x00
,
0x00
,
0x00
,
0x00
,
0x1c
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x50
,
0x4b
,
0x01
,
0x02
,
0x1f
,
0x00
,
0x0a
,
0x00
,
0x09
,
0x00
,
0x63
,
0x00
,
0x47
,
0xa3
,
0xb6
,
0x50
,
0x00
,
0x00
,
0x00
,
0x00
,
0x1c
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x08
,
0x00
,
0x0b
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x20
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x70
,
0x61
,
0x73
,
0x73
,
0x77
,
0x6f
,
0x72
,
0x64
,
0x01
,
0x99
,
0x07
,
0x00
,
0x02
,
0x00
,
0x41
,
0x45
,
0x03
,
0x00
,
0x00
,
0x50
,
0x4b
,
0x05
,
0x06
,
0x00
,
0x00
,
0x00
,
0x00
,
0x01
,
0x00
,
0x01
,
0x00
,
0x41
,
0x00
,
0x00
,
0x00
,
0x5d
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
}))
assert
.
EqualError
(
t
,
err
,
"zip: unsupported compression algorithm"
)
}
func
TestBrokenFile
(
t
*
testing
.
T
)
{
...
...
lib.go
浏览文件 @
7f78464f
...
...
@@ -15,7 +15,6 @@ import (
"container/list"
"fmt"
"io"
"log"
"strconv"
"strings"
"unsafe"
...
...
@@ -59,7 +58,6 @@ func (f *File) saveFileList(name string, content []byte) {
func
readFile
(
file
*
zip
.
File
)
([]
byte
,
error
)
{
rc
,
err
:=
file
.
Open
()
if
err
!=
nil
{
log
.
Println
(
err
)
return
nil
,
err
}
dat
:=
make
([]
byte
,
0
,
file
.
FileInfo
()
.
Size
())
...
...
@@ -176,11 +174,7 @@ func CellNameToCoordinates(cell string) (int, int, error) {
}
col
,
err
:=
ColumnNameToNumber
(
colname
)
if
err
!=
nil
{
return
-
1
,
-
1
,
fmt
.
Errorf
(
msg
,
cell
,
err
)
}
return
col
,
row
,
nil
return
col
,
row
,
err
}
// CoordinatesToCellName converts [X, Y] coordinates to alpha-numeric cell
...
...
@@ -195,11 +189,7 @@ func CoordinatesToCellName(col, row int) (string, error) {
return
""
,
fmt
.
Errorf
(
"invalid cell coordinates [%d, %d]"
,
col
,
row
)
}
colname
,
err
:=
ColumnNumberToName
(
col
)
if
err
!=
nil
{
// Error should never happens here.
return
""
,
fmt
.
Errorf
(
"invalid cell coordinates [%d, %d]: %v"
,
col
,
row
,
err
)
}
return
fmt
.
Sprintf
(
"%s%d"
,
colname
,
row
),
nil
return
fmt
.
Sprintf
(
"%s%d"
,
colname
,
row
),
err
}
// boolPtr returns a pointer to a bool with the given value.
...
...
lib_test.go
浏览文件 @
7f78464f
...
...
@@ -208,3 +208,9 @@ func TestBytesReplace(t *testing.T) {
s
:=
[]
byte
{
0x01
}
assert
.
EqualValues
(
t
,
s
,
bytesReplace
(
s
,
[]
byte
{},
[]
byte
{},
0
))
}
func
TestStack
(
t
*
testing
.
T
)
{
s
:=
NewStack
()
assert
.
Equal
(
t
,
s
.
Peek
(),
nil
)
assert
.
Equal
(
t
,
s
.
Pop
(),
nil
)
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录