[libcxx-commits] [libcxx] [libc++][NFC] Make AssertionInfoMatcher::CheckMessageMatches Stricter (PR #77721)

Will Hawkins via libcxx-commits libcxx-commits at lists.llvm.org
Wed Jan 10 19:41:07 PST 2024


https://github.com/hawkinsw created https://github.com/llvm/llvm-project/pull/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 

>From ede4846a1379341a7b9a3da16eddd917e95ef6cb Mon Sep 17 00:00:00 2001
From: Will Hawkins <hawkinsw at obs.cr>
Date: Wed, 10 Jan 2024 22:35:32 -0500
Subject: [PATCH] [libc++][NFC] Make AssertionInfoMatcher::CheckMessageMatches
 Stricter

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.
---
 libcxx/test/support/check_assertion.h | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/libcxx/test/support/check_assertion.h b/libcxx/test/support/check_assertion.h
index 98dd95b11556e6..01e296d9138d0c 100644
--- a/libcxx/test/support/check_assertion.h
+++ b/libcxx/test/support/check_assertion.h
@@ -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_;



More information about the libcxx-commits mailing list