-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_parse_file_options.cmake
67 lines (52 loc) · 1.9 KB
/
test_parse_file_options.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
include(add_target.cmake)
include(unit_test_for_cmake/unit-test.cmake)
function(test_main)
parse_file_options("test.cpp" file options)
expect_streq("${file}" "test.cpp")
expect_empty("${options}")
parse_file_options("test.cpp:toto" file options)
expect_streq("${file}" "test.cpp")
expect_streq("${options}" "toto")
parse_file_options("test.cpp:toto,tata" file options)
expect_streq("${file}" "test.cpp")
expect_streq("${options}" "toto;tata")
parse_file_options("test.cpp" file options)
expect_streq("${file}" "test.cpp")
expect_empty("${options}")
parse_file_options("" file options)
expect_empty("${file}")
expect_empty("${options}")
parse_file_options(":" file options)
expect_empty("${file}")
expect_empty("${options}")
parse_file_options("test.cpp:" file options)
expect_streq("${file}" "test.cpp")
expect_empty("${options}")
parse_file_options(":toto" file options)
expect_empty("${file}")
expect_empty("${options}")
endfunction()
# Using same variable names as in function definition because some
# implementations may break in this case.
function(test_same_variable_names)
parse_file_options("test.cpp" out_file out_options)
expect_streq("${out_file}" "test.cpp")
expect_empty("${out_options}")
parse_file_options("test.cpp:toto" out_file out_options)
expect_streq("${out_file}" "test.cpp")
expect_streq("${out_options}" "toto")
parse_file_options("test.cpp" out_file out_options)
expect_streq("${out_file}" "test.cpp")
expect_empty("${out_options}")
parse_file_options(":" out_file out_options)
expect_empty("${out_file}")
expect_empty("${out_options}")
parse_file_options("test.cpp:" out_file out_options)
expect_streq("${out_file}" "test.cpp")
expect_empty("${out_options}")
parse_file_options(":toto" out_file out_options)
expect_empty("${out_file}")
expect_empty("${out_options}")
endfunction()
test_main()
test_same_variable_names()