Compare commits
1 Commits
b7736b7d4c
...
v0.0.2
| Author | SHA1 | Date | |
|---|---|---|---|
| 66c1eef44a |
30
test/assert/equal.go
Normal file
30
test/assert/equal.go
Normal file
@@ -0,0 +1,30 @@
|
||||
package assert
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func Equal(t *testing.T, expected interface{}, actual interface{}, msgAndArgs ...interface{}) bool {
|
||||
t.Helper()
|
||||
|
||||
if reflect.DeepEqual(expected, actual) {
|
||||
return true
|
||||
}
|
||||
|
||||
t.Error(msgAndArgs...)
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func Equalf(t *testing.T, expected interface{}, actual interface{}, msg string, args ...interface{}) bool {
|
||||
t.Helper()
|
||||
|
||||
if reflect.DeepEqual(expected, actual) {
|
||||
return true
|
||||
}
|
||||
|
||||
t.Errorf(msg, args...)
|
||||
|
||||
return false
|
||||
}
|
||||
15
test/assert/nil.go
Normal file
15
test/assert/nil.go
Normal file
@@ -0,0 +1,15 @@
|
||||
package assert
|
||||
|
||||
import "testing"
|
||||
|
||||
func Nil(t *testing.T, data any, msgAndArgs ...interface{}) bool {
|
||||
t.Helper()
|
||||
|
||||
if data != nil {
|
||||
t.Error(msgAndArgs...)
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
@@ -1,25 +1,25 @@
|
||||
package require
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
"gitoa.ru/go-4devs/config/test/assert"
|
||||
)
|
||||
|
||||
func Equal(t *testing.T, expected interface{}, actual interface{}, msgAndArgs ...interface{}) {
|
||||
t.Helper()
|
||||
|
||||
if reflect.DeepEqual(expected, actual) {
|
||||
if assert.Equal(t, expected, actual, msgAndArgs...) {
|
||||
return
|
||||
}
|
||||
|
||||
t.Error(msgAndArgs...)
|
||||
t.FailNow()
|
||||
}
|
||||
|
||||
func Equalf(t *testing.T, expected interface{}, actual interface{}, msg string, args ...interface{}) {
|
||||
t.Helper()
|
||||
|
||||
if reflect.DeepEqual(expected, actual) {
|
||||
if assert.Equalf(t, expected, actual, msg, args...) {
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user