Files
codeql/cpp/ql/test/library-tests/dataflow/asDefinition/test.ql
Mathias Vorreiter Pedersen e58a8330cd C++: Add test for asDefinition.
2026-01-23 16:22:39 +00:00

23 lines
649 B
Plaintext

import cpp
import utils.test.InlineExpectationsTest
import semmle.code.cpp.dataflow.new.DataFlow::DataFlow
bindingset[s]
string quote(string s) { if s.matches("% %") then result = "\"" + s + "\"" else result = s }
module AsDefinitionTest implements TestSig {
string getARelevantTag() { result = "asDefinition" }
predicate hasActualResult(Location location, string element, string tag, string value) {
exists(Node n, Expr e |
e = n.asDefinition() and
location = e.getLocation() and
element = n.toString() and
tag = "asDefinition" and
value = quote(e.toString())
)
}
}
import MakeTest<AsDefinitionTest>