1 /*
2 * This file is part of HexEditor plugin for Code::Blocks studio
3 * Copyright (C) 2009 Bartlomiej Swiecki
4 *
5 * HexEditor plugin is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * HexEditor plugin is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with HexEditor plugin. If not, see <http://www.gnu.org/licenses/>.
17 *
18 * $Revision: 7443 $
19 * $Id: TestCasesBase.h 7443 2011-09-01 16:29:16Z mortenmacfly $
20 * $HeadURL: svn://svn.code.sf.net/p/codeblocks/code/branches/release-20.xx/src/plugins/contrib/HexEditor/TestCasesBase.h $
21 */
22 
23 
24 #ifndef TESTCASESBASE_H
25 #define TESTCASESBASE_H
26 
27 /** \brief Base class for performing tests */
28 class TestCasesBase
29 {
30     public:
31 
32         /** \brief Structure gathering the output from tests */
33         struct Output
34         {
35             virtual void AddLog( const wxString& logLine ) = 0;
36             virtual bool StopTest() = 0;
37         };
38 
39         /** \brief Ctor */
TestCasesBase()40         TestCasesBase(): m_Out( 0 ) {}
41 
42         /** \brief Initialize functors */
InitOutput(Output & out)43         inline void InitOutput( Output& out ) { m_Out = &out; }
44 
45         /** \brief Dctor */
~TestCasesBase()46         virtual ~TestCasesBase() {}
47 
48         /** \brief Perform all tests */
49         virtual bool PerformTests() = 0;
50 
51     protected:
52 
53         /** \brief Output some test log */
AddLog(const wxString & logLine)54         inline void AddLog( const wxString& logLine ) { m_Out->AddLog( logLine ); }
55 
56         /** \brief Check if we should stop */
StopTest()57         inline bool StopTest() { return m_Out->StopTest(); }
58 
59     private:
60 
61         Output* m_Out;  ///< \brief structure gathering the output
62 };
63 
64 #endif
65