xref: /freebsd/contrib/lutok/api-docs/html/a00056.html (revision a259b98fa211ed87bfee58c575de4e2de94ee0fa)
1<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
3<head>
4<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
5<meta http-equiv="X-UA-Compatible" content="IE=11"/>
6<meta name="generator" content="Doxygen 1.9.6"/>
7<meta name="viewport" content="width=device-width, initial-scale=1"/>
8<title>Lutok: test_utils.hpp File Reference</title>
9<link href="tabs.css" rel="stylesheet" type="text/css"/>
10<script type="text/javascript" src="jquery.js"></script>
11<script type="text/javascript" src="dynsections.js"></script>
12<link href="search/search.css" rel="stylesheet" type="text/css"/>
13<script type="text/javascript" src="search/searchdata.js"></script>
14<script type="text/javascript" src="search/search.js"></script>
15<link href="doxygen.css" rel="stylesheet" type="text/css" />
16</head>
17<body>
18<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
19<div id="titlearea">
20<table cellspacing="0" cellpadding="0">
21 <tbody>
22 <tr id="projectrow">
23  <td id="projectalign">
24   <div id="projectname">Lutok<span id="projectnumber">&#160;0.6.2</span>
25   </div>
26  </td>
27 </tr>
28 </tbody>
29</table>
30</div>
31<!-- end header part -->
32<!-- Generated by Doxygen 1.9.6 -->
33<script type="text/javascript">
34/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
35var searchBox = new SearchBox("searchBox", "search/",'.html');
36/* @license-end */
37</script>
38<script type="text/javascript" src="menudata.js"></script>
39<script type="text/javascript" src="menu.js"></script>
40<script type="text/javascript">
41/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
42$(function() {
43  initMenu('',true,false,'search.php','Search');
44  $(document).ready(function() { init_search(); });
45});
46/* @license-end */
47</script>
48<div id="main-nav"></div>
49<!-- window showing the filter options -->
50<div id="MSearchSelectWindow"
51     onmouseover="return searchBox.OnSearchSelectShow()"
52     onmouseout="return searchBox.OnSearchSelectHide()"
53     onkeydown="return searchBox.OnSearchSelectKey(event)">
54</div>
55
56<!-- iframe showing the search results (closed by default) -->
57<div id="MSearchResultsWindow">
58<div id="MSearchResults">
59<div class="SRPage">
60<div id="SRIndex">
61<div id="SRResults"></div>
62<div class="SRStatus" id="Loading">Loading...</div>
63<div class="SRStatus" id="Searching">Searching...</div>
64<div class="SRStatus" id="NoMatches">No Matches</div>
65</div>
66</div>
67</div>
68</div>
69
70</div><!-- top -->
71<div class="header">
72  <div class="summary">
73<a href="#nested-classes">Classes</a> &#124;
74<a href="#define-members">Macros</a> &#124;
75<a href="#func-members">Functions</a>  </div>
76  <div class="headertitle"><div class="title">test_utils.hpp File Reference</div></div>
77</div><!--header-->
78<div class="contents">
79
80<p>Utilities for tests of the lua modules.
81<a href="#details">More...</a></p>
82<div class="textblock"><code>#include &lt;atf-c++.hpp&gt;</code><br />
83<code>#include &quot;<a class="el" href="a00032_source.html">c_gate.hpp</a>&quot;</code><br />
84<code>#include &quot;<a class="el" href="a00053_source.html">exceptions.hpp</a>&quot;</code><br />
85<code>#include &quot;<a class="el" href="a00029_source.html">state.hpp</a>&quot;</code><br />
86</div>
87<p><a href="a00056_source.html">Go to the source code of this file.</a></p>
88<table class="memberdecls">
89<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="nested-classes" name="nested-classes"></a>
90Classes</h2></td></tr>
91<tr class="memitem:"><td class="memItemLeft" align="right" valign="top">class &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00923.html">anonymous_namespace{test_utils.hpp}::stack_balance_checker</a></td></tr>
92<tr class="memdesc:"><td class="mdescLeft">&#160;</td><td class="mdescRight">Ensures that the Lua stack maintains its original height upon exit.  <a href="a00923.html#details">More...</a><br /></td></tr>
93<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
94</table><table class="memberdecls">
95<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="define-members" name="define-members"></a>
96Macros</h2></td></tr>
97<tr class="memitem:a8f10eccfd8799f9631163705fb92ea5a"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00056.html#a8f10eccfd8799f9631163705fb92ea5a">REQUIRE_API_ERROR</a>(exp_api_function,  statement)</td></tr>
98<tr class="memdesc:a8f10eccfd8799f9631163705fb92ea5a"><td class="mdescLeft">&#160;</td><td class="mdescRight">Checks that a given expression raises a particular <a class="el" href="a00899.html" title="Exception for errors raised by the Lua API library.">lutok::api_error</a>.  <br /></td></tr>
99<tr class="separator:a8f10eccfd8799f9631163705fb92ea5a"><td class="memSeparator" colspan="2">&#160;</td></tr>
100</table><table class="memberdecls">
101<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="func-members" name="func-members"></a>
102Functions</h2></td></tr>
103<tr class="memitem:a790da0edff2966ce9a413e689d522c19"><td class="memItemLeft" align="right" valign="top">static lua_State *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00067.html#a790da0edff2966ce9a413e689d522c19">anonymous_namespace{test_utils.hpp}::raw</a> (<a class="el" href="a00919.html">lutok::state</a> &amp;state)</td></tr>
104<tr class="memdesc:a790da0edff2966ce9a413e689d522c19"><td class="mdescLeft">&#160;</td><td class="mdescRight">Gets the pointer to the internal lua_State of a state object.  <br /></td></tr>
105<tr class="separator:a790da0edff2966ce9a413e689d522c19"><td class="memSeparator" colspan="2">&#160;</td></tr>
106</table>
107<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
108<div class="textblock"><p>Utilities for tests of the lua modules. </p>
109<p>This file is intended to be included once, and only once, for every test program that needs it. All the code is herein contained to simplify the dependency chain in the build rules. </p>
110</div><h2 class="groupheader">Macro Definition Documentation</h2>
111<a id="a8f10eccfd8799f9631163705fb92ea5a" name="a8f10eccfd8799f9631163705fb92ea5a"></a>
112<h2 class="memtitle"><span class="permalink"><a href="#a8f10eccfd8799f9631163705fb92ea5a">&#9670;&#160;</a></span>REQUIRE_API_ERROR</h2>
113
114<div class="memitem">
115<div class="memproto">
116      <table class="memname">
117        <tr>
118          <td class="memname">#define REQUIRE_API_ERROR</td>
119          <td>(</td>
120          <td class="paramtype">&#160;</td>
121          <td class="paramname">exp_api_function, </td>
122        </tr>
123        <tr>
124          <td class="paramkey"></td>
125          <td></td>
126          <td class="paramtype">&#160;</td>
127          <td class="paramname">statement&#160;</td>
128        </tr>
129        <tr>
130          <td></td>
131          <td>)</td>
132          <td></td><td></td>
133        </tr>
134      </table>
135</div><div class="memdoc">
136<b>Value:</b><div class="fragment"><div class="line">    <span class="keywordflow">do</span> { \</div>
137<div class="line">        <span class="keywordflow">try</span> { \</div>
138<div class="line">            statement; \</div>
139<div class="line">            ATF_FAIL(<span class="stringliteral">&quot;api_error not raised by &quot;</span> #statement); \</div>
140<div class="line">        } <span class="keywordflow">catch</span> (<span class="keyword">const</span> <a class="code hl_class" href="a00899.html">lutok::api_error</a>&amp; api_error) { \</div>
141<div class="line">            ATF_REQUIRE_EQ(exp_api_function, api_error.<a class="code hl_function" href="a00899.html#a69a79fd116c6ab783e40139220fad08b">api_function</a>()); \</div>
142<div class="line">        } \</div>
143<div class="line">    } <span class="keywordflow">while</span> (0)</div>
144<div class="ttc" id="aa00899_html"><div class="ttname"><a href="a00899.html">lutok::api_error</a></div><div class="ttdoc">Exception for errors raised by the Lua API library.</div><div class="ttdef"><b>Definition:</b> exceptions.hpp:53</div></div>
145<div class="ttc" id="aa00899_html_a69a79fd116c6ab783e40139220fad08b"><div class="ttname"><a href="a00899.html#a69a79fd116c6ab783e40139220fad08b">lutok::api_error::api_function</a></div><div class="ttdeci">const std::string &amp; api_function(void) const</div><div class="ttdoc">Gets the name of the Lua API function that caused this error.</div><div class="ttdef"><b>Definition:</b> exceptions.cpp:96</div></div>
146</div><!-- fragment -->
147<p>Checks that a given expression raises a particular <a class="el" href="a00899.html" title="Exception for errors raised by the Lua API library.">lutok::api_error</a>. </p>
148<p>We cannot make any assumptions regarding the error text provided by Lua, so we resort to checking only which API function raised the error (because our code is the one hardcoding these strings).</p>
149<dl class="params"><dt>Parameters</dt><dd>
150  <table class="params">
151    <tr><td class="paramname">exp_api_function</td><td>The name of the Lua C API function that causes the error. </td></tr>
152    <tr><td class="paramname">statement</td><td>The statement to execute. </td></tr>
153  </table>
154  </dd>
155</dl>
156
157</div>
158</div>
159</div><!-- contents -->
160<!-- start footer part -->
161<hr class="footer"/><address class="footer"><small>
162Generated by&#160;<a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.6
163</small></address>
164</body>
165</html>
166