File tree Expand file tree Collapse file tree 1 file changed +40
-0
lines changed Expand file tree Collapse file tree 1 file changed +40
-0
lines changed Original file line number Diff line number Diff line change 1+ include ("rsp/testing" )
2+ include ("rsp/helpers" )
3+
4+ define_test_case(
5+ "Requires Arguments Test"
6+ LABELS "requires;args;helpers"
7+ )
8+
9+ # -------------------------------------------------------------------------------------------------------------- #
10+ # Helpers
11+ # -------------------------------------------------------------------------------------------------------------- #
12+
13+ function (fn_with_required_args)
14+ set (options "" ) # N/A
15+ set (oneValueArgs NAME DESCRIPTION)
16+ set (multiValueArgs "" ) # N/A
17+
18+ cmake_parse_arguments (INPUT "${options} " "${oneValueArgs} " "${multiValueArgs} " ${ARGN} )
19+ requires_arguments(INPUT "NAME;DESCRIPTION" )
20+ endfunction ()
21+
22+ # -------------------------------------------------------------------------------------------------------------- #
23+ # Actual Tests
24+ # -------------------------------------------------------------------------------------------------------------- #
25+
26+ define_test("ensures required args are defined" "ensures_required_args_defined" )
27+ function (ensures_required_args_defined)
28+
29+ # If invoking method does not cause a fatal error, test passes.
30+ fn_with_required_args(NAME "foo" DESCRIPTION "bar" )
31+
32+ endfunction ()
33+
34+ define_test("fails when required args are not defined" "fails_when_required_arg_not_defined" EXPECT_FAILURE)
35+ function (fails_when_required_arg_not_defined)
36+
37+ # This should cause a failure because DESCRIPTION is required
38+ fn_with_required_args(NAME "foo" )
39+
40+ endfunction ()
You can’t perform that action at this time.
0 commit comments