Initial commit
This commit is contained in:
35
util_test.go
Normal file
35
util_test.go
Normal file
@@ -0,0 +1,35 @@
|
||||
package camfish
|
||||
|
||||
import "errors"
|
||||
import "testing"
|
||||
import "context"
|
||||
|
||||
func TestDefaul(test *testing.T) {
|
||||
value := defaul("", "askjd")
|
||||
test.Log(value)
|
||||
if value != "askjd" { test.Fatal("not equal") }
|
||||
value1 := defaul("zzzz", "askjd")
|
||||
test.Log(value1)
|
||||
if value1 != "zzzz" { test.Fatal("not equal") }
|
||||
value2 := defaul(0, 3)
|
||||
test.Log(value2)
|
||||
if value2 != 3 { test.Fatal("not equal") }
|
||||
}
|
||||
|
||||
func TestPanicWrap(test *testing.T) {
|
||||
err := panicWrap(context.Background(), func (ctx context.Context) error {
|
||||
return errors.New("test case 0")
|
||||
})
|
||||
test.Log(err)
|
||||
if err.Error() != "test case 0" { test.Fatal("not equal") }
|
||||
err = panicWrap(context.Background(), func (ctx context.Context) error {
|
||||
panic(errors.New("test case 1"))
|
||||
})
|
||||
test.Log(err)
|
||||
if err.Error() != "test case 1" { test.Fatal("not equal") }
|
||||
err = panicWrap(context.Background(), func (ctx context.Context) error {
|
||||
return nil
|
||||
})
|
||||
test.Log(err)
|
||||
if err != nil { test.Fatal("not equal") }
|
||||
}
|
||||
Reference in New Issue
Block a user