1/*
2** Copyright 2004, Michael Pfeiffer (laplace@users.sourceforge.net).
3** Distributed under the terms of the MIT License.
4**
5*/
6
7#ifndef _TEST_H
8#define _TEST_H
9
10#include <stdio.h>
11
12class AssertStatistics {
13private:
14	AssertStatistics();
15
16public:
17	static AssertStatistics* GetInstance();
18
19	void AssertFailed() { fAssertions++; fFailed++; }
20	void AssertPassed() { fAssertions++; fPassed++; }
21
22	void Print();
23
24	int fAssertions;
25	int fPassed;
26	int fFailed;
27	static AssertStatistics* fStatistics;
28};
29
30class Item
31{
32public:
33	Item() { Init(); }
34	Item(const Item& item) : fValue(item.fValue) { Init(); };
35	Item(int value) : fValue(value) { Init(); };
36	virtual ~Item() {  fInstances --; }
37
38	int Value() { return fValue; }
39
40	bool Equals(Item* item) {
41		return item != NULL && fValue == item->fValue;
42	}
43
44	static int GetNumberOfInstances() { return fInstances; }
45
46	void Print() {
47		fprintf(stderr, "[%d] %d", fID, fValue);
48		// fprintf(stderr, "id: %d; value: %d", fID, fValue);
49	}
50
51	static int Compare(const void* a, const void* b);
52
53private:
54	void Init() {
55		fID = fNextID ++;
56		fInstances ++;
57	}
58
59	int fID;     // unique id for each created Item
60	int fValue;  // the value of the item
61
62
63	static int fNextID;
64	static int fInstances;
65};
66
67
68#endif
69