From 0b976e9a4c4c30715ba0ef61c562a9df5b92b998 Mon Sep 17 00:00:00 2001 From: dudaodong Date: Mon, 11 Dec 2023 15:45:02 +0800 Subject: [PATCH] fix: fix failed unit test --- docs/api/packages/random.md | 6 +++--- docs/en/api/packages/random.md | 2 +- fileutil/file_test.go | 2 +- xerror/xerror_test.go | 10 +--------- 4 files changed, 6 insertions(+), 14 deletions(-) diff --git a/docs/api/packages/random.md b/docs/api/packages/random.md index 546ef9e..3137ee1 100644 --- a/docs/api/packages/random.md +++ b/docs/api/packages/random.md @@ -223,7 +223,7 @@ func main() { ### RandSymbolChar -

生成给定长度的随机符号字符串. 符号字符包括: !@#$%^&*()_+-=[]{}|;':\",./<>?。

+

生成给定长度的随机符号字符串。

函数签名: @@ -231,7 +231,7 @@ func main() { func RandSymbolChar(length int) string ``` -示例:[Run](https://go.dev/play/p/Im6ZJxAykOm) +示例:[运行](https://go.dev/play/p/Im6ZJxAykOm) ```go package main @@ -338,7 +338,7 @@ func main() { func RandFloats(n int, min, max float64, precision int) []float64 ``` -实例:[Run](https://go.dev/play/p/I3yndUQ-rhh) +实例:[运行](https://go.dev/play/p/I3yndUQ-rhh) ```go package main diff --git a/docs/en/api/packages/random.md b/docs/en/api/packages/random.md index 443237b..70397ce 100644 --- a/docs/en/api/packages/random.md +++ b/docs/en/api/packages/random.md @@ -223,7 +223,7 @@ func main() { ### RandSymbolChar -

Generate a random symbol char of specified length. Symbol chars: !@#$%^&*()_+-=[]{}|;':\",./<>?.

+

Generate a random symbol char of specified length.

Signature: diff --git a/fileutil/file_test.go b/fileutil/file_test.go index 44d9784..fde1f63 100644 --- a/fileutil/file_test.go +++ b/fileutil/file_test.go @@ -27,7 +27,7 @@ func TestCreateFile(t *testing.T) { assert := internal.NewAssert(t, "TestCreateFile") - f := "./text.txt" + f := "./testdata/text.txt" if CreateFile(f) { file, err := os.Open(f) assert.IsNil(err) diff --git a/xerror/xerror_test.go b/xerror/xerror_test.go index 3aa1233..c14714e 100644 --- a/xerror/xerror_test.go +++ b/xerror/xerror_test.go @@ -14,12 +14,6 @@ func TestTryUnwrap(t *testing.T) { assert := internal.NewAssert(t, "TestTryUnwrap") assert.Equal(42, TryUnwrap(strconv.Atoi("42"))) -} - -func TestTryUnwrapFail(t *testing.T) { - t.Parallel() - - assert := internal.NewAssert(t, "TestTryUnwrapFail") _, err := strconv.Atoi("4o2") defer func() { @@ -76,8 +70,6 @@ func TestXError_Unwrap(t *testing.T) { } func TestXError_StackTrace(t *testing.T) { - // t.Parallel() - assert := internal.NewAssert(t, "TestXError_StackTrace") err := New("error") @@ -86,7 +78,7 @@ func TestXError_StackTrace(t *testing.T) { assert.Equal(3, len(stacks)) assert.Equal("github.com/duke-git/lancet/v2/xerror.TestXError_StackTrace", stacks[0].Func) - assert.Equal(83, stacks[0].Line) + assert.Equal(75, stacks[0].Line) assert.Equal(true, strings.Contains(stacks[0].File, "xerror_test.go")) }