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

Method nextprevious

test/testtoken.cpp:138–156  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

136 }
137
138 void nextprevious() const {
139 auto tokensFrontBack = std::make_shared<TokensFrontBack>();
140 auto *token = new Token(list, std::move(tokensFrontBack));
141 token->str("1");
142 (void)token->insertToken("2");
143 (void)token->next()->insertToken("3");
144 Token *last = token->tokAt(2);
145 ASSERT_EQUALS(token->str(), "1");
146 ASSERT_EQUALS(token->strAt(1), "2");
147 ASSERT_EQUALS(token->tokAt(2)->str(), "3");
148 ASSERT_EQUALS_MSG(true, last->next() == nullptr, "Null was expected");
149
150 ASSERT_EQUALS(last->str(), "3");
151 ASSERT_EQUALS(last->strAt(-1), "2");
152 ASSERT_EQUALS(last->tokAt(-2)->str(), "1");
153 ASSERT_EQUALS_MSG(true, token->previous() == nullptr, "Null was expected");
154
155 TokenList::deleteTokens(token);
156 }
157
158#define MatchCheck(...) MatchCheck_(__FILE__, __LINE__, __VA_ARGS__)
159 bool MatchCheck_(const char* file, int line, const std::string& code, const std::string& pattern) {

Callers

nothing calls this directly

Calls 4

insertTokenMethod · 0.80
nextMethod · 0.80
strMethod · 0.45
tokAtMethod · 0.45

Tested by

no test coverage detected