From af590028fa2cb481c8cc2b4688d6180df63eee90 Mon Sep 17 00:00:00 2001 From: jsalling Date: Wed, 3 Aug 2016 21:31:37 -0500 Subject: [PATCH] Unity to print C-style escaped strings as "\x16" Changes from "\0x16" before, makes it easier to copy strings from output --- src/unity.c | 6 ++++-- test/tests/testunity.c | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/unity.c b/src/unity.c index 8d8bb2d..4a1f85e 100644 --- a/src/unity.c +++ b/src/unity.c @@ -106,6 +106,7 @@ void UnityPrint(const char* string) else { UNITY_OUTPUT_CHAR('\\'); + UNITY_OUTPUT_CHAR('x'); UnityPrintNumberHex((_U_UINT)*pch, 2); } pch++; @@ -143,6 +144,7 @@ void UnityPrintLen(const char* string, const _UU32 length) else { UNITY_OUTPUT_CHAR('\\'); + UNITY_OUTPUT_CHAR('x'); UnityPrintNumberHex((_U_UINT)*pch, 2); } pch++; @@ -163,6 +165,8 @@ void UnityPrintNumberByStyle(const _U_SINT number, const UNITY_DISPLAY_STYLE_T s } else { + UNITY_OUTPUT_CHAR('0'); + UNITY_OUTPUT_CHAR('x'); UnityPrintNumberHex((_U_UINT)number, (char)((style & 0x000F) << 1)); } } @@ -207,8 +211,6 @@ void UnityPrintNumberHex(const _U_UINT number, const char nibbles_to_print) { _U_UINT nibble; char nibbles = nibbles_to_print; - UNITY_OUTPUT_CHAR('0'); - UNITY_OUTPUT_CHAR('x'); while (nibbles > 0) { diff --git a/test/tests/testunity.c b/test/tests/testunity.c index a796704..2fc1010 100644 --- a/test/tests/testunity.c +++ b/test/tests/testunity.c @@ -1373,7 +1373,7 @@ void testNotEqualString4(void) void testNotEqualStringLen4(void) { EXPECT_ABORT_BEGIN - TEST_ASSERT_EQUAL_STRING_LEN("\r\x16", "bar\n", 4); + TEST_ASSERT_EQUAL_STRING_LEN("ba\r\x16", "ba\r\n", 4); VERIFY_FAILS_END }