Skip to content

Commit

Permalink
feat: improve assertion message in assert_message function
Browse files Browse the repository at this point in the history
  • Loading branch information
threeal committed May 30, 2024
1 parent ac4997a commit 830c048
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion cmake/Assertion.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion test/cmake/AssertionTest.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down

0 comments on commit 830c048

Please sign in to comment.