<commit_before>#include "TextTestResult.h"
#include "Exception.h"
#include "estring.h"
#include "Test.h"

using namespace std;
using namespace CppUnit;



std::ostream& 
CppUnit::operator<< (std::ostream& stream, TextTestResult& result)
{ 
  result.print (stream); return stream; 
}

void 
TextTestResult::addError (Test *test, Exception *e)
{
    TestResult::addError (test, e);
    cerr << "E\n";

}

void 
TextTestResult::addFailure (Test *test, Exception *e)
{
    TestResult::addFailure (test, e);
    cerr << "F\n";

}

void 
TextTestResult::startTest (Test *test)
{

  cerr << "Running " << test->getName() << " ";
  TestResult::startTest (test);
  cerr << ".\n";

}


void 
TextTestResult::printErrors (ostream& stream)
{
    if (testErrors () != 0) {

        if (testErrors () == 1)
            stream << "There was " << testErrors () << " error: " << endl;
        else
            stream << "There were " << testErrors () << " errors: " << endl;

        int i = 1;

        for (vector<TestFailure *>::iterator it = errors ().begin (); it != errors ().end (); ++it) {
            TestFailure             *failure    = *it;
            Exception        *e          = failure->thrownException ();

            stream << i 
                   << ") "
                   << "line: " << (e ? estring (e->lineNumber ()) : "") << " "
                   << (e ? e->fileName () : "") << " "
                   << "\"" << failure->thrownException ()->what () << "\""
                   << endl;
            i++;
        }
    }

}

void 
TextTestResult::printFailures (ostream& stream) 
{
    if (testFailures () != 0) {
        if (testFailures () == 1)
            stream << "There was " << testFailures () << " failure: " << endl;
        else
            stream << "There were " << testFailures () << " failures: " << endl;

        int i = 1;

        for (vector<TestFailure *>::iterator it = failures ().begin (); it != failures ().end (); ++it) {
            TestFailure             *failure    = *it;
            Exception        *e          = failure->thrownException ();

            stream << i 
                   << ") "
                   << "line: " << (e ? estring (e->lineNumber ()) : "") << " "
                   << (e ? e->fileName () : "") << " "
                   << "\"" << failure->thrownException ()->what () << "\""
                   << endl;
            i++;
        }
    }

}


void 
TextTestResult::print (ostream& stream) 
{
    printHeader (stream);
    printErrors (stream);
    printFailures (stream);

}


void 
TextTestResult::printHeader (ostream& stream)
{
    if (wasSuccessful ())
        cout << endl << "OK (" << runTests () << " tests)" << endl;
    else
        cout << endl
             << "!!!FAILURES!!!" << endl
             << "Test Results:" << endl
             << "Run:  "
             << runTests ()
             << "   Failures: "
             << testFailures ()
             << "   Errors: "
             << testErrors ()
             << endl;

}<commit_msg>Fix bug #232636: TextTestResult::printHeader(ostream& stream) outputs to cout.<commit_after>#include "TextTestResult.h"
#include "Exception.h"
#include "estring.h"
#include "Test.h"

using namespace std;
using namespace CppUnit;



std::ostream& 
CppUnit::operator<< (std::ostream& stream, TextTestResult& result)
{ 
  result.print (stream); return stream; 
}

void 
TextTestResult::addError (Test *test, Exception *e)
{
    TestResult::addError (test, e);
    cerr << "E\n";

}

void 
TextTestResult::addFailure (Test *test, Exception *e)
{
    TestResult::addFailure (test, e);
    cerr << "F\n";

}

void 
TextTestResult::startTest (Test *test)
{

  cerr << "Running " << test->getName() << " ";
  TestResult::startTest (test);
  cerr << ".\n";

}


void 
TextTestResult::printErrors (ostream& stream)
{
    if (testErrors () != 0) {

        if (testErrors () == 1)
            stream << "There was " << testErrors () << " error: " << endl;
        else
            stream << "There were " << testErrors () << " errors: " << endl;

        int i = 1;

        for (vector<TestFailure *>::iterator it = errors ().begin (); it != errors ().end (); ++it) {
            TestFailure             *failure    = *it;
            Exception        *e          = failure->thrownException ();

            stream << i 
                   << ") "
                   << "line: " << (e ? estring (e->lineNumber ()) : "") << " "
                   << (e ? e->fileName () : "") << " "
                   << "\"" << failure->thrownException ()->what () << "\""
                   << endl;
            i++;
        }
    }

}

void 
TextTestResult::printFailures (ostream& stream) 
{
    if (testFailures () != 0) {
        if (testFailures () == 1)
            stream << "There was " << testFailures () << " failure: " << endl;
        else
            stream << "There were " << testFailures () << " failures: " << endl;

        int i = 1;

        for (vector<TestFailure *>::iterator it = failures ().begin (); it != failures ().end (); ++it) {
            TestFailure             *failure    = *it;
            Exception        *e          = failure->thrownException ();

            stream << i 
                   << ") "
                   << "line: " << (e ? estring (e->lineNumber ()) : "") << " "
                   << (e ? e->fileName () : "") << " "
                   << "\"" << failure->thrownException ()->what () << "\""
                   << endl;
            i++;
        }
    }

}


void 
TextTestResult::print (ostream& stream) 
{
    printHeader (stream);
    printErrors (stream);
    printFailures (stream);

}


void 
TextTestResult::printHeader (ostream& stream)
{
    if (wasSuccessful ())
        stream << endl << "OK (" << runTests () << " tests)" << endl;
    else
        stream << endl
             << "!!!FAILURES!!!" << endl
             << "Test Results:" << endl
             << "Run:  "
             << runTests ()
             << "   Failures: "
             << testFailures ()
             << "   Errors: "
             << testErrors ()
             << endl;

}
{'fraction_non_alphanumeric': 0.18044866546585886, 'fraction_numerical': 0.002947437366955952, 'mean_word_length': 1.711051930758988, 'pattern_counts': {'":': 0, '<': 255, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2197099', 'n_tokens_mistral': 1856, 'n_tokens_neox': 1782, 'n_words': 411}