GitHub Viewer
/*
* Cppcheck - A tool for static C/C++ code analysis
* Copyright (C) 2007-2026 Cppcheck team.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
#include "checkpostfixoperator.h"
#include "errortypes.h"
#include "fixture.h"
#include "helpers.h"
#include "settings.h"
#include
class TestPostfixOperator : public TestFixture {
public:
TestPostfixOperator() : TestFixture("TestPostfixOperator") {}
private:
const Settings settings = settingsBuilder().severity(Severity::performance).build();
#define check(...) check_(__FILE__, __LINE__, __VA_ARGS__)
template
void check_(const char* file, int line, const char (&code)[size]) {
// Tokenize..
SimpleTokenizer tokenizer(settings, *this);
ASSERT_LOC(tokenizer.tokenize(code), file, line);
CheckPostfixOperatorImpl checkPostfixOperator(&tokenizer, settings, *this);
checkPostfixOperator.postfixOperator();
}
void run() override {
mNewTemplate = true;
TEST_CASE(testsimple);
TEST_CASE(testfor);
TEST_CASE(testvolatile);
TEST_CASE(testiterator);
TEST_CASE(test2168);
TEST_CASE(pointerSimplest);
TEST_CASE(pointer); // #2321 - postincrement of pointer is OK
TEST_CASE(testtemplate); // #4686
TEST_CASE(testmember);
TEST_CASE(testcomma);
TEST_CASE(testauto); // #8350
}
void testsimple() {
check("int main()\n"
"{\n"
" unsigned int k(0);\n"
" std::cout