Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

assert.Regexp: handle []byte array properly #1587

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

kevinburkesegment
Copy link
Contributor

Summary

The regexp package works more efficiently on bytes; if you have bytes, it is easier to pass these directly to assert.Regexp than to convert them to a string first.

In addition, FindIndex/FindStringIndex are unnecessary here because we immediately throw away the result - let's just call Match() instead.

Motivation

More efficient test calls, fewer casts in test code.

Related issues

Updates #1585.

@dolmen dolmen added pkg-assert Change related to package testify/assert assert.Regexp About assert.Regexp bug enhancement labels Apr 17, 2024
@dolmen dolmen changed the title assert: handle []byte array properly assert.Regexp: handle []byte array properly Apr 17, 2024
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.

LGTM

The regexp package works more efficiently on bytes; if you have bytes,
it is easier to pass these directly to assert.Regexp than to convert
them to a string first.

In addition, FindIndex/FindStringIndex are unnecessary here because we
immediately throw away the result - let's just call Match() instead.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
assert.Regexp About assert.Regexp bug enhancement pkg-assert Change related to package testify/assert
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants