add assert tests
This commit is contained in:
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
|
package require
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"reflect"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"gitoa.ru/go-4devs/config/test/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Equal(t *testing.T, expected interface{}, actual interface{}, msgAndArgs ...interface{}) {
|
func Equal(t *testing.T, expected interface{}, actual interface{}, msgAndArgs ...interface{}) {
|
||||||
t.Helper()
|
t.Helper()
|
||||||
|
|
||||||
if reflect.DeepEqual(expected, actual) {
|
if assert.Equal(t, expected, actual, msgAndArgs...) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
t.Error(msgAndArgs...)
|
|
||||||
t.FailNow()
|
t.FailNow()
|
||||||
}
|
}
|
||||||
|
|
||||||
func Equalf(t *testing.T, expected interface{}, actual interface{}, msg string, args ...interface{}) {
|
func Equalf(t *testing.T, expected interface{}, actual interface{}, msg string, args ...interface{}) {
|
||||||
t.Helper()
|
t.Helper()
|
||||||
|
|
||||||
if reflect.DeepEqual(expected, actual) {
|
if assert.Equalf(t, expected, actual, msg, args...) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user