mirror of
https://gitee.com/johng/gf.git
synced 2024-11-30 19:27:46 +08:00
edit TestTruncate fun
This commit is contained in:
parent
ff473e2fcc
commit
1868465319
2
TODO.MD
2
TODO.MD
@ -1,4 +1,4 @@
|
|||||||
# ON THE WAY go go go
|
# ON THE WAY
|
||||||
1. 增加图形验证码支持,至少支持数字和英文字母;
|
1. 增加图形验证码支持,至少支持数字和英文字母;
|
||||||
1. Cookie&Session数据池化处理;
|
1. Cookie&Session数据池化处理;
|
||||||
1. ghttp.Client增加proxy特性;
|
1. ghttp.Client增加proxy特性;
|
||||||
|
@ -72,8 +72,8 @@ func TestGetContents(t *testing.T) {
|
|||||||
func TestGetBinContents(t *testing.T) {
|
func TestGetBinContents(t *testing.T) {
|
||||||
gtest.Case(t, func() {
|
gtest.Case(t, func() {
|
||||||
var (
|
var (
|
||||||
filepaths1 string = "/testfile_t1.txt" //存在文件
|
filepaths1 string = "/testfile_t1.txt" //文件存在时
|
||||||
filepaths2 string = Testpath() + "/testfile_t1_no.txt" //不存大文件
|
filepaths2 string = Testpath() + "/testfile_t1_no.txt" //文件不存在时
|
||||||
readcontent []byte
|
readcontent []byte
|
||||||
str1 string = "my name is jroam"
|
str1 string = "my name is jroam"
|
||||||
)
|
)
|
||||||
@ -85,9 +85,6 @@ func TestGetBinContents(t *testing.T) {
|
|||||||
readcontent = GetBinContents(filepaths2)
|
readcontent = GetBinContents(filepaths2)
|
||||||
gtest.Assert(string(readcontent), "")
|
gtest.Assert(string(readcontent), "")
|
||||||
|
|
||||||
//if readcontent!=nil{
|
|
||||||
// t.Error("文件应不存在")
|
|
||||||
//}
|
|
||||||
gtest.Assert(string(GetBinContents(filepaths2)), "")
|
gtest.Assert(string(GetBinContents(filepaths2)), "")
|
||||||
|
|
||||||
})
|
})
|
||||||
@ -97,15 +94,25 @@ func TestGetBinContents(t *testing.T) {
|
|||||||
func TestTruncate(t *testing.T) {
|
func TestTruncate(t *testing.T) {
|
||||||
gtest.Case(t, func() {
|
gtest.Case(t, func() {
|
||||||
var (
|
var (
|
||||||
filepaths1 string = "/testfile_GetContents.txt" //存在文件
|
filepaths1 string = "/testfile_GetContentsyyui.txt" //文件存在时
|
||||||
err error
|
err error
|
||||||
|
files *os.File
|
||||||
)
|
)
|
||||||
CreateTestFile(filepaths1, "abcdefghijkmln")
|
CreateTestFile(filepaths1, "abcdefghijkmln")
|
||||||
defer DelTestFiles(filepaths1)
|
defer DelTestFiles(filepaths1)
|
||||||
err = Truncate(Testpath()+filepaths1, 200)
|
err = Truncate(Testpath()+filepaths1, 10)
|
||||||
gtest.Assert(err, nil)
|
gtest.Assert(err, nil)
|
||||||
|
|
||||||
err = Truncate("", 200)
|
//=========================检查修改文后的大小,是否与期望一致
|
||||||
|
files, err = os.Open(Testpath() + filepaths1)
|
||||||
|
defer files.Close()
|
||||||
|
gtest.Assert(err, nil)
|
||||||
|
fileinfo, err2 := files.Stat()
|
||||||
|
gtest.Assert(err2, nil)
|
||||||
|
gtest.Assert(fileinfo.Size(), 10)
|
||||||
|
|
||||||
|
//====测试当为空时,是否报错
|
||||||
|
err = Truncate("", 10)
|
||||||
gtest.AssertNE(err, nil)
|
gtest.AssertNE(err, nil)
|
||||||
|
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user