File: UnitTest.h

package info (click to toggle)
steghide 0.5.1-15
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 3,440 kB
  • sloc: cpp: 13,302; ansic: 6,184; sh: 3,960; makefile: 384; yacc: 316; perl: 228; sed: 16
file content (78 lines) | stat: -rw-r--r-- 2,214 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/*
 * steghide 0.5.1 - a steganography program
 * Copyright (C) 1999-2003 Stefan Hetzl <shetzl@chello.at>
 *
 * 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 2
 * 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, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *
 */

#ifndef SH_UNITTEST_H
#define SH_UNITTEST_H

#include <string>
#include <vector>

#include "common.h"

#include "Test.h"
#include "TestCategoryCaller.h"
// declared here to avoid circulating includes
class TestCategory ;
class TestSuite ;

#define ADDTESTCATEGORY(UTCLASS,CMETHOD) \
	addTestCategory (new TestCategoryCaller<UTCLASS> (strip_test(#CMETHOD), getSuite(), this, &UTCLASS::CMETHOD))

class UnitTest : public Test {
	public:
	/**
	 * \param n name of this unit test (probably the name of the tested class)
	 **/
	UnitTest (std::string n, TestSuite* s) : Test(n,s), GlobsBackup(NULL) {} ;

	~UnitTest (void) ;

	/**
	 * setup the unit test - called before run
	 *
	 * UnitTest::setup will (together with UnitTest::cleanup) save and restore the object
	 * stored in Globs so they should be called from the corresponding functions in the
	 * derived object if the derived unit test manipulates the Globs object.
	 **/
	virtual void setup (void) ;

	void run (void) ;

	/**
	 * cleanup the unit test - called after run
	 **/
	virtual void cleanup (void) ;

	protected:
	void addTestCategory (TestCategory *tc) ;

	void addTestResult (bool r) ;

	char *strip_test (char* s)
		{ return (s + 4) ; } ;

	private:
	std::vector<TestCategory*> TestCategories ;

	/// servers as a backup for the Globals object stored in Globs
	Globals GlobsBackup ;
} ;

#endif // ndef SH_UNITTEST_H