summaryrefslogtreecommitdiff
path: root/test/test_compopt.c
blob: 509825c8d2d71abbe24b1d6e80cc2220c17718ba (plain)
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
/*
 * Copyright (C) 2010 Joel Rosdahl
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the Free
 * Software Foundation; either version 3 of the License, or (at your option)
 * any later version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
 * more details.
 *
 * You should have received a copy of the GNU General Public License along with
 * this program; if not, write to the Free Software Foundation, Inc., 51
 * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 */

/*
 * This file contains tests for the compopt_* functions.
 */

#include "ccache.h"
#include "compopt.h"
#include "test/framework.h"

TEST_SUITE(compopt)

TEST(option_table_should_be_sorted)
{
	bool compopt_verify_sortedness();
	CHECK(compopt_verify_sortedness());
}

TEST(dash_I_affects_cpp)
{
	CHECK(compopt_affects_cpp("-I"));
	CHECK(!compopt_affects_cpp("-Ifoo"));
}

TEST(compopt_short)
{
	CHECK(compopt_short(compopt_affects_cpp, "-Ifoo"));
	CHECK(!compopt_short(compopt_affects_cpp, "-include"));
}

TEST(dash_V_doesnt_affect_cpp)
{
	CHECK(!compopt_affects_cpp("-V"));
}

TEST(dash_doesnexist_doesnt_affect_cpp)
{
	CHECK(!compopt_affects_cpp("-doesntexist"));
}

TEST(dash_MM_too_hard)
{
	CHECK(compopt_too_hard("-MM"));
}

TEST(dash_MD_not_too_hard)
{
	CHECK(!compopt_too_hard("-MD"));
}

TEST(dash_doesnexist_not_too_hard)
{
	CHECK(!compopt_too_hard("-doesntexist"));
}

TEST(dash_Xpreprocessor_too_hard_for_direct_mode)
{
	CHECK(compopt_too_hard_for_direct_mode("-Xpreprocessor"));
}

TEST(dash_nostdinc_not_too_hard_for_direct_mode)
{
	CHECK(!compopt_too_hard_for_direct_mode("-nostdinc"));
}

TEST(dash_I_takes_path)
{
	CHECK(compopt_takes_path("-I"));
}

TEST(dash_Xlinker_takes_arg)
{
	CHECK(compopt_takes_arg("-Xlinker"));
}

TEST(dash_xxx_doesnt_take_arg)
{
	CHECK(!compopt_takes_arg("-xxx"));
}

TEST_SUITE_END