File: faq.html

package info (click to toggle)
libtut 0.0.20070706-3
  • links: PTS
  • area: main
  • in suites: bookworm, bullseye
  • size: 1,144 kB
  • sloc: cpp: 3,588; xml: 137; makefile: 18; ansic: 9
file content (401 lines) | stat: -rw-r--r-- 10,448 bytes parent folder | download | duplicates (3)
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
<title>TUT Frequently Asked Questions - TUT: C++ Unit Test Framework</title>
<meta name="keywords" content="C++ test-driven unit tests TUT framework STL">
<meta name="description" content="TUT Frequently Asked Questions - often asked questions and answers for them">
<style type="text/css">
<!--

body, p, td
{
	scrollbar-base-color: #eeeeee;
	scrollbar-track-color: #ffffff;
	scrollbar-arrow-color: #cccccc;
	scrollbar-shadow-color: #cccccc;
	scrollbar-highlight-color: #cccccc;
	scrollbar-darkshadow-color: #ffffff;
	scrollbar-3dlight-color: #ffffff;
	
	/*
	scrollbar-base-color: #cccccc;
	scrollbar-track-color: #ffffff;
	scrollbar-arrow-color: #eeeeee;
	*/
	
	font-family : Verdana, Arial, Helvetica, sans-serif;
	font-size : 14px;
	color: #000000;
}

pre
{
	font-family : Courier, sans-serif;
	font-size : 12px;
}

strong, b
{
	font-weight : bold;
}

ul
{
	list-style-type : square;
}

.header
{
	font-size : 24px;
	font-weight : bold;
}

.subheader
{
	font-size : 16px;
	font-weight : bold;
}

.logo
{
	font-size : 24px;
	font-weight : bold;
}

.question
{
	font-size : 16px;
	font-weight : bold;
	color : #000000;
}

a
{
	font-weight : bold;
	color : #ff9900;
	text-decoration : none;
}

a:hover
{
	font-weight : bold;
	color : #ff9900;
	text-decoration : underline;
}

a:visited
{
	font-weight : bold;
	color : #ff9900;
}

a.menu
{
	font-weight : bold;
	color : #ff9900;
	text-decoration : none;
}

a.menu:hover
{
	font-weight : bold;
	color : #ff9900;
	text-decoration : underline;
}

a.menu:visited
{
	font-weight : bold;
	color : #ff9900;
}

//-->
</style>
</head>

<body text="#000000" link="#ff9900" alink="#ffcc00" vlink="#ff9900" bgcolor="#ffffff" leftmargin=0 topmargin=0 marginheight=0 marginwidth=0>

<img src="/_img/pixel.gif" alt="" width=1 height=20><br>
<table width="100%" cellspacing=0 cellpadding=0>
<tr>
<td width=20 align=left valign=top>
<img src="/_img/pixel.gif" alt="" width=20 height=1><br>
</td>
<td width="100%" align=left valign=top>
<!-- home table >> -->
<table width="100%" cellspacing=0 cellpadding=0>
<tr>
<td width="100%" align=center valign=center bgcolor="#cccccc">
<!-- >> -->
<table width="100%" cellspacing=1 cellpadding=10>
<tr>
<td width="100%" align=left valign=top bgcolor="#eeeeee">
<p class="logo"><a href="/">TUT: C++ Unit Test Framework</a></p>
</td>
</tr>
</table>
<!-- << -->
</td>
</tr>
</table>
<!-- home table << -->
</td>
<td width=20 align=left valign=top>
<img src="/_img/pixel.gif" alt="" width=20 height=1><br>
</td>
</tr>
</table>

