You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ntool/ntest/assert/assertions_test.go

44 lines
803 B
Go

1 year ago
package assert_test
import (
"errors"
"git.noahlan.cn/noahlan/ntool/ntest/assert"
"testing"
)
func TestAssertions_Chain(t *testing.T) {
// err := "error message"
err := errors.New("error message")
as := assert.New(t).
NotEmpty(err).
NotNil(err).
Err(err).
ErrMsg(err, "error message").
Eq("error message", err.Error()).
Neq("message", err.Error()).
Equal("error message", err.Error()).
Contains(err.Error(), "message").
StrContains(err.Error(), "message").
NotContains(err.Error(), "success").
Gt(4, 3).
Lt(2, 3)
assert.True(t, as.IsOk())
assert.False(t, as.IsFail())
iv := 23
as = assert.New(t).
IsType(1, iv).
NotEq(22, iv).
NotEqual(22, iv).
Lte(iv, 23).
Gte(iv, 23).
Empty(0).
True(true).
False(false).
Nil(nil)
assert.True(t, as.IsOk())
}