Skip to content

Commit 490fa07

Browse files
committed
Add ASSERT_CONTENTS_EQUAL test macro in testing.cmake
Checks if the contents of a file matches the given input
1 parent cd28d44 commit 490fa07

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

cmake/testing.cmake

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,3 +79,16 @@ function(ASSERT_NOT_EXISTS file)
7979
message(FATAL_ERROR "assertion failed: file ${file} exists")
8080
endif()
8181
endfunction()
82+
83+
function(ASSERT_CONTENTS_EQUAL file content)
84+
if(EXISTS ${file})
85+
file(READ ${file} file_content)
86+
if(content STREQUAL file_content)
87+
message(STATUS "test passed: '${file}' exists and contains '${content}'")
88+
else()
89+
message(FATAL_ERROR "assertion failed: file '${file}' does not contain expected content.")
90+
endif()
91+
else()
92+
message(FATAL_ERROR "assertion failed: file '${file} does not exist")
93+
endif()
94+
endfunction()

0 commit comments

Comments
 (0)