FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
codeql/cpp/ql/lib/semmle/code/cpp/TestFile.qll at codeql-cli/v2.27.1 · github/codeql · GitHub
github
codeql
Repository navigation
Code
Issues
1k
(1k)
Pull requests
481
(481)
Discussions
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
codeql
/
cpp
/
ql
/
lib
/
semmle
/
code
/
cpp
/
TestFile.qll
Copy path
More file actions
More file actions
Latest commit
History
History
History
89 lines (80 loc) · 2.09 KB
Breadcrumbs
codeql
/
cpp
/
ql
/
lib
/
semmle
/
code
/
cpp
/
TestFile.qll
Copy path
File metadata and controls
89 lines (80 loc) · 2.09 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
/**
* Provides classes for identifying files that contain test cases. It is often
* desirable to exclude these files from analysis.
*/
import
semmle.code.cpp.File
/**
* The `gtest/gtest.h` file.
*/
private
class
GoogleTestHeader
extends
File
{
GoogleTestHeader
(
)
{
this
.
getBaseName
(
)
=
"gtest.h"
and
this
.
getParentContainer
(
)
.
getBaseName
(
)
=
"gtest"
}
}
/**
* A test using the Google Test library.
*/
private
class
GoogleTest
extends
MacroInvocation
{
GoogleTest
(
)
{
// invocation of a macro from Google Test.
this
.
getMacro
(
)
.
getFile
(
)
instanceof
GoogleTestHeader
}
}
/**
* The `boost/test` directory.
*/
private
class
BoostTestFolder
extends
Folder
{
BoostTestFolder
(
)
{
this
.
getBaseName
(
)
=
"test"
and
this
.
getParentContainer
(
)
.
getBaseName
(
)
=
"boost"
}
}
/**
* A test using the Boost Test library.
*/
private
class
BoostTest
extends
MacroInvocation
{
BoostTest
(
)
{
// invocation of a macro from Boost Test.
this
.
getMacro
(
)
.
getFile
(
)
.
getParentContainer
+
(
)
instanceof
BoostTestFolder
}
}
/**
* The `cppunit` directory.
*/
private
class
CppUnitFolder
extends
Folder
{
CppUnitFolder
(
)
{
this
.
getBaseName
(
)
=
"cppunit"
}
}
/**
* A class from the `cppunit` directory.
*/
private
class
CppUnitClass
extends
Class
{
CppUnitClass
(
)
{
this
.
getFile
(
)
.
getParentContainer
+
(
)
instanceof
CppUnitFolder
and
this
.
getNamespace
(
)
.
getParentNamespace
*
(
)
.
getName
(
)
=
"CppUnit"
}
}
/**
* A test using the CppUnit library.
*/
private
class
CppUnitTest
extends
Element
{
CppUnitTest
(
)
{
// class with a base class from cppunit.
this
.
(
Class
)
.
getABaseClass
*
(
)
instanceof
CppUnitClass
and
// class itself is not a part of cppunit.
not
this
instanceof
CppUnitClass
or
// any member function of a test is also test code
this
.
(
Function
)
.
getDeclaringType
(
)
instanceof
CppUnitTest
}
}
/**
* A file that contains one or more test cases.
*/
class
TestFile
extends
File
{
TestFile
(
)
{
exists
(
GoogleTest
test
|
test
.
getFile
(
)
=
this
)
or
exists
(
BoostTest
test
|
test
.
getFile
(
)
=
this
)
or
exists
(
CppUnitTest
test
|
test
.
getFile
(
)
=
this
)
}
}
Back
|
FazBrowse Home
|
New Git URL