diff --git a/test/test_assert_call.cmake b/test/test_assert_call.cmake index f3bf0cd..6805679 100644 --- a/test/test_assert_call.cmake +++ b/test/test_assert_call.cmake @@ -2,51 +2,57 @@ cmake_minimum_required(VERSION 3.24) include(${CMAKE_CURRENT_LIST_DIR}/../cmake/Assertion.cmake) -section("it should assert error messages") - assert_call(message FATAL_ERROR "an error message" - EXPECT_ERROR "an e...r message") +function(throw_errors) + message(SEND_ERROR "a send error message") + message(FATAL_ERROR "a fatal error message") +endfunction() - assert_call(message SEND_ERROR "an error message" - EXPECT_ERROR "an e...r message") +section("it should assert error messages") + assert_call(throw_errors EXPECT_ERROR + "a se.*or message\n" + "a fa.*or message") - assert_call( - CALL message FATAL_ERROR "an error message" - EXPECT_ERROR "an e...r message") + assert_call(CALL throw_errors EXPECT_ERROR + "a se.*or message\n" + "a fa.*or message") - assert_call(message FATAL_ERROR "an error message" - EXPECT_ERROR MATCHES "an e...r message") + assert_call(throw_errors EXPECT_ERROR MATCHES + "a se.*or message\n" + "a fa.*or message") - assert_call(message FATAL_ERROR "an error message" - EXPECT_ERROR STREQUAL "an error message") + assert_call(throw_errors EXPECT_ERROR STREQUAL + "a send error message\n" + "a fatal error message") endsection() section("it should fail to assert error messages") - macro(failed_assertion) - assert_call(message FATAL_ERROR "an error message" - EXPECT_ERROR "an..... e...r message") - endmacro() - - assert_call(failed_assertion - EXPECT_ERROR STREQUAL "expected error message:\n an error message\n" - "to match:\n an..... e...r message") - - macro(failed_assertion) - assert_call(message SEND_ERROR "an error message" - EXPECT_ERROR MATCHES "an..... e...r message") + macro(assert_failures) + assert_call(throw_errors EXPECT_ERROR + "another se.*or message\n" + "another fa.*or message") endmacro() - assert_call(failed_assertion - EXPECT_ERROR STREQUAL "expected error message:\n an error message\n" - "to match:\n an..... e...r message") + assert_call(assert_failures EXPECT_ERROR STREQUAL + "expected error message:\n" + " a send error message\n" + " a fatal error message\n" + "to match:\n" + " another se.*or message\n" + " another fa.*or message") - macro(failed_assertion) - assert_call(message FATAL_ERROR "an error message" - EXPECT_ERROR STREQUAL "another error message") + macro(assert_failures) + assert_call(throw_errors EXPECT_ERROR + "another send error message\n" + "another fatal error message") endmacro() - assert_call(failed_assertion - EXPECT_ERROR STREQUAL "expected error message:\n an error message\n" - "to be equal to:\n another error message") + assert_call(assert_failures EXPECT_ERROR STREQUAL + "expected error message:\n" + " a send error message\n" + " a fatal error message\n" + "to match:\n" + " another send error message\n" + " another fatal error message") endsection() section("it should fail to assert error messages " @@ -55,6 +61,6 @@ section("it should fail to assert error messages " assert_call(message "a message" EXPECT_ERROR "a message") endmacro() - assert_call(failed_assertion - EXPECT_ERROR "expected to receive an error message") + assert_call(failed_assertion EXPECT_ERROR + "expected to receive an error message") endsection()