CppTest home page CppTest project page

cpptest-collectoroutput.h

Go to the documentation of this file.
00001 // ---
00002 //
00003 // $Id: cpptest-collectoroutput.h,v 1.3 2005/06/08 08:08:06 nilu Exp $
00004 //
00005 // CppTest - A C++ Unit Testing Framework
00006 // Copyright (c) 2003 Niklas Lundell
00007 //
00008 // ---
00009 //
00010 // This library is free software; you can redistribute it and/or
00011 // modify it under the terms of the GNU Lesser General Public
00012 // License as published by the Free Software Foundation; either
00013 // version 2 of the License, or (at your option) any later version.
00014 //
00015 // This library is distributed in the hope that it will be useful,
00016 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00018 // Lesser General Public License for more details.
00019 //
00020 // You should have received a copy of the GNU Lesser General Public
00021 // License along with this library; if not, write to the
00022 // Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00023 // Boston, MA 02111-1307, USA.
00024 //
00025 // ---
00026 
00029 #ifndef CPPTEST_COLLECTOROUTPUT_H
00030 #define CPPTEST_COLLECTOROUTPUT_H
00031 
00032 #include <list>
00033 #include <string>
00034 #include <vector>
00035 
00036 #include "cpptest-output.h"
00037 #include "cpptest-source.h"
00038 #include "cpptest-time.h"
00039 
00040 namespace Test
00041 {
00047     class CollectorOutput : public Output
00048     {
00049     public:
00050         virtual void finished(int tests, const Time& time);
00051         virtual void suite_start(int tests, const std::string& name);
00052         virtual void suite_end(int tests, const std::string& name,
00053                                const Time& time);
00054         virtual void test_start(const std::string& name);
00055         virtual void test_end(const std::string& name, bool ok,
00056                               const Time& time);
00057         virtual void assertment(const Source& s);
00058         
00059     protected:
00060         struct OutputSuiteInfo;
00061         struct OutputTestInfo;
00062         struct OutputErrorTestInfo;
00063         
00064         typedef std::list<Source> Sources;
00065         
00066         struct TestInfo
00067         {
00068             std::string _name;
00069             Time        _time;
00070             
00071             bool        _success : 1;
00072             Sources     _sources;
00073             
00074             explicit TestInfo(const std::string name);
00075         };
00076         
00077         typedef std::vector<TestInfo> Tests;
00078         
00079         struct SuiteInfo
00080         {
00081             std::string _name;
00082             int         _errors;
00083             Tests       _tests;
00084             Time        _time;
00085             
00086             SuiteInfo(const std::string& name, int tests);
00087         };
00088         
00089         typedef std::list<SuiteInfo> Suites;
00090         
00091         Suites          _suites;
00092         int             _total_errors;
00093         int             _total_tests;
00094         Time            _total_time;
00095         
00096         CollectorOutput();
00097         
00098     private:
00099         SuiteInfo*      _cur_suite;
00100         TestInfo*       _cur_test;
00101     };
00102     
00103 } // namespace Test
00104     
00105 #endif // #ifndef CPPTEST_COLLECTOROUTPUT_H
00106 

Supported by:

SourceForge Logo