Skip to content

Commit

Permalink
test: add test for testing message assertion function
Browse files Browse the repository at this point in the history
  • Loading branch information
threeal committed May 4, 2024
1 parent 4c59086 commit 947946e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 10 deletions.
1 change: 1 addition & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,5 @@ add_cmake_test(
"Assert equal strings"
"Assert unequal strings"
"Mock message"
"Assert messages"
)
30 changes: 20 additions & 10 deletions test/cmake/AssertionTest.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,17 @@ function(test_assert_unequal_strings)
assert_not_strequal("some string" "some other string")
endfunction()

function(call_sample_messages)
message(WARNING "some warning message")
message(WARNING "some other warning message")
message(ERROR "some error message")
message(FATAL_ERROR "some fatal error message")
message(ERROR "some other error message")
endfunction()

function(test_mock_message)
mock_message(ON)

function(test)
message(WARNING "some warning message")
message(WARNING "some other warning message")
message(ERROR "some error message")
message(FATAL_ERROR "some fatal error message")
message(ERROR "some other error message")
endfunction()
test()

call_sample_messages()
mock_message(OFF)

assert_defined(WARNING_MESSAGES)
Expand All @@ -51,6 +50,17 @@ function(test_mock_message)
assert_strequal("${FATAL_ERROR_MESSAGES}" "some fatal error message")
endfunction()

function(test_assert_messages)
mock_message(ON)
call_sample_messages()
mock_message(OFF)

assert_message(WARNING "some warning message")
assert_message(WARNING "some other warning message")
assert_message(ERROR "some error message")
assert_message(FATAL_ERROR "some fatal error message")
endfunction()

if(NOT DEFINED TEST_COMMAND)
message(FATAL_ERROR "The 'TEST_COMMAND' variable should be defined")
elseif(NOT COMMAND test_${TEST_COMMAND})
Expand Down

0 comments on commit 947946e

Please sign in to comment.