| 164 | } |
| 165 | |
| 166 | void function_match_args_default() const { |
| 167 | constexpr char xmldata[] = "<?xml version=\"1.0\"?>\n" |
| 168 | "<def>\n" |
| 169 | " <function name=\"foo\">\n" |
| 170 | " <arg nr=\"1\"/>" |
| 171 | " <arg nr=\"2\" default=\"0\"/>" |
| 172 | " </function>\n" |
| 173 | "</def>"; |
| 174 | |
| 175 | Library library; |
| 176 | ASSERT(LibraryHelper::loadxmldata(library, xmldata, sizeof(xmldata))); |
| 177 | |
| 178 | { |
| 179 | TokenList tokenList(settingsDefault, Standards::Language::CPP); |
| 180 | const char code[] = "foo();"; // <- too few arguments, not library function |
| 181 | ASSERT(tokenList.createTokensFromString(code)); |
| 182 | Token::createMutualLinks(tokenList.front()->next(), tokenList.back()->previous()); |
| 183 | tokenList.createAst(); |
| 184 | |
| 185 | ASSERT(library.isNotLibraryFunction(tokenList.front())); |
| 186 | } |
| 187 | { |
| 188 | TokenList tokenList(settingsDefault, Standards::Language::CPP); |
| 189 | const char code[] = "foo(a);"; // <- library function |
| 190 | ASSERT(tokenList.createTokensFromString(code)); |
| 191 | Token::createMutualLinks(tokenList.front()->next(), tokenList.back()->previous()); |
| 192 | tokenList.createAst(); |
| 193 | |
| 194 | const Library::Function* func = nullptr; |
| 195 | ASSERT(!library.isNotLibraryFunction(tokenList.front(), &func)); |
| 196 | ASSERT(func); |
| 197 | } |
| 198 | { |
| 199 | TokenList tokenList(settingsDefault, Standards::Language::CPP); |
| 200 | const char code[] = "foo(a, b);"; // <- library function |
| 201 | ASSERT(tokenList.createTokensFromString(code)); |
| 202 | Token::createMutualLinks(tokenList.front()->next(), tokenList.back()->previous()); |
| 203 | tokenList.createAst(); |
| 204 | |
| 205 | const Library::Function* func = nullptr; |
| 206 | ASSERT(!library.isNotLibraryFunction(tokenList.front(), &func)); |
| 207 | ASSERT(func); |
| 208 | } |
| 209 | { |
| 210 | TokenList tokenList(settingsDefault, Standards::Language::CPP); |
| 211 | const char code[] = "foo(a, b, c);"; // <- too much arguments, not library function |
| 212 | ASSERT(tokenList.createTokensFromString(code)); |
| 213 | Token::createMutualLinks(tokenList.front()->next(), tokenList.back()->previous()); |
| 214 | tokenList.createAst(); |
| 215 | |
| 216 | ASSERT(library.isNotLibraryFunction(tokenList.front())); |
| 217 | } |
| 218 | } |
| 219 | |
| 220 | void function_match_var() const { |
| 221 | constexpr char xmldata[] = "<?xml version=\"1.0\"?>\n" |
nothing calls this directly
no test coverage detected