Skip to content

Commit

Permalink
[libc++][NFC] Make AssertionInfoMatcher::CheckMessageMatches Stricter (
Browse files Browse the repository at this point in the history
…#77721)

Rather than allow for a message to be considered a match for the actual
assertion if it is anywhere in the assertion text, make sure that the
expected and the actual assertion are identical.

Addresses #77701
  • Loading branch information
hawkinsw committed Jan 12, 2024
1 parent b348126 commit 882b4fc
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ int main(int, char**) {
{
std::layout_left::mapping<std::dextents<int, 3>> m{std::dextents<int, 3>{100, 100, 100}};

TEST_LIBCPP_ASSERT_FAILURE(m.stride(4), "invalid rank index");
TEST_LIBCPP_ASSERT_FAILURE(m.stride(4), "layout_left::mapping::stride(): invalid rank index");
}
return 0;
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ int main(int, char**) {
{
std::layout_right::mapping<std::dextents<int, 3>> m{std::dextents<int, 3>{100, 100, 100}};

TEST_LIBCPP_ASSERT_FAILURE(m.stride(4), "invalid rank index");
TEST_LIBCPP_ASSERT_FAILURE(m.stride(4), "layout_right::mapping::stride(): invalid rank index");
}
return 0;
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ int main(int, char**) {
std::layout_stride::mapping<std::dextents<int, 3>> m(
std::dextents<int, 3>(100, 100, 100), std::array<int, 3>{1, 100, 10000});

TEST_LIBCPP_ASSERT_FAILURE(m.stride(4), "invalid rank index");
TEST_LIBCPP_ASSERT_FAILURE(m.stride(4), "layout_stride::mapping::stride(): invalid rank index");
}
return 0;
}
3 changes: 1 addition & 2 deletions libcxx/test/support/check_assertion.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,7 @@ struct AssertionInfoMatcher {
std::size_t found_at = got_msg.find(msg_);
if (found_at == std::string_view::npos)
return false;
// Allow any match
return true;
return found_at == 0 && got_msg.size() == msg_.size();
}
private:
bool is_empty_;
Expand Down

0 comments on commit 882b4fc

Please sign in to comment.