1 // Copyright (C) 2010-2016 Joel Rosdahl
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)
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
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
17 // This file contains tests for the compopt_* functions.
19 #include "../ccache.h"
20 #include "../compopt.h"
21 #include "framework.h"
25 TEST(option_table_should_be_sorted)
27 bool compopt_verify_sortedness();
28 CHECK(compopt_verify_sortedness());
31 TEST(dash_I_affects_cpp)
33 CHECK(compopt_affects_cpp("-I"));
34 CHECK(!compopt_affects_cpp("-Ifoo"));
39 CHECK(compopt_short(compopt_affects_cpp, "-Ifoo"));
40 CHECK(!compopt_short(compopt_affects_cpp, "-include"));
43 TEST(dash_V_doesnt_affect_cpp)
45 CHECK(!compopt_affects_cpp("-V"));
48 TEST(dash_doesnexist_doesnt_affect_cpp)
50 CHECK(!compopt_affects_cpp("-doesntexist"));
53 TEST(dash_MM_too_hard)
55 CHECK(compopt_too_hard("-MM"));
58 TEST(dash_MD_not_too_hard)
60 CHECK(!compopt_too_hard("-MD"));
63 TEST(dash_fprofile_arcs_not_too_hard)
65 CHECK(!compopt_too_hard("-fprofile-arcs"));
68 TEST(dash_ftest_coverage_not_too_hard)
70 CHECK(!compopt_too_hard("-ftest-coverage"));
73 TEST(dash_doesnexist_not_too_hard)
75 CHECK(!compopt_too_hard("-doesntexist"));
78 TEST(dash_Xpreprocessor_too_hard_for_direct_mode)
80 CHECK(compopt_too_hard_for_direct_mode("-Xpreprocessor"));
83 TEST(dash_nostdinc_not_too_hard_for_direct_mode)
85 CHECK(!compopt_too_hard_for_direct_mode("-nostdinc"));
88 TEST(dash_I_takes_path)
90 CHECK(compopt_takes_path("-I"));
93 TEST(dash_Xlinker_takes_arg)
95 CHECK(compopt_takes_arg("-Xlinker"));
98 TEST(dash_xxx_doesnt_take_arg)
100 CHECK(!compopt_takes_arg("-xxx"));
103 TEST(dash_iframework_prefix_affects_cpp)
105 CHECK(compopt_prefix_affects_cpp("-iframework"));