assert_streq: add newlines to failure message

Message ID 20211026212746.671762-1-dmalcolm@redhat.com
State Committed
Commit ebfc3a2304383edf7ccd50a327e380ee6a8afa43
Headers
Series assert_streq: add newlines to failure message |

Commit Message

David Malcolm Oct. 26, 2021, 9:27 p.m. UTC
  Adding newlines so that the two strings line up makes string equality
failures considerably easier to read.

Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu.
OK for trunk?

gcc/ChangeLog:
	* selftest.c (assert_streq): Add newlines when emitting non-equal
	non-NULL strings.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
---
 gcc/selftest.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Jeff Law Oct. 28, 2021, 2:53 p.m. UTC | #1
On 10/26/2021 3:27 PM, David Malcolm via Gcc-patches wrote:
> Adding newlines so that the two strings line up makes string equality
> failures considerably easier to read.
>
> Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu.
> OK for trunk?
>
> gcc/ChangeLog:
> 	* selftest.c (assert_streq): Add newlines when emitting non-equal
> 	non-NULL strings.
>
> Signed-off-by: David Malcolm <dmalcolm@redhat.com>
OK
jeff
  

Patch

diff --git a/gcc/selftest.c b/gcc/selftest.c
index 8f1cde0cc19..0db56f3b240 100644
--- a/gcc/selftest.c
+++ b/gcc/selftest.c
@@ -89,7 +89,7 @@  assert_streq (const location &loc,
 	if (strcmp (val1, val2) == 0)
 	  pass (loc, "ASSERT_STREQ");
 	else
-	  fail_formatted (loc, "ASSERT_STREQ (%s, %s) val1=\"%s\" val2=\"%s\"",
+	  fail_formatted (loc, "ASSERT_STREQ (%s, %s)\n val1=\"%s\"\n val2=\"%s\"\n",
 			  desc_val1, desc_val2, val1, val2);
       }
 }