[ Web Proxy ]
URL:
Viewing: https://raw.githubusercontent.com/napcode/cppcheck/master/test/testsuite.cpp [Back]  [Original]

/*
 * Cppcheck - A tool for static C/C++ code analysis
 * Copyright (C) 2007-2019 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 "testsuite.h"

#include "options.h"
#include "redirect.h"

#include 
#include 
#include 

std::ostringstream errout;
std::ostringstream output;

/**
 * TestRegistry
 **/

struct CompareFixtures {
    bool operator()(const TestFixture* lhs, const TestFixture* rhs) const {
        return lhs->classname < rhs->classname;
    }
};

typedef std::set TestSet;
class TestRegistry {
    TestSet _tests;
public:

    static TestRegistry &theInstance() {
        static TestRegistry testreg;
        return testreg;
    }

    void addTest(TestFixture *t) {
        _tests.insert(t);
    }

    const TestSet &tests() const {
        return _tests;
    }
};


/**
 * TestFixture
 **/

std::ostringstream TestFixture::errmsg;
unsigned int       TestFixture::countTests;

std::size_t TestFixture::fails_counter = 0;
std::size_t TestFixture::todos_counter = 0;
std::size_t TestFixture::succeeded_todos_counter = 0;
std::set TestFixture::missingLibs;

TestFixture::TestFixture(const char * const _name)
    :mVerbose(false),
     quiet_tests(false),
     classname(_name)
{
    TestRegistry::theInstance().addTest(this);
}


bool TestFixture::prepareTest(const char testname[])
{
    mVerbose = false;
    mTemplateFormat.clear();
    mTemplateLocation.clear();

    // Check if tests should be executed
    if (testToRun.empty() || testToRun == testname) {
        // Tests will be executed - prepare them
        mTestname = testname;
        ++countTests;
        if (quiet_tests) {
            std::putchar('.'); // Use putchar to write through redirection of std::cout/cerr
            std::fflush(stdout);
        } else {
            std::cout 

Web Proxy Viewer  |  New URL  |  Original Page