Skip to content

Commit

Permalink
test: add a test creation test
Browse files Browse the repository at this point in the history
  • Loading branch information
threeal committed Jul 3, 2024
1 parent c1a5685 commit 44e5f78
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ if(ASSERT_ENABLE_TESTS)
assertion_add_test(
"inclusion of other modules" test/IncludeOtherModules.cmake)

assertion_add_test("test creation" test/TestCreation.cmake)
assertion_add_test("failure invocation" test/Fail.cmake)
assertion_add_test("condition assertions" test/Assert.cmake)
assertion_add_test("fatal error assertions" test/AssertFatalError.cmake)
Expand Down
12 changes: 12 additions & 0 deletions test/TestCreation.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
section("it should correctly create a new test")
function(add_test)
cmake_parse_arguments(PARSE_ARGV 0 ARG "" "NAME" "COMMAND")
assert(ARG_NAME STREQUAL "some test")

set(EXPECTED_COMMAND "${CMAKE_COMMAND}" -P "${ASSERTION_LIST_FILE}"
-- ${CMAKE_CURRENT_SOURCE_DIR}/some_test.cmake)
assert(ARG_COMMAND STREQUAL EXPECTED_COMMAND)
endfunction()

assertion_add_test("some test" some_test.cmake)
endsection()

0 comments on commit 44e5f78

Please sign in to comment.