glib-testing.html
来自「最新gtk中文资料集」· HTML 代码 · 共 1,300 行 · 第 1/4 页
HTML
1,300 行
<div class="refsect2" lang="en"><a name="id3218082"></a><h3><a name="g-test-verbose"></a>g_test_verbose()</h3><a class="indexterm" name="id3218095"></a><pre class="programlisting">#define g_test_verbose()</pre><p></p></div><hr><div class="refsect2" lang="en"><a name="id3218111"></a><h3><a name="g-test-quiet"></a>g_test_quiet()</h3><a class="indexterm" name="id3218123"></a><pre class="programlisting">#define g_test_quiet()</pre><p></p></div><hr><div class="refsect2" lang="en"><a name="id3218138"></a><h3><a name="g-test-run"></a>g_test_run ()</h3><a class="indexterm" name="id3218153"></a><pre class="programlisting">int g_test_run (void);</pre><p>Runs all tests under the toplevel suite which can be retrievedwith <code class="function">g_test_get_root()</code>. Similar to <code class="function">g_test_run_suite()</code>, the testcases to be run are filtered according totest path arguments (-p <em class="replaceable"><code>testpath</code></em>) as parsed by <a class="link" href="glib-Testing.html#g-test-init"><code class="function">g_test_init()</code></a>.<code class="function">g_test_run_suite()</code> or <a class="link" href="glib-Testing.html#g-test-run"><code class="function">g_test_run()</code></a> may only be called oncein a program.</p><p></p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td><td> 0 on success</td></tr></tbody></table></div><p class="since">Since 2.16</p></div><hr><div class="refsect2" lang="en"><a name="id3218262"></a><h3><a name="g-test-add-func"></a>g_test_add_func ()</h3><a class="indexterm" name="id3218277"></a><pre class="programlisting">void g_test_add_func (const char *testpath, void (test_funcvoid) ());</pre><p>Create a new test case, similar to <code class="function">g_test_create_case()</code>. Howeverthe test is assumed to use no fixture, and test suites are automaticallycreated on the fly and added to the root fixture, based on theslash seperated portions of <em class="parameter"><code>testpath</code></em>.</p><p></p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><p><span class="term"><em class="parameter"><code>testpath</code></em> :</span></p></td><td> Slash seperated test case path name for the test.</td></tr><tr><td><p><span class="term"><em class="parameter"><code>test_func</code></em> :</span></p></td><td> The test function to invoke for this test.</td></tr></tbody></table></div><p class="since">Since 2.16</p></div><hr><div class="refsect2" lang="en"><a name="id3218379"></a><h3><a name="g-test-add-data-func"></a>g_test_add_data_func ()</h3><a class="indexterm" name="id3218394"></a><pre class="programlisting">void g_test_add_data_func (const char *testpath, <a class="link" href="glib-Basic-Types.html#gconstpointer">gconstpointer</a> test_data, void (test_funcgconstpointer) ());</pre><p>Create a new test case, similar to <code class="function">g_test_create_case()</code>. Howeverthe test is assumed to use no fixture, and test suites are automaticallycreated on the fly and added to the root fixture, based on theslash seperated portions of <em class="parameter"><code>testpath</code></em>. The <em class="parameter"><code>test_data</code></em> argumentwill be passed as first argument to <em class="parameter"><code>test_func</code></em>.</p><p></p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><p><span class="term"><em class="parameter"><code>testpath</code></em> :</span></p></td><td> Slash separated test case path name for the test.</td></tr><tr><td><p><span class="term"><em class="parameter"><code>test_data</code></em> :</span></p></td><td> Test data argument for the test function.</td></tr><tr><td><p><span class="term"><em class="parameter"><code>test_func</code></em> :</span></p></td><td> The test function to invoke for this test.</td></tr></tbody></table></div><p class="since">Since 2.16</p></div><hr><div class="refsect2" lang="en"><a name="id3218530"></a><h3><a name="g-test-add"></a>g_test_add()</h3><a class="indexterm" name="id3218545"></a><pre class="programlisting">#define g_test_add(testpath, Fixture, tdata, fsetup, ftest, fteardown)</pre><p>Hook up a new test case at <em class="parameter"><code>testpath</code></em>, similar to <a class="link" href="glib-Testing.html#g-test-add-func"><code class="function">g_test_add_func()</code></a>.A fixture data structure with setup and teardown function may be providedthough, simmilar to <code class="function">g_test_create_case()</code>.<a class="link" href="glib-Testing.html#g-test-add"><code class="function">g_test_add()</code></a> is implemented as a macro, so that the <code class="function">fsetup()</code>, <code class="function">ftest()</code> and<code class="function">fteardown()</code> callbacks can expect a <em class="parameter"><code>Fixture</code></em> pointer as first argument ina type safe manner.</p><p></p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><p><span class="term"><em class="parameter"><code>testpath</code></em> :</span></p></td><td> The test path for a new test case.</td></tr><tr><td><p><span class="term"><em class="parameter"><code>Fixture</code></em> :</span></p></td><td> The type of a fixture data structure.</td></tr><tr><td><p><span class="term"><em class="parameter"><code>tdata</code></em> :</span></p></td><td> Data argument for the test functions.</td></tr><tr><td><p><span class="term"><em class="parameter"><code>fsetup</code></em> :</span></p></td><td> The function to set up the fixture data.</td></tr><tr><td><p><span class="term"><em class="parameter"><code>ftest</code></em> :</span></p></td><td> The actual test function.</td></tr><tr><td><p><span class="term"><em class="parameter"><code>fteardown</code></em> :</span></p></td><td> The function to tear down the fixture data.</td></tr></tbody></table></div><p class="since">Since 2.16</p></div><hr><div class="refsect2" lang="en"><a name="id3218742"></a><h3><a name="g-test-message"></a>g_test_message ()</h3><a class="indexterm" name="id3218757"></a><pre class="programlisting">void g_test_message (const char *format, ...);</pre><p>Add a message to the test report.</p><p></p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><p><span class="term"><em class="parameter"><code>format</code></em> :</span></p></td><td> the format string</td></tr><tr><td><p><span class="term"><em class="parameter"><code>...</code></em> :</span></p></td><td> printf-like arguments to <em class="parameter"><code>format</code></em></td></tr></tbody></table></div><p class="since">Since 2.16</p></div><hr><div class="refsect2" lang="en"><a name="id3218835"></a><h3><a name="g-test-bug-base"></a>g_test_bug_base ()</h3><a class="indexterm" name="id3218850"></a><pre class="programlisting">void g_test_bug_base (const char *uri_pattern);</pre><p>Specify the base URI for bug reports.The base URI is used to construct bug report messages for<a class="link" href="glib-Testing.html#g-test-message"><code class="function">g_test_message()</code></a> when <a class="link" href="glib-Testing.html#g-test-bug"><code class="function">g_test_bug()</code></a> is called.Calling this function outside of a test case sets thedefault base URI for all test cases. Calling it from withina test case changes the base URI for the scope of the testcase only.Bug URIs are constructed by appending a bug specific URIportion to <em class="parameter"><code>uri_pattern</code></em>, or by replacing the special string'<code class="literal">s</code>' within <em class="parameter"><code>uri_pattern</code></em> if that is present.</p><p></p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><p><span class="term"><em class="parameter"><code>uri_pattern</code></em> :</span></p></td><td> the base pattern for bug URIs</td></tr></tbody></table></div><p class="since">Since 2.16</p></div><hr><div class="refsect2" lang="en"><a name="id3218958"></a><h3><a name="g-test-bug"></a>g_test_bug ()</h3><a class="indexterm" name="id3218973"></a><pre class="programlisting">void g_test_bug (const char *bug_uri_snippet);</pre><p>This function adds a message to test reports thatassociates a bug URI with a test case.Bug URIs are constructed from a base URI set with <a class="link" href="glib-Testing.html#g-test-bug-base"><code class="function">g_test_bug_base()</code></a>and <em class="parameter"><code>bug_uri_snippet</code></em>.</p><p></p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><p><span class="term"><em class="parameter"><code>bug_uri_snippet</code></em> :</span></p></td><td> Bug specific bug tracker URI portion.</td></tr></tbody></table></div><p class="since">Since 2.16</p></div><hr><div class="refsect2" lang="en"><a name="id3219050"></a><h3><a name="g-test-timer-start"></a>g_test_timer_start ()</h3><a class="indexterm" name="id3219065"></a><pre class="programlisting">void g_test_timer_start (void);</pre><p>Start a timing test. Call <a class="link" href="glib-Testing.html#g-test-timer-elapsed"><code class="function">g_test_timer_elapsed()</code></a> when the task is supposedto be done. Call this function again to restart the timer.</p><p></p><p class="since">Since 2.16</p></div><hr><div class="refsect2" lang="en"><a name="id3219109"></a><h3><a name="g-test-timer-elapsed"></a>g_test_timer_elapsed ()</h3><a class="indexterm" name="id3219125"></a><pre class="programlisting">double g_test_timer_elapsed (void);</pre><p>Get the time since the last start of the timer with <a class="link" href="glib-Testing.html#g-test-timer-start"><code class="function">g_test_timer_start()</code></a>.</p><p></p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td><td> the time since the last start of the timer, as a double</td></tr></tbody></table></div><p class="since">Since 2.16</p></div><hr><div class="refsect2" lang="en"><a name="id3219184"></a><h3><a name="g-test-timer-last"></a>g_test_timer_last ()</h3><a class="indexterm" name="id3219199"></a><pre class="programlisting">double g_test_timer_last (void);</pre><p>Report the last result of <a class="link" href="glib-Testing.html#g-test-timer-elapsed"><code class="function">g_test_timer_elapsed()</code></a>.</p><p></p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td><td> the last result of <a class="link" href="glib-Testing.html#g-test-timer-elapsed"><code class="function">g_test_timer_elapsed()</code></a>, as a double</td></tr></tbody></table></div><p class="since">Since 2.16</p></div><hr><div class="refsect2" lang="en"><a name="id3219268"></a><h3><a name="g-test-queue-free"></a>g_test_queue_free ()</h3><a class="indexterm" name="id3219284"></a><pre class="programlisting">void g_test_queue_free (<a class="link" href="glib-Basic-Types.html#gpointer">gpointer</a> gfree_pointer);</pre><p>Enqueue a pointer to be released with <a class="link" href="glib-Memory-Allocation.html#g-free"><code class="function">g_free()</code></a> during the nextteardown phase. This is equivalent to calling <a class="link" href="glib-Testing.html#g-test-queue-destroy"><code class="function">g_test_queue_destroy()</code></a>with a destroy callback of <a class="link" href="glib-Memory-Allocation.html#g-free"><code class="function">g_free()</code></a>.</p><p></p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?