Skip to content

Convert EXPECT_STREQ to matcher syntax #424

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

Merged
merged 1 commit into from
May 9, 2025
Merged

Conversation

hoffbrinkle
Copy link
Member

This converts existing uses of EXPECT_STREQ to use the StrEq and IsEmpty
matchers. Note that we really want to test the StringContstant's ability to
do string things. If we want to test the behavior of c_str, that should be a
specific test.

Partial implementation for #404.

@hoffbrinkle hoffbrinkle marked this pull request as ready for review May 9, 2025 16:02
using ::testing::StrEq;

namespace detail {

TEST(StringConstant, CanCreateFromStringLiteral) {
constexpr StringConstant<5> x{"hello"};
EXPECT_STREQ(x.c_str(), "hello");
Copy link
Member

Choose a reason for hiding this comment

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

I didn't realize we could get rid of these c_str() calls. Neat! I wonder if we needed them with EXPECT_STREQ, and if not, then I wonder why I added them in the first place.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not sure I tried it. I do know the matcher certainly provided better ability to match different types, so I just tried it and it worked!

@chiphogg chiphogg merged commit 1273e65 into main May 9, 2025
15 checks passed
@chiphogg chiphogg deleted the hoffbrinkle/expect_streq branch May 9, 2025 18:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants