1# This is a C++ feature
2enable_language(CXX)
3
4# Include check feature.
5include(${cookoff_path}/CheckCXX11Features.cmake)
6
7# Now call function with fake input
8set(ALL_FEATURES "first;second;third")
9
10# No input OPTIONALS == ALL_FEATURES
11parse_input_features("${ALL_FEATURES}" OPTIONALS REQUIRED ERRORS "")
12if(NOT "${OPTIONALS}" STREQUAL "${ALL_FEATURES}")
13  message(FATAL_ERROR "OPTIONALS results should contain everything.")
14endif(NOT "${OPTIONALS}" STREQUAL "${ALL_FEATURES}")
15if(NOT "${REQUIRED}" STREQUAL "")
16  message(FATAL_ERROR "REQUIRED should be empty.")
17endif(NOT "${REQUIRED}" STREQUAL "")
18if(NOT "${ERRORS}" STREQUAL "")
19  message(FATAL_ERROR "ERRORS should be empty.")
20endif(NOT "${ERRORS}" STREQUAL "")
21
22# Single input without REQUIRED
23parse_input_features("${ALL_FEATURES}" OPTIONALS REQUIRED ERRORS "second")
24if(NOT "${OPTIONALS}" STREQUAL "second")
25  message(FATAL_ERROR "OPTIONALS results should second.")
26endif()
27if(NOT "${REQUIRED}" STREQUAL "")
28  message(FATAL_ERROR "REQUIRED should be empty.")
29endif()
30if(NOT "${ERRORS}" STREQUAL "")
31  message(FATAL_ERROR "ERRORS should be empty.")
32endif()
33
34# Single error input without REQUIRED
35parse_input_features("${ALL_FEATURES}" OPTIONALS REQUIRED ERRORS "none")
36if(NOT "${OPTIONALS}" STREQUAL "")
37  message(FATAL_ERROR "OPTIONALS results should be empty.")
38endif()
39if(NOT "${REQUIRED}" STREQUAL "")
40  message(FATAL_ERROR "REQUIRED should be empty.")
41endif()
42if(NOT "${ERRORS}" STREQUAL "none")
43  message(FATAL_ERROR "ERRORS should be none.")
44endif()
45
46# Single valid input with REQUIRED
47parse_input_features("${ALL_FEATURES}" OPTIONALS REQUIRED ERRORS REQUIRED first)
48if(NOT "${OPTIONALS}" STREQUAL "")
49  message(FATAL_ERROR "OPTIONALS results should be empty.")
50endif()
51if(NOT "${REQUIRED}" STREQUAL "first")
52  message(FATAL_ERROR "REQUIRED should be first.")
53endif()
54if(NOT "${ERRORS}" STREQUAL "")
55  message(FATAL_ERROR "ERRORS should be empty.")
56endif()
57
58# one of each
59parse_input_features("${ALL_FEATURES}" OPTIONALS REQUIRED ERRORS second third REQUIRED first none)
60if(NOT "${OPTIONALS}" STREQUAL "second;third")
61  message(FATAL_ERROR "OPTIONALS results should be second;optional.")
62endif()
63if(NOT "${REQUIRED}" STREQUAL "first")
64  message(FATAL_ERROR "REQUIRED should be first.")
65endif()
66if(NOT "${ERRORS}" STREQUAL "none")
67  message(FATAL_ERROR "ERRORS should be none.")
68endif()
69