<table border=0 width="100%" cellspacing=20 cellpadding=0>
<tr>
<td width="30%" align=left valign=top>
<!-- menu table >> -->
<table width="100%" cellspacing=0 cellpadding=0>
<tr>
<td width="100%" align=center valign=center bgcolor="#cccccc">
<!-- >> -->
<table width="100%" cellspacing=1 cellpadding=10>
<tr>
<td width="100%" align=left valign=top bgcolor="#eeeeee">
<p class="subheader">Documentation</p>
<ul>
<li><p><a href="/howto/" class="menu">TUT How-To</a><br>minimum steps to make TUT work for you</p></li>
<li><p><a href="/design/" class="menu">TUT Design</a><br>what's hidden under the hood of tut.h, and why things are such as they
		are</p></li>
<li><p><a href="/example/" class="menu">TUT Usage Example</a><br>it's better to see once...</p></li>
<li><p><a href="/whole/" class="menu">TUT As Is</a><br>complete source of TUT</p></li>
</ul>
<p class="subheader">Distribution</p>
<ul>
<li><p><a href="/copyright/" class="menu">The TUT License</a><br>almost no restrictions to use</p></li>
<li><p><a href="/download/" class="menu">TUT Downloads</a><br>latest version of TUT as well as other related stuff</p></li>
</ul>
<p class="subheader">Support</p>
<ul>
<li><p><strong>TUT Frequently Asked Questions</strong><br>often asked questions and answers for them</p></li>
<li><p><a href="/links/" class="menu">Links</a><br>related projects and concepts</p></li>
<li><p><a href="/author/" class="menu">TUT Author</a><br>who is the author</p></li>
</ul>
</td>
</tr>
</table>
<!-- << -->
</td>
</tr>
</table>
<!-- menu table << -->
</td>
<td width="70%" valign=top>
<!-- content table >> -->
<table width="100%" cellspacing=0 cellpadding=0>
<tr>
<td width="100%" align=center valign=center bgcolor="#cccccc">
<!-- >> -->
<table width="100%" cellspacing=1 cellpadding=10>
<tr>
<td width="100%" align=left valign=top bgcolor="#eeeeee">
<p class="header">TUT Frequently Asked Questions</p>
<p class="question">What is TUT?</p>
<p>
TUT is a small and portable unit test framework for C++. It's so small that it fits into
one header file. It's so portable that it could be used on almost any C++ platform, including
Windows, MacOS and unices.
</p>


<p class="question">
How it's different from C++Unit (boost::test, ...)?
</p>
<p>
C++Unit, boost::test and other frameworks perform similar tasks.
</p> 

<p>
But there are some issues with most of them: 
<ul>
<li>they require to build them as a library</li>
<li>tests depend on preprocessor macros</li>
<li>they often overloaded with features</li>
</ul>
</p>

<p>
TUT, in contrast, is located in a single header file (20K). 
All you should do is to include it into the test module. No linking at all.
</p>

<p>
TUT uses C++ template engine to dispatch calls to test methods. Therefore 
you shouldn't even register methods as tests: template will do it for you automatically. 
As a result, the test code will be more readable.
</p>

<p>
And finally, TUT is a minimal software. It only does what it's designed for. 
It doesn't attempt to integrate with MSDN or to control production processes. It just runs tests.
</p>


<p class="question">
What compilers are supported?
</p>

<p>
Most modern compilers are supported.
Some outdated compilers are unable to handle templates in TUT, though
</p>

<p>Supported:
<ul>
  <li>GNU GCC 2.95</li>
  <li>GNU GCC 3.x (both under unix and <a href="http://www.mingw.org">MinGW</a>)</li>
  <li>Borland 5.6 (Borland C++ Builder 6)</li>
  <li>Intel C++ Compiler 6.x</li>
  <li>Intel C++ Compiler 8.1</li>
  <li>Sun Studio 9: C++ 5.6 Compiler</li>
  <li>Microsoft VC7 (Microsoft VS.NET 2003 and later)</li>
  <li>Sun WorkShop 6 update 2 C++ 5.3 (probably, previous versions as well)</li>
