mirror of
https://github.com/duke-git/lancet.git
synced 2026-03-01 00:35:28 +08:00
fix: fix failed unit test
This commit is contained in:
@@ -223,7 +223,7 @@ func main() {
|
|||||||
|
|
||||||
### <span id="RandSymbolChar">RandSymbolChar</span>
|
### <span id="RandSymbolChar">RandSymbolChar</span>
|
||||||
|
|
||||||
<p>生成给定长度的随机符号字符串. 符号字符包括: !@#$%^&*()_+-=[]{}|;':\",./<>?。</p>
|
<p>生成给定长度的随机符号字符串。</p>
|
||||||
|
|
||||||
<b>函数签名:</b>
|
<b>函数签名:</b>
|
||||||
|
|
||||||
@@ -231,7 +231,7 @@ func main() {
|
|||||||
func RandSymbolChar(length int) string
|
func RandSymbolChar(length int) string
|
||||||
```
|
```
|
||||||
|
|
||||||
<b>示例:<span style="float:right;display:inline-block;">[Run](https://go.dev/play/p/Im6ZJxAykOm)</span></b>
|
<b>示例:<span style="float:right;display:inline-block;">[运行](https://go.dev/play/p/Im6ZJxAykOm)</span></b>
|
||||||
|
|
||||||
```go
|
```go
|
||||||
package main
|
package main
|
||||||
@@ -338,7 +338,7 @@ func main() {
|
|||||||
func RandFloats(n int, min, max float64, precision int) []float64
|
func RandFloats(n int, min, max float64, precision int) []float64
|
||||||
```
|
```
|
||||||
|
|
||||||
<b>实例:<span style="float:right;display:inline-block;">[Run](https://go.dev/play/p/I3yndUQ-rhh)</span></b>
|
<b>实例:<span style="float:right;display:inline-block;">[运行](https://go.dev/play/p/I3yndUQ-rhh)</span></b>
|
||||||
|
|
||||||
```go
|
```go
|
||||||
package main
|
package main
|
||||||
|
|||||||
@@ -223,7 +223,7 @@ func main() {
|
|||||||
|
|
||||||
### <span id="RandSymbolChar">RandSymbolChar</span>
|
### <span id="RandSymbolChar">RandSymbolChar</span>
|
||||||
|
|
||||||
<p>Generate a random symbol char of specified length. Symbol chars: !@#$%^&*()_+-=[]{}|;':\",./<>?.</p>
|
<p>Generate a random symbol char of specified length.</p>
|
||||||
|
|
||||||
<b>Signature:</b>
|
<b>Signature:</b>
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ func TestCreateFile(t *testing.T) {
|
|||||||
|
|
||||||
assert := internal.NewAssert(t, "TestCreateFile")
|
assert := internal.NewAssert(t, "TestCreateFile")
|
||||||
|
|
||||||
f := "./text.txt"
|
f := "./testdata/text.txt"
|
||||||
if CreateFile(f) {
|
if CreateFile(f) {
|
||||||
file, err := os.Open(f)
|
file, err := os.Open(f)
|
||||||
assert.IsNil(err)
|
assert.IsNil(err)
|
||||||
|
|||||||
@@ -14,12 +14,6 @@ func TestTryUnwrap(t *testing.T) {
|
|||||||
|
|
||||||
assert := internal.NewAssert(t, "TestTryUnwrap")
|
assert := internal.NewAssert(t, "TestTryUnwrap")
|
||||||
assert.Equal(42, TryUnwrap(strconv.Atoi("42")))
|
assert.Equal(42, TryUnwrap(strconv.Atoi("42")))
|
||||||
}
|
|
||||||
|
|
||||||
func TestTryUnwrapFail(t *testing.T) {
|
|
||||||
t.Parallel()
|
|
||||||
|
|
||||||
assert := internal.NewAssert(t, "TestTryUnwrapFail")
|
|
||||||
|
|
||||||
_, err := strconv.Atoi("4o2")
|
_, err := strconv.Atoi("4o2")
|
||||||
defer func() {
|
defer func() {
|
||||||
@@ -76,8 +70,6 @@ func TestXError_Unwrap(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestXError_StackTrace(t *testing.T) {
|
func TestXError_StackTrace(t *testing.T) {
|
||||||
// t.Parallel()
|
|
||||||
|
|
||||||
assert := internal.NewAssert(t, "TestXError_StackTrace")
|
assert := internal.NewAssert(t, "TestXError_StackTrace")
|
||||||
|
|
||||||
err := New("error")
|
err := New("error")
|
||||||
@@ -86,7 +78,7 @@ func TestXError_StackTrace(t *testing.T) {
|
|||||||
|
|
||||||
assert.Equal(3, len(stacks))
|
assert.Equal(3, len(stacks))
|
||||||
assert.Equal("github.com/duke-git/lancet/v2/xerror.TestXError_StackTrace", stacks[0].Func)
|
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"))
|
assert.Equal(true, strings.Contains(stacks[0].File, "xerror_test.go"))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user