forked from cpm-cmake/CPM.cmake
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtesting.cmake
81 lines (70 loc) · 2.17 KB
/
testing.cmake
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
function(ASSERT_EQUAL)
if(NOT ARGC EQUAL 2)
message(FATAL_ERROR "assertion failed: invalid argument count: ${ARGC}")
endif()
if(NOT "${ARGV0}" STREQUAL "${ARGV1}")
message(FATAL_ERROR "assertion failed: '${ARGV0}' != '${ARGV1}'")
else()
message(STATUS "test passed: '${ARGV0}' == '${ARGV1}'")
endif()
endfunction()
function(ASSERT_NOT_EQUAL)
if(NOT ARGC EQUAL 2)
message(FATAL_ERROR "assertion failed: invalid argument count: ${ARGC}")
endif()
if("${ARGV0}" STREQUAL "${ARGV1}")
message(FATAL_ERROR "assertion failed: '${ARGV0}' == '${ARGV1}'")
else()
message(STATUS "test passed: '${ARGV0}' != '${ARGV1}'")
endif()
endfunction()
function(ASSERT_EMPTY)
if(NOT ARGC EQUAL 0)
message(FATAL_ERROR "assertion failed: input ${ARGC} not empty: '${ARGV}'")
endif()
endfunction()
function(ASSERT_DEFINED KEY)
if(DEFINED ${KEY})
message(STATUS "test passed: '${KEY}' is defined")
else()
message(FATAL_ERROR "assertion failed: '${KEY}' is not defined")
endif()
endfunction()
function(ASSERT_NOT_DEFINED KEY)
if(DEFINED ${KEY})
message(FATAL_ERROR "assertion failed: '${KEY}' is defined (${${KEY}})")
else()
message(STATUS "test passed: '${KEY}' is not defined")
endif()
endfunction()
function(ASSERT_TRUTHY KEY)
if(${${KEY}})
message(STATUS "test passed: '${KEY}' is set truthy")
else()
message(FATAL_ERROR "assertion failed: value of '${KEY}' is not truthy (${${KEY}})")
endif()
endfunction()
function(ASSERT_FALSY KEY)
if(${${KEY}})
message(FATAL_ERROR "assertion failed: value of '${KEY}' is not falsy (${${KEY}})")
else()
message(STATUS "test passed: '${KEY}' is set falsy")
endif()
endfunction()
function(ASSERTION_FAILED)
message(FATAL_ERROR "assertion failed: ${ARGN}")
endfunction()
function(ASSERT_EXISTS file)
if(EXISTS ${file})
message(STATUS "test passed: '${file}' exists")
else()
message(FATAL_ERROR "assertion failed: file ${file} does not exist")
endif()
endfunction()
function(ASSERT_NOT_EXISTS file)
if(NOT EXISTS ${file})
message(STATUS "test passed: '${file}' does not exist")
else()
message(FATAL_ERROR "assertion failed: file ${file} exists")
endif()
endfunction()