google / google/googletest

MatchesRegEx doesn't seem to work.

Open
#3,084 9 comments 6 reactions 1 assignee Claimed by @derekmauro View on GitHub
Dominant language
C++
Stars
39.5k
Forks
10.9k
Avg merge
6d 13h
Merged PRs (30d)
1

Description

I'm trying to to use MatchesRegEx to match a date but it always returns failed. I'm run this test on MacOS so it's a posix system but i'm just trying to use the simplified syntax so i don't have to have 2 versions.

The code I'm trying to use is
`EXPECT_THAT(Log::GenerateISO8601Time(true), ::testing::MatchesRegex("\\d\\d\\d\\d-\\d\\d-\\d\\dT\\d\\d:\\d\\d:\\d\\dZ"));`

I figured maybe it wasn't correct so i went to a simple test for just
`EXPECT_THAT(std::string("2020"), ::testing::MatchesRegex("\\d+"));`

It also doesn't work.

This does work though
`EXPECT_THAT(std::string("2020"), ::testing::MatchesRegex("2020"));
EXPECT_THAT(std::string("2020"), ::testing::MatchesRegex(".+"));`

I did browse through the chromium repo looking at its use of MatchesRegEx.
I'm also using bazel as the build system so it build gtest as a dependency of the test.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.