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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
|
// regress.h -- Regression test program, header file
// $Id$
// This is part of Metakit, see http://www.equi4.com/metakit/
#include "mk4.h"
#include "mk4io.h"
#include "mk4str.h"
#define TraceAll false
// default for dos and unix is to assume they don't support exceptions
#if defined (_DOS) || defined (unix) || defined (__unix__) || \
defined (__GNUC__) || defined (_WIN32_WCE)
#if !defined (q4_NOTHROW)
#define q4_NOTHROW 1
#endif
#endif
#ifdef _WIN32_WCE
int remove(const char*);
#endif
#if _MSC_VER == 800
#pragma warning (disable: 4703) // function too large for global optimizations
// also no exceptions in MSVC 1.52 when used with a QuickWin target
#if defined (_TQWINVER) && !defined (q4_NOTHROW)
#define q4_NOTHROW 1
#endif
#endif
#if q4_NOTHROW
#define try
#define catch(x) if (0)
extern const char* msg;
#endif
#if defined (macintosh)
#define TESTDIR ":tests:"
#define TEXTOUT "wt"
#define LINESEP "\r"
#elif defined (__VMS)
#define TESTDIR "[.tests]"
#define TEXTOUT "w"
#define LINESEP "\r\n" // is this correct?
#elif defined (unix) || defined (__unix__) || defined (__GNUC__)
#define TESTDIR "tests/"
#define TEXTOUT "w"
#define LINESEP "\n"
#else
#define TESTDIR "tests\\"
#define TEXTOUT "wt"
#define LINESEP "\r\n"
#endif
#include <stdio.h>
#if q4_MFC && defined(_DEBUG)
#define B(n_,d_,c_) \
if (StartTest(c_, #n_, #d_)) \
{ \
CMemoryState oldState, newState, diffState; \
oldState.Checkpoint(); \
afxTraceEnabled = TraceAll; \
try \
{ \
{
#define E \
} \
puts("<<< done."); \
} \
catch (const char* msg) { CatchMsg(msg); } \
catch (...) { CatchOther(); } \
afxTraceEnabled = true; \
fflush(stdout); \
newState.Checkpoint(); \
if (diffState.Difference(oldState, newState)) \
{ \
fputs("\tMemory leaked!\n", stderr); \
puts("*** Memory leaked ***"); \
TRACE(" *** Memory leaked, "); \
diffState.DumpAllObjectsSince(); \
} \
fflush(stdout); \
}
#else
#define B(n_,d_,c_) \
if (StartTest(c_, #n_, #d_)) \
{ \
try \
{ \
{
#define E \
} \
puts("<<< done."); \
} \
catch (const char* msg) { CatchMsg(msg); } \
catch (...) { CatchOther(); } \
fflush(stdout); \
}
#endif
#define A(e_) if (e_) ; else FailExpr(#e_)
#define W(f_) remove(#f_)
#define R(f_) A(remove(#f_) == 0)
#define D(f_) DumpFile(#f_, TESTDIR #f_ ".txt")
typedef c4_BytesProp c4_MemoProp;
extern void DumpFile(const char* in_, const char* out_);
extern void Fail(const char* msg);
extern void FailExpr(const char* expr);
extern int StartTest(int, const char*, const char*);
extern void CatchMsg(const char* msg);
extern void CatchOther();
extern void TestBasics1();
extern void TestBasics2();
extern void TestCustom1();
extern void TestCustom2();
extern void TestDiffer();
extern void TestExtend();
extern void TestFormat();
extern void TestLimits();
extern void TestMapped();
extern void TestNotify();
extern void TestResize();
extern void TestStores1();
extern void TestStores2();
extern void TestStores3();
extern void TestStores4();
extern void TestStores5();
|