Imported Upstream version 3.3.6
[platform/upstream/ccache.git] / test / test_compopt.c
1 // Copyright (C) 2010-2016 Joel Rosdahl
2 //
3 // This program is free software; you can redistribute it and/or modify it
4 // under the terms of the GNU General Public License as published by the Free
5 // Software Foundation; either version 3 of the License, or (at your option)
6 // any later version.
7 //
8 // This program is distributed in the hope that it will be useful, but WITHOUT
9 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11 // more details.
12 //
13 // You should have received a copy of the GNU General Public License along with
14 // this program; if not, write to the Free Software Foundation, Inc., 51
15 // Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
17 // This file contains tests for the compopt_* functions.
18
19 #include "../ccache.h"
20 #include "../compopt.h"
21 #include "framework.h"
22
23 TEST_SUITE(compopt)
24
25 TEST(option_table_should_be_sorted)
26 {
27         bool compopt_verify_sortedness();
28         CHECK(compopt_verify_sortedness());
29 }
30
31 TEST(dash_I_affects_cpp)
32 {
33         CHECK(compopt_affects_cpp("-I"));
34         CHECK(!compopt_affects_cpp("-Ifoo"));
35 }
36
37 TEST(compopt_short)
38 {
39         CHECK(compopt_short(compopt_affects_cpp, "-Ifoo"));
40         CHECK(!compopt_short(compopt_affects_cpp, "-include"));
41 }
42
43 TEST(dash_V_doesnt_affect_cpp)
44 {
45         CHECK(!compopt_affects_cpp("-V"));
46 }
47
48 TEST(dash_doesnexist_doesnt_affect_cpp)
49 {
50         CHECK(!compopt_affects_cpp("-doesntexist"));
51 }
52
53 TEST(dash_MM_too_hard)
54 {
55         CHECK(compopt_too_hard("-MM"));
56 }
57
58 TEST(dash_MD_not_too_hard)
59 {
60         CHECK(!compopt_too_hard("-MD"));
61 }
62
63 TEST(dash_fprofile_arcs_not_too_hard)
64 {
65         CHECK(!compopt_too_hard("-fprofile-arcs"));
66 }
67
68 TEST(dash_ftest_coverage_not_too_hard)
69 {
70         CHECK(!compopt_too_hard("-ftest-coverage"));
71 }
72
73 TEST(dash_doesnexist_not_too_hard)
74 {
75         CHECK(!compopt_too_hard("-doesntexist"));
76 }
77
78 TEST(dash_Xpreprocessor_too_hard_for_direct_mode)
79 {
80         CHECK(compopt_too_hard_for_direct_mode("-Xpreprocessor"));
81 }
82
83 TEST(dash_nostdinc_not_too_hard_for_direct_mode)
84 {
85         CHECK(!compopt_too_hard_for_direct_mode("-nostdinc"));
86 }
87
88 TEST(dash_I_takes_path)
89 {
90         CHECK(compopt_takes_path("-I"));
91 }
92
93 TEST(dash_Xlinker_takes_arg)
94 {
95         CHECK(compopt_takes_arg("-Xlinker"));
96 }
97
98 TEST(dash_xxx_doesnt_take_arg)
99 {
100         CHECK(!compopt_takes_arg("-xxx"));
101 }
102
103 TEST(dash_iframework_prefix_affects_cpp)
104 {
105         CHECK(compopt_prefix_affects_cpp("-iframework"));
106 }
107
108 TEST_SUITE_END