summaryrefslogtreecommitdiff
path: root/doc/03-assertions.html
blob: 92126a8d4ada75aa2f5bf58b710604041c9c7671 (plain)
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
<!DOCTYPE HTML>
<html>
<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<link rel="stylesheet" href="style.css">
	<title>Assertions | lily-test</title>
</head>
<body>
	<div id="flex-root">
	<iframe id="toc" src="table-of-contents.html"></iframe>
	<div id="content">


	<h1>Assertions</h1>

	<p>There are two different basic types of assertions: checks and requirements. Both checks and requires will mark the overall test as failed if they are false, but a require will also immediately stop executing the test in addition.<p>

	<h2>Check Macros</h2>

	<h3>CHECK(x)</h3>

	<p>Marks the test as failed if <code>x</code> is false and prints stringified <code>x</code>.</p>

	<h3>CHECK_EQ(x, y, fmt)</h3>

	<p>Marks the test as failed if <code>x == y</code> is false. Prints both the stringified names of <code>x</code> and <code>y</code> as well as their values, using the printf format code provided in <code>fmt</code>.

	<h3>CHECK_NEQ(x, y, fmt)</h3>

	<p>Marks the test as failed if <code>x != y</code> is false. Prints both the stringified names of <code>x</code> and <code>y</code> as well as their values, using the printf format code provided in <code>fmt</code>.

	<h3>CHECK_LT(x, y, fmt)</h3>

	<p>Marks the test as failed if <code>x < y</code> is false. Prints both the stringified names of <code>x</code> and <code>y</code> as well as their values, using the printf format code provided in <code>fmt</code>.

	<h3>CHECK_LE(x, y, fmt)</h3>

	<p>Marks the test as failed if <code>x <= y</code> is false. Prints both the stringified names of <code>x</code> and <code>y</code> as well as their values, using the printf format code provided in <code>fmt</code>.

	<h3>CHECK_GT(x, y, fmt)</h3>

	<p>Marks the test as failed if <code>x > y</code> is false. Prints both the stringified names of <code>x</code> and <code>y</code> as well as their values, using the printf format code provided in <code>fmt</code>.

	<h3>CHECK_GE(x, y, fmt)</h3>

	<p>Marks the test as failed if <code>x >= y</code> is false. Prints both the stringified names of <code>x</code> and <code>y</code> as well as their values, using the printf format code provided in <code>fmt</code>.

	<br>

	<h2>Require Macros</h2>

	<h3>REQUIRE(x)</h3>

	<p>Marks the test as failed and immediately ends test execution if <code>x</code> is false and prints stringified <code>x</code>.</p>

	<h3>REQUIRE_EQ(x, y, fmt)</h3>

	<p>Marks the test as failed and immediately ends test execution if <code>x == y</code> is false. Prints both the stringified names of <code>x</code> and <code>y</code> as well as their values, using the printf format code provided in <code>fmt</code>.

	<h3>REQUIRE_NEQ(x, y, fmt)</h3>

	<p>Marks the test as failed and immediately ends test execution if <code>x != y</code> is false. Prints both the stringified names of <code>x</code> and <code>y</code> as well as their values, using the printf format code provided in <code>fmt</code>.

	<h3>REQUIRE_LT(x, y, fmt)</h3>

	<p>Marks the test as failed and immediately ends test execution if <code>x < y</code> is false. Prints both the stringified names of <code>x</code> and <code>y</code> as well as their values, using the printf format code provided in <code>fmt</code>.

	<h3>REQUIRE_LE(x, y, fmt)</h3>

	<p>Marks the test as failed and immediately ends test execution if <code>x <= y</code> is false. Prints both the stringified names of <code>x</code> and <code>y</code> as well as their values, using the printf format code provided in <code>fmt</code>.

	<h3>REQUIRE_GT(x, y, fmt)</h3>

	<p>Marks the test as failed and immediately ends test execution if <code>x > y</code> is false. Prints both the stringified names of <code>x</code> and <code>y</code> as well as their values, using the printf format code provided in <code>fmt</code>.

	<h3>REQUIRE_GE(x, y, fmt)</h3>

	<p>Marks the test as failed and immediately ends test execution if <code>x >= y</code> is false. Prints both the stringified names of <code>x</code> and <code>y</code> as well as their values, using the printf format code provided in <code>fmt</code>.


	</div>
	</div>
	<div id="footer">
		<a id="prev" href="02-writing-tests.html">⇐ Previous</a>
		<a id="next" href="#">Next ⇒</a>
	</div>
</body>
</html>