Update documentation and quick fix to test.h
This commit is contained in:
1 parent
656c0e3b3a
commit
05883903c9
6 files changed
+78
-8
No files matched your search
@@ -176,7 +176,9 @@
|
||||
</ul>
|
||||
<p>Inside a test you can use the assertions from <code>assert.h</code> to automatically pass or fail a test.</p>
|
||||
<h2><a class="header" href="#cmc_test_abort" id="cmc_test_abort">CMC_TEST_ABORT</a></h2>
|
||||
<p>Aborts a unit test. This will jump to a <code>goto</code> located at the end of the Unit Test.</p>
|
||||
<p>Aborts a unit test. This will jump to a <code>goto</code> located at the end of the Unit Test. Must be called inside a <code>CMC_CREATE_TEST</code>.</p>
|
||||
<pre><code class="language-c">#define CMC_TEST_ABORT()
|
||||
</code></pre>
|
||||
<h2><a class="header" href="#cmc_test_info" id="cmc_test_info">cmc_test_info</a></h2>
|
||||
<p>Contains information about a Unit Test. Used internally.</p>
|
||||
<pre><code class="language-c">struct cmc_test_info
|
||||
@@ -184,10 +186,21 @@
|
||||
uintmax_t total;
|
||||
uintmax_t passed;
|
||||
uintmax_t failed;
|
||||
uintmax_t assert_total;
|
||||
uintmax_t assert_failed;
|
||||
bool aborted;
|
||||
bool verbose;
|
||||
};
|
||||
</code></pre>
|
||||
<ul>
|
||||
<li><code>uintmax_t total</code> - Total tests in the unit test</li>
|
||||
<li><code>uintmax_t passed</code> - Total tests passed in the unit test</li>
|
||||
<li><code>uintmax_t failed</code> - Total tests failed in the unit test</li>
|
||||
<li><code>uintmax_t assert_total</code> - Total assertions in the unit test</li>
|
||||
<li><code>uintmax_t assert_failed</code> - Total assertions failed in the unit test</li>
|
||||
<li><code>bool aborted</code> - If the unit test was aborted</li>
|
||||
<li><code>bool verbose</code> - Information about each test is displayed</li>
|
||||
</ul>
|
||||
<h2><a class="header" href="#cmc_test_color" id="cmc_test_color">CMC_TEST_COLOR</a></h2>
|
||||
<p>Define this macro if you wish to have color output from the messages printed by each test. Note that a Unit Test need to have <code>VERBOSE</code> equal to <code>true</code>.</p>
|
||||
<h2><a class="header" href="#example" id="example">Example</a></h2>
|
||||
@@ -213,6 +226,16 @@ CMC_CREATE_UNIT(check_math, true, {
|
||||
if (strcmp("2 + 2", "fish") != 0)
|
||||
cmc_assert_state = false;
|
||||
});
|
||||
|
||||
CMC_CREATE_TEST(abort!, {
|
||||
if (4 % 2 == 0)
|
||||
CMC_TEST_ABORT();
|
||||
});
|
||||
|
||||
CMC_CREATE_TEST(sad..., {
|
||||
// This test won't be called because unit test was aborted above
|
||||
cmc_assert(true);
|
||||
});
|
||||
});
|
||||
|
||||
int main(void)
|
||||
|
||||
Reference in new issue
Block a user