MCPcopy Create free account
hub / github.com/cppcheck-opensource/cppcheck / function_arg_direction

Method function_arg_direction

test/testlibrary.cpp:298–320  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

296 }
297
298 void function_arg_direction() const {
299 constexpr char xmldata[] = "<?xml version=\"1.0\"?>\n"
300 "<def>\n"
301 "<function name=\"foo\">\n"
302 " <arg nr=\"1\" direction=\"in\"></arg>\n"
303 " <arg nr=\"2\" direction=\"out\"></arg>\n"
304 " <arg nr=\"3\" direction=\"inout\"></arg>\n"
305 " <arg nr=\"4\"></arg>\n"
306 "</function>\n"
307 "</def>";
308
309 Library library;
310 ASSERT(LibraryHelper::loadxmldata(library, xmldata, sizeof(xmldata)));
311
312 const char code[] = "foo(a,b,c,d);";
313 SimpleTokenList tokenList(code);
314 tokenList.front()->next()->astOperand1(tokenList.front());
315
316 ASSERT(Library::ArgumentChecks::Direction::DIR_IN == library.getArgDirection(tokenList.front(), 1));
317 ASSERT(Library::ArgumentChecks::Direction::DIR_OUT == library.getArgDirection(tokenList.front(), 2));
318 ASSERT(Library::ArgumentChecks::Direction::DIR_INOUT == library.getArgDirection(tokenList.front(), 3));
319 ASSERT(Library::ArgumentChecks::Direction::DIR_UNKNOWN == library.getArgDirection(tokenList.front(), 4));
320 }
321
322 void function_arg_valid() const {
323 constexpr char xmldata[] = "<?xml version=\"1.0\"?>\n"

Callers

nothing calls this directly

Calls 4

astOperand1Method · 0.80
nextMethod · 0.80
frontMethod · 0.80
getArgDirectionMethod · 0.80

Tested by

no test coverage detected