From 830c048e03c7484d4f2a85d2c4a9bd9f4f5b7cae Mon Sep 17 00:00:00 2001 From: Alfi Maulana Date: Thu, 30 May 2024 17:41:36 +0700 Subject: [PATCH] feat: improve assertion message in `assert_message` function --- cmake/Assertion.cmake | 5 ++++- test/cmake/AssertionTest.cmake | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/cmake/Assertion.cmake b/cmake/Assertion.cmake index fa57fd1..36dd6fa 100644 --- a/cmake/Assertion.cmake +++ b/cmake/Assertion.cmake @@ -395,7 +395,10 @@ function(assert_message MODE EXPECTED_MESSAGE) if(NOT MESSAGE STREQUAL EXPECTED_MESSAGE) string(TOLOWER "${MODE}" MODE) string(REPLACE "_" " " MODE "${MODE}") - message(FATAL_ERROR "expected ${MODE} message '${MESSAGE}' to be equal to '${EXPECTED_MESSAGE}'") + _assert_internal_format_message( + ASSERT_MESSAGE "expected ${MODE} message:" "${MESSAGE}" + "to be equal to:" "${EXPECTED_MESSAGE}") + message(FATAL_ERROR "${ASSERT_MESSAGE}") endif() if(DEFINED ${MODE}_MESSAGES) diff --git a/test/cmake/AssertionTest.cmake b/test/cmake/AssertionTest.cmake index 24b16c1..3bcef98 100644 --- a/test/cmake/AssertionTest.cmake +++ b/test/cmake/AssertionTest.cmake @@ -200,7 +200,7 @@ function("Message assertions") end_mock_message() assert_message( FATAL_ERROR - "expected error message '' to be equal to 'some other error message'" + "expected error message:\n \nto be equal to:\n some other error message" ) endfunction()