Skip to content

Conversation

matinFT
Copy link

@matinFT matinFT commented Feb 5, 2021

added assert.Kind to the given object is of the given type.(issue #633)

@dolmen dolmen added enhancement pkg-assert Change related to package testify/assert enhancement: extend API An enhancement that grows the API surface labels Jun 2, 2025
Copy link
Collaborator

@dolmen dolmen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs more work to match signatures of other functions.

}

// Kind check if the given object is of the given type
func Kind(t TestingT, expected reflect.Kind, object interface{}) bool {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add msgAndArgs parameter like in other functions.

if reflect.TypeOf(object).Kind() == expected {
return true
}
return false
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use Fail.

{m["bar"], "something", false, ""},
{myType("1"), myType("2"), false, ""},
{time.Date(2020, 3, 1, 12, 23, 14, 0, time.UTC), time.Date(2020, 5, 1, 12, 23, 14, 0, time.UTC), true, ""},
{time.Date(2020, 6, 3, 12, 23, 14, 0, time.UTC), time.Date(2020, 8, 3, 12, 23, 14, 0, time.UTC), true, ""},
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change doesn't seem related.

{myType("1"), myType("1"), true, ""},
{&struct{}{}, &struct{}{}, true, "pointer equality is based on equality of underlying value"},
{time.Date(2020, 3, 1, 12, 23, 14, 0, time.UTC), time.Date(2020, 3, 1, 12, 23, 14, 0, time.UTC), true, ""},
{time.Date(2020, 6, 3, 12, 23, 14, 0, time.UTC), time.Date(2020, 6, 3, 12, 23, 14, 0, time.UTC), true, ""},
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change doesn't seem related.

@dolmen dolmen changed the title added Kind method + tests assert: add Kind Jun 2, 2025
@segogoreng
Copy link

Hi @dolmen
It's been a while since the last comment. I created a new PR #1803 based on the @matinFT's branch, addressing your comments here, and also adds the corresponding NotKind function. Could you review, please?
Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement: extend API An enhancement that grows the API surface enhancement must-rebase pkg-assert Change related to package testify/assert

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants