| 44 | } |
| 45 | |
| 46 | static std::string testTokenRange(ConstTokenRange range, const Token* start, const Token* end) { |
| 47 | auto tokenToString = [](const Token* t) { |
| 48 | return t ? t->str() : "<null>"; |
| 49 | }; |
| 50 | int index = 0; |
| 51 | const Token* expected = start; |
| 52 | for (const Token* t : range) { |
| 53 | if (expected != t) { |
| 54 | std::ostringstream message; |
| 55 | message << "Failed to match token " << tokenToString(expected) << " at position " << index << ". Got " << tokenToString(t) << " instead"; |
| 56 | return message.str(); |
| 57 | } |
| 58 | index++; |
| 59 | expected = expected->next(); |
| 60 | } |
| 61 | if (expected != end) { |
| 62 | std::ostringstream message; |
| 63 | message << "Failed to terminate on " << tokenToString(end) << ". Instead terminated on " << tokenToString(expected) << " at position " << index << "."; |
| 64 | return message.str(); |
| 65 | } |
| 66 | return ""; |
| 67 | } |
| 68 | |
| 69 | void enumerationToEnd() const { |
| 70 | const char code[] = "void a(){} void main(){ if(true){a();} }"; |
nothing calls this directly
no test coverage detected