</ul>
</p>
<p>Unsupported:
<ul>
  <li>Borland 5.5.x (Borland C++ Builder 5)</li>
  <li>Microsoft VC6 (including SP5)</li>
  <li>Microsoft VC7 (Microsoft VS.NET 2002)</li>
  <li>C for AIX Compiler, Version 6</li>
  <li>KAI C++ Compiler</li>
  <li>Portland Group Compiler, Version 5.2-4</li>
</ul>
</p>

<p>
  If you use TUT with any other compiler or environment please let me know.
</p>

<p>
Some broken compiler/linker/platform combinations require to make methods ensure(),
ensure_equals and fail() to be inline, and not in anonymous namespace. Try to
change tut.h accordingly if you see "duplicate symbol ensure" or "ensure is not found" 
during linking stage.
</p>


<p class="question">
I've taken a look at the selftest code and it looks awful
</p>

<p>
Self tests are very special beasties, and actually you've seen 
two(!) TUT frameworks running one under control of another. The case is 
quite extreme. Regular TUT tests are very simple to read; you'd better look 
at the online <a href="/example">example</a>.
</p>


<p class="question">
Why don't you provide methods to catch user-code exceptions?
</p>

<p>
First of all, the user-code exceptions are intercepted inside the test runner, 
and afterwards  user receives them along with the test_result status. For std 
exceptions, a textual message is included into results. For the others there 
will be a message that an unknown exception was generated.
</p>


<p class="question">
I've used ensure_equals() method and compiler refused to build my code complaining that there is ambiguous overload for operator &lt;&lt;.
</p>
<p>
One or both types you've provided to ensure_equals() have no operator &lt;&lt; at all. 
Since the diagnostic message is built using std::stringstream, compiler needs the 
operator to format your objects. Either add the operator or use ensure() method 
(which doesn't tell you the exact values the objects had, just the fact they were not equal).
</p>


<p class="question">
What about segmentation faults in code being tested? What about deadlocks?
</p>

<p>
C++ Standard doesn't specify what happens if the code references
wrong address. Thus, segmentation fault processing is system and compiler dependent,
and shall be handled differently in each system/compiler pair.
</p>

<p>
If you want TUT to react correctly to tests failures caused by segfaults,
you must somehow convert hardware faults into C++ exceptions.
</p>

<p>
For Win32 TUT uses SEH. You need to specify -DTUT_USE_SEH at build time.
</p>

<p>
For unixes there is no standard way to convert SIGSEGV into an exception.
Consult your platform/compiler documentation for possible ways to do that.
</p>
      
<p>
You may also use restartable wrapper defined in optional header 
tut_restartable.h. It runs the tests the same way
as regular runner does, but also logs the progress. If a test crashes the test 
application, and then test application runs again, the wrapper will load last 
log record, and continue test execution from position after the crashed test.
</p>

<p>
Of course, this requires helper script that runs test application
until all tests will be runned. The script might be is as simple as
</p>

      <pre>
while true
do
  ./restartable &amp;&amp; exit 0
done
      </pre>

<p>Directory examples/restartable contains simple restartable test application.</p>

<p>
This approach can be extended to support deadlocks in code. The script
must be modified to automatically kill test application after specified
period of time.
</p>
<img src="/_img/pixel.gif" alt="" width=1 height=300><br>

<center>
<!--RAX counter-->
<script language="JavaScript">
<!--
document.write('<a href="http://www.rax.ru/click" '+
'target=_blank><img src="http://counter.yadro.ru/hit?t13.4;r'+
escape(document.referrer)+((typeof(screen)=='undefined')?'':
';s'+screen.width+'*'+screen.height+'*'+(screen.colorDepth?
screen.colorDepth:screen.pixelDepth))+';'+Math.random()+
'" alt="rax.ru:     24 ,   24    \" '+
'border=0 width=88 height=31></a><br>')
//-->
</script>
<!--/RAX-->
</center>

</td>
</tr>
</table>
<!-- << -->
</td>
</tr>
</table>
<!-- content table << -->
</td>
</tr>
</table>

</body>
</html>