diff --git a/os/gfile/gfile_z_exmaple_basic_test.go b/os/gfile/gfile_z_exmaple_basic_test.go index 188d0a374..3f9d87ded 100644 --- a/os/gfile/gfile_z_exmaple_basic_test.go +++ b/os/gfile/gfile_z_exmaple_basic_test.go @@ -340,14 +340,17 @@ func ExampleIsReadable() { func ExampleIsWritable() { // init var ( - path = gfile.Pwd() + gfile.Separator + "testdata/readline/file.log" + path = gfile.Pwd() + gfile.Separator + "testdata/readline/" + file = "file.log" ) // Checks whether given `path` is writable. fmt.Println(gfile.IsWritable(path)) + fmt.Println(gfile.IsWritable(path + file)) // Output: // true + // true } func ExampleChmod() { diff --git a/os/gfile/gfile_z_unit_contents_test.go b/os/gfile/gfile_z_unit_contents_test.go index 3d38e18a6..bb9b01da3 100644 --- a/os/gfile/gfile_z_unit_contents_test.go +++ b/os/gfile/gfile_z_unit_contents_test.go @@ -323,7 +323,7 @@ func Test_Home(t *testing.T) { err error ) - reads, err = gfile.Home() + reads, err = gfile.Home("a", "b") t.Assert(err, nil) t.AssertNE(reads, "") }) diff --git a/os/gfile/gfile_z_unit_copy_test.go b/os/gfile/gfile_z_unit_copy_test.go index 73cb2689f..6a00895fa 100644 --- a/os/gfile/gfile_z_unit_copy_test.go +++ b/os/gfile/gfile_z_unit_copy_test.go @@ -28,7 +28,8 @@ func Test_Copy(t *testing.T) { defer delTestFiles(topath) t.Assert(gfile.IsFile(testpath()+topath), true) - t.AssertNE(gfile.Copy("", ""), nil) + t.AssertNE(gfile.Copy(paths, ""), nil) + t.AssertNE(gfile.Copy("", topath), nil) }) } @@ -46,7 +47,8 @@ func Test_CopyFile(t *testing.T) { defer delTestFiles(topath) t.Assert(gfile.IsFile(testpath()+topath), true) - t.AssertNE(gfile.CopyFile("", ""), nil) + t.AssertNE(gfile.CopyFile(paths, ""), nil) + t.AssertNE(gfile.CopyFile("", topath), nil) }) // Content replacement. gtest.C(t, func(t *gtest.T) { @@ -128,5 +130,8 @@ func Test_CopyDir(t *testing.T) { t.Assert(err, nil) t.Assert(gfile.GetContents(src), srcContent) t.Assert(gfile.GetContents(dst), srcContent) + + t.AssertNE(gfile.CopyDir(gfile.Dir(src), ""), nil) + t.AssertNE(gfile.CopyDir("", gfile.Dir(dst)), nil) }) } diff --git a/os/gfile/gfile_z_unit_size_test.go b/os/gfile/gfile_z_unit_size_test.go index f5f97c506..8e410a97b 100644 --- a/os/gfile/gfile_z_unit_size_test.go +++ b/os/gfile/gfile_z_unit_size_test.go @@ -68,6 +68,11 @@ func Test_StrToSize(t *testing.T) { t.Assert(gfile.StrToSize("8.53P"), gconv.Int64(8.53*1024*1024*1024*1024*1024)) t.Assert(gfile.StrToSize("8.53PB"), gconv.Int64(8.53*1024*1024*1024*1024*1024)) t.Assert(gfile.StrToSize("8.01EB"), gconv.Int64(8.01*1024*1024*1024*1024*1024*1024)) + t.Assert(gfile.StrToSize("0.01ZB"), gconv.Int64(0.01*1024*1024*1024*1024*1024*1024*1024)) + t.Assert(gfile.StrToSize("0.01YB"), gconv.Int64(0.01*1024*1024*1024*1024*1024*1024*1024*1024)) + t.Assert(gfile.StrToSize("0.01BB"), gconv.Int64(0.01*1024*1024*1024*1024*1024*1024*1024*1024*1024)) + t.Assert(gfile.StrToSize("0.01AB"), gconv.Int64(-1)) + t.Assert(gfile.StrToSize("123456789"), 123456789) }) } diff --git a/os/gfile/gfile_z_unit_test.go b/os/gfile/gfile_z_unit_test.go index 1b0c6596b..e290621e7 100644 --- a/os/gfile/gfile_z_unit_test.go +++ b/os/gfile/gfile_z_unit_test.go @@ -571,6 +571,7 @@ func Test_Dir(t *testing.T) { t.Assert(readlPath, testpath()) + t.Assert(len(gfile.Dir(".")) > 0, true) }) } @@ -667,3 +668,15 @@ func Test_MainPkgPath(t *testing.T) { t.Assert(reads, "") }) } + +func Test_SelfName(t *testing.T) { + gtest.C(t, func(t *gtest.T) { + t.Assert(len(gfile.SelfName()) > 0, true) + }) +} + +func Test_MTimestamp(t *testing.T) { + gtest.C(t, func(t *gtest.T) { + t.Assert(gfile.MTimestamp(gfile.Temp()) > 0, true) + }) +}