Skip to content

Commit 04ed68e

Browse files
Tensorstore Teamcopybara-github
Tensorstore Team
authored andcommitted
Fix tests' dependencies on gtest implementation details.
These tests rely on the exact failure messages generated by `ElementsAre()`, which are not part of gtest's public API and are subject to change without notice. If a test needs to verify matcher messages, it must only use matchers owned by the same project. It's never OK to depend on implementation details of code that one doesn't own. PiperOrigin-RevId: 738045085 Change-Id: I5f84775808f751fa41aa76609394424649e027f1
1 parent 3486ca4 commit 04ed68e

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

tensorstore/array_testutil_test.cc

+6-6
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ using ::tensorstore::MakeOffsetArray;
2828
using ::tensorstore::MakeScalarArray;
2929
using ::tensorstore::MatchesArray;
3030
using ::tensorstore::MatchesScalarArray;
31+
using ::testing::MatchesRegex;
3132

3233
TEST(MatchesArrayTest, Describe) {
3334
std::ostringstream ss;
@@ -77,19 +78,18 @@ TEST(MatchesArrayTest, ExplainElementMatch) {
7778
{::testing::Not(::testing::ElementsAre('d')),
7879
::testing::Not(::testing::ElementsAre('a', 'b'))}),
7980
MakeArray<std::string>({"x", "ac"}), &listener);
80-
EXPECT_EQ(
81-
"whose element at {0} matches, whose element #0 doesn't match,\n"
82-
"and whose element at {1} matches, whose element #1 doesn't match",
83-
listener.str());
81+
EXPECT_THAT(listener.str(),
82+
MatchesRegex("whose element at \\{0\\} matches, .*\\n"
83+
"and whose element at \\{1\\} matches, .*"));
8484
}
8585

8686
TEST(MatchesArrayTest, ExplainElementMismatchExplanation) {
8787
::testing::StringMatchResultListener listener;
8888
::testing::ExplainMatchResult(
8989
MatchesScalarArray<std::string>(::testing::ElementsAre('a', 'b')),
9090
MakeScalarArray<std::string>("ac"), &listener);
91-
EXPECT_EQ("whose element at {} doesn't match, whose element #1 doesn't match",
92-
listener.str());
91+
EXPECT_THAT(listener.str(),
92+
MatchesRegex("whose element at \\{\\} doesn't match.*"));
9393
}
9494

9595
TEST(MatchesArrayTest, Matches) {

0 commit comments

Comments
 (0)