FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
cppcheck/test/testpathmatch.cpp at master · 2php/cppcheck · GitHub
2php
/
cppcheck
Public
forked from
cppcheck-opensource/cppcheck
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
cppcheck
/
test
/
testpathmatch.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
197 lines (163 loc) · 5.55 KB
Breadcrumbs
cppcheck
/
test
/
testpathmatch.cpp
Copy path
File metadata and controls
197 lines (163 loc) · 5.55 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
/*
* Cppcheck - A tool for static C/C++ code analysis
* Copyright (C) 2007-2018 Cppcheck team.
*
* 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, see <http://www.gnu.org/licenses/>.
*/
#
include
"
pathmatch.h
"
#
include
"
testsuite.h
"
#
include
<
string
>
#
include
<
vector
>
class
TestPathMatch
:
public
TestFixture
{
public:
TestPathMatch
()
: TestFixture(
"
TestPathMatch
"
)
, emptyMatcher(std::vector<std::string>())
, srcMatcher(std::vector<std::string>(
1
,
"
src/
"
))
, fooCppMatcher(std::vector<std::string>(
1
,
"
foo.cpp
"
))
, srcFooCppMatcher(std::vector<std::string>(
1
,
"
src/foo.cpp
"
)) {
}
private:
const
PathMatch emptyMatcher;
const
PathMatch srcMatcher;
const
PathMatch fooCppMatcher;
const
PathMatch srcFooCppMatcher;
void
run
()
override
{
TEST_CASE
(emptymaskemptyfile);
TEST_CASE
(emptymaskpath1);
TEST_CASE
(emptymaskpath2);
TEST_CASE
(emptymaskpath3);
TEST_CASE
(onemaskemptypath);
TEST_CASE
(onemasksamepath);
TEST_CASE
(onemasksamepathdifferentcase);
TEST_CASE
(onemasksamepathwithfile);
TEST_CASE
(onemaskdifferentdir1);
TEST_CASE
(onemaskdifferentdir2);
TEST_CASE
(onemaskdifferentdir3);
TEST_CASE
(onemaskdifferentdir4);
TEST_CASE
(onemasklongerpath1);
TEST_CASE
(onemasklongerpath2);
TEST_CASE
(onemasklongerpath3);
TEST_CASE
(twomasklongerpath1);
TEST_CASE
(twomasklongerpath2);
TEST_CASE
(twomasklongerpath3);
TEST_CASE
(twomasklongerpath4);
TEST_CASE
(filemask1);
TEST_CASE
(filemaskdifferentcase);
TEST_CASE
(filemask2);
TEST_CASE
(filemask3);
TEST_CASE
(filemaskpath1);
TEST_CASE
(filemaskpath2);
TEST_CASE
(filemaskpath3);
TEST_CASE
(filemaskpath4);
}
//
Test empty PathMatch
void
emptymaskemptyfile
()
const
{
ASSERT
(!emptyMatcher.
match
(
"
"
));
}
void
emptymaskpath1
()
const
{
ASSERT
(!emptyMatcher.
match
(
"
src/
"
));
}
void
emptymaskpath2
()
const
{
ASSERT
(!emptyMatcher.
match
(
"
../src/
"
));
}
void
emptymaskpath3
()
const
{
ASSERT
(!emptyMatcher.
match
(
"
/home/user/code/src/
"
));
}
//
Test PathMatch containing "src/"
void
onemaskemptypath
()
const
{
ASSERT
(!srcMatcher.
match
(
"
"
));
}
void
onemasksamepath
()
const
{
ASSERT
(srcMatcher.
match
(
"
src/
"
));
}
void
onemasksamepathdifferentcase
()
const
{
std::vector<std::string>
masks
(
1
,
"
sRc/
"
);
PathMatch
match
(masks,
false
);
ASSERT
(match.
match
(
"
srC/
"
));
}
void
onemasksamepathwithfile
()
const
{
ASSERT
(srcMatcher.
match
(
"
src/file.txt
"
));
}
void
onemaskdifferentdir1
()
const
{
ASSERT
(!srcMatcher.
match
(
"
srcfiles/file.txt
"
));
}
void
onemaskdifferentdir2
()
const
{
ASSERT
(!srcMatcher.
match
(
"
proj/srcfiles/file.txt
"
));
}
void
onemaskdifferentdir3
()
const
{
ASSERT
(!srcMatcher.
match
(
"
proj/mysrc/file.txt
"
));
}
void
onemaskdifferentdir4
()
const
{
ASSERT
(!srcMatcher.
match
(
"
proj/mysrcfiles/file.txt
"
));
}
void
onemasklongerpath1
()
const
{
ASSERT
(srcMatcher.
match
(
"
/tmp/src/
"
));
}
void
onemasklongerpath2
()
const
{
ASSERT
(srcMatcher.
match
(
"
src/module/
"
));
}
void
onemasklongerpath3
()
const
{
ASSERT
(srcMatcher.
match
(
"
project/src/module/
"
));
}
void
twomasklongerpath1
()
const
{
std::vector<std::string> masks = {
"
src/
"
,
"
module/
"
};
PathMatch
match
(masks);
ASSERT
(!match.
match
(
"
project/
"
));
}
void
twomasklongerpath2
()
const
{
std::vector<std::string> masks = {
"
src/
"
,
"
module/
"
};
PathMatch
match
(masks);
ASSERT
(match.
match
(
"
project/src/
"
));
}
void
twomasklongerpath3
()
const
{
std::vector<std::string> masks = {
"
src/
"
,
"
module/
"
};
PathMatch
match
(masks);
ASSERT
(match.
match
(
"
project/module/
"
));
}
void
twomasklongerpath4
()
const
{
std::vector<std::string> masks = {
"
src/
"
,
"
module/
"
};
PathMatch
match
(masks);
ASSERT
(match.
match
(
"
project/src/module/
"
));
}
//
Test PathMatch containing "foo.cpp"
void
filemask1
()
const
{
ASSERT
(fooCppMatcher.
match
(
"
foo.cpp
"
));
}
void
filemaskdifferentcase
()
const
{
std::vector<std::string>
masks
(
1
,
"
foo.cPp
"
);
PathMatch
match
(masks,
false
);
ASSERT
(match.
match
(
"
fOo.cpp
"
));
}
void
filemask2
()
const
{
ASSERT
(fooCppMatcher.
match
(
"
../foo.cpp
"
));
}
void
filemask3
()
const
{
ASSERT
(fooCppMatcher.
match
(
"
src/foo.cpp
"
));
}
//
Test PathMatch containing "src/foo.cpp"
void
filemaskpath1
()
const
{
ASSERT
(srcFooCppMatcher.
match
(
"
src/foo.cpp
"
));
}
void
filemaskpath2
()
const
{
ASSERT
(srcFooCppMatcher.
match
(
"
proj/src/foo.cpp
"
));
}
void
filemaskpath3
()
const
{
ASSERT
(!srcFooCppMatcher.
match
(
"
foo.cpp
"
));
}
void
filemaskpath4
()
const
{
ASSERT
(!srcFooCppMatcher.
match
(
"
bar/foo.cpp
"
));
}
};
REGISTER_TEST
(TestPathMatch)
Back
|
FazBrowse Home
|
New Git URL