File: TUT-2007-03-19.xml

package info (click to toggle)
libtut 0.0.20070706-1
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd, lenny, squeeze, stretch, wheezy
  • size: 1,020 kB
  • ctags: 607
  • sloc: cpp: 3,588; sh: 2,202; xml: 137; makefile: 59; ansic: 9
file content (59 lines) | stat: -rw-r--r-- 1,526 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
<?xml version="1.0"?>
<changes>

<p>
Introduced a new exception <code>tut_error</code> as base for all TUT exceptions.
I have two reasons to do it:
<ul>
	<li>
		To avoid interference with <code>std::logic_error</code> leading to annoyed pitfalls
		in inaccurate test code. For example:<pre>
	// function to test
	void foo(bool cond)
	{
		if (!cond) 
		{
			throw logic_error("condition is not set");
		}
	}
	
	// inside a test
	try
	{
		ensure("something", some_expression); // can throw logic_error
		foo(false);
	}
	catch (const logic_error&amp;)
	{
		// ok or pitfall?
	}
</pre>
		Howewer, because of that <code>tut_error</code> is derived from 
		<code>std::exception</code>, you should avoid catching <code>std::exception</code> 
		in your test code without appropriate checks.
	</li>
	<li>
		Some implementations of Standard C++ Library restrict size of a message passed into
		a standard exception (from &lt;stdexcept&gt;) within narrow limits 
		(usually, 256 bytes). Sometimes, it leads to incomplete messages in TUT reports. 
	</li>
</ul>
</p>
<p>
Minors: 
	<ul>
		<li>
			actual and expected values are quoted to increase failure messages readability;
		</li>
		<li>
			if <code>ensure_distance</code> fails it will output a range in round brackets
			because range borders are excluded from range (thanks to Koolin Timofey);
		</li>
	</ul>
</p>
<p>
New function added: <code>ensure_not</code>. I found that <code>ensure_not(condition)</code>
is more readable than <code>ensure(!condition)</code>.
</p>

</changes>