Commit e48c7ab2 authored by tlh2000's avatar tlh2000

* moved website out of trunk


git-svn-id: http://svn.code.sf.net/p/cunit/code/trunk@122 f00e6729-6848-4c17-8bfb-678c97c00071
parent b8774a7a
A:link {
color: blue;
}
A:active {
color: blue;
font-weight: bold;
}
A:visited {
color: blue;
}
BODY {
color: black;
font-family: Arial, Helvetica, sans-serif;
margin-right: 20px;
margin-left: 20px;
background-color: #D3D3D3;
}
CITE {
color: maroon;
font-family: "Times New Roman", Times, serif;
font-style: normal;
font-weight: normal;
font-size: 105%;
}
P.indent2 {
margin-left: +2%;
}
P.indent5 {
margin-left: +5%;
}
P.indent10 {
margin-left: +10%;
}
B.cite {
color: maroon;
}
PRE.indent2 {
margin-left: +2%;
}
PRE.indent5 {
margin-left: +5%;
}
PRE.indent10 {
margin-left: +10%;
}
.copyright {
font-size: 70%;
font-style: italic;
}
CODE.preprocessor {
color: maroon;
}
CODE.keyword {
color: blue;
font-weight: normal;
}
CODE.comment {
color: green;
}
This directory contains the version 2 CUnit website pages.
The ./images subfolder contains gif screenshot images
referred to in the screenshot pages. The web pages and
images are all committed to the CUnit cvs on SourceForge.
NOTE:
The page 'documentation.html' links to html versions of
both the CUnit docs (distributed with CUnit) and the
doxygen-generated programmers reference. It expects to
find the starting pages of these 2 documents at the
following locations:
./doc/index.html Start page of standard docs
./doxdocs/index.html Start page of doxygen docs
These documentation files are NOT archived in the CUnit
cvs on SourceForge. To publish the website, the following
steps need to be taken to provide valid links to these
documents:
1. In these steps 'DIST' refers to the top directory of
the CUnit distribution tree. 'WEB' refers to the top
directory in the website tree.
2. Copy SOURCE/doc/*.html and SOURCE/doc/*.css to WEB/doc.
3. Copy SOURCE/CUnit/Headers/*.h to WEB/doc/headers.
4. Generate the doxygen docs for the CUnit source using
the doxygen configuration file SOURCE/Doxyfile. The
doxygen docs will be generated in SOURCE/doc/html.
5. Copy SOURCE/doc/html/*.* to WEB/doxdocs.
JDS
4-May-2005
#include "CUnit/Basic.h"
#include "CUnit/Console.h"
#include "CUnit/Automated.h"
int init_suite_success(void) { return 0; }
int init_suite_failure(void) { return -1; }
int clean_suite_success(void) { return 0; }
int clean_suite_failure(void) { return -1; }
void test_success1(void)
{
CU_ASSERT(TRUE);
}
void test_success2(void)
{
CU_ASSERT_NOT_EQUAL(2, -1);
}
void test_success3(void)
{
CU_ASSERT_STRING_EQUAL("string #1", "string #1");
}
void test_success4(void)
{
CU_ASSERT_STRING_NOT_EQUAL("string #1", "string #2");
}
void test_failure1(void)
{
CU_ASSERT(FALSE);
}
void test_failure2(void)
{
CU_ASSERT_EQUAL(2, 3);
}
void test_failure3(void)
{
CU_ASSERT_STRING_NOT_EQUAL("string #1", "string #1");
}
void test_failure4(void)
{
CU_ASSERT_STRING_EQUAL("string #1", "string #2");
}
int main()
{
CU_pSuite pSuite = NULL;
/* initialize the CUnit test registry */
if (CUE_SUCCESS != CU_initialize_registry())
return CU_get_error();
/* add a suite to the registry */
pSuite = CU_add_suite("Suite_success", init_suite_success, clean_suite_success);
if (NULL == pSuite) {
CU_cleanup_registry();
return CU_get_error();
}
/* add the tests to the suite */
if ((NULL == CU_add_test(pSuite, "successful_test_1", test_success1)) ||
(NULL == CU_add_test(pSuite, "successful_test_2", test_success2)) ||
(NULL == CU_add_test(pSuite, "successful_test_3", test_success3)))
{
CU_cleanup_registry();
return CU_get_error();
}
/* add a suite to the registry */
pSuite = CU_add_suite("Suite_init_failure", init_suite_failure, NULL);
if (NULL == pSuite) {
CU_cleanup_registry();
return CU_get_error();
}
/* add the tests to the suite */
if ((NULL == CU_add_test(pSuite, "successful_test_1", test_success1)) ||
(NULL == CU_add_test(pSuite, "successful_test_2", test_success2)) ||
(NULL == CU_add_test(pSuite, "successful_test_3", test_success3)))
{
CU_cleanup_registry();
return CU_get_error();
}
/* add a suite to the registry */
pSuite = CU_add_suite("Suite_clean_failure", NULL, clean_suite_failure);
if (NULL == pSuite) {
CU_cleanup_registry();
return CU_get_error();
}
/* add the tests to the suite */
if ((NULL == CU_add_test(pSuite, "successful_test_4", test_success1)) ||
(NULL == CU_add_test(pSuite, "failed_test_2", test_failure2)) ||
(NULL == CU_add_test(pSuite, "successful_test_1", test_success1)))
{
CU_cleanup_registry();
return CU_get_error();
}
/* add a suite to the registry */
pSuite = CU_add_suite("Suite_mixed", NULL, NULL);
if (NULL == pSuite) {
CU_cleanup_registry();
return CU_get_error();
}
/* add the tests to the suite */
if ((NULL == CU_add_test(pSuite, "successful_test_2", test_success2)) ||
(NULL == CU_add_test(pSuite, "failed_test_4", test_failure4)) ||
(NULL == CU_add_test(pSuite, "failed_test_2", test_failure2)) ||
(NULL == CU_add_test(pSuite, "successful_test_4", test_success4)))
{
CU_cleanup_registry();
return CU_get_error();
}
/* Run all tests using the basic interface */
/*
CU_basic_set_mode(CU_BRM_VERBOSE);
CU_basic_run_tests();
printf("\n");
CU_basic_show_failures(CU_get_failure_list());
printf("\n\n");
*/
/* Run all tests using the console interface */
CU_console_run_tests();
/* Run all tests using the automated interface */
CU_automated_run_tests();
CU_list_tests_to_file();
CU_cleanup_registry();
return CU_get_error();
}
<!DOCTYPE html PUBLIC "-//W3C//DTD html 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>CUnit Contact</title>
<link rel="StyleSheet" href="CUnit_web.css" type="text/css">
</head>
<body>
<table border="0" width="732" cellspacing="0" cellpadding="0">
<tr>
<td width="131" style="border-bottom: thin maroon solid">&nbsp;</td>
<td width="593" style="border-bottom: thin maroon solid">
<H1 align="CENTER">CUnit</H1>
<H3 align="CENTER">A Unit Testing Framework for C</H3>
</td>
</tr>
<tr>
<td width="131" valign="top" style=" border-right: thin maroon solid">
<table border="0" width="100%" cellspacing="5" cellpadding="0">
<tr>
<td>&nbsp;</td>
</tr>
<tr>
<td><a href="index.html">Overview</a></td>
</tr>
<tr>
<td><a href="documentation.html">Documentation</a></td>
</tr>
<tr>
<td><a href="screenshots.html">Screenshots</a></td>
</tr>
<tr>
<td>Contacts</td>
</tr>
<tr>
<td><a href="example.html">Example Code</a></td>
</tr>
<tr>
<td>&nbsp;</td>
</tr>
<tr>
<td><a href="http://sourceforge.net/projects/cunit/">Project Home</a></td>
</tr>
<tr>
<td valign="bottom" height="100"><a href="http://sourceforge.net">
<img SRC="http://sourceforge.net/sflogo.php?group_id=32992&amp;type=2"
width="125" height="37" border="0" alt="SourceForge.net Logo"></a></td>
</tr>
<tr>
<td valign="bottom" height="75"><a href="http://validator.w3.org/check?uri=referer">
<img border="0" src="http://www.w3.org/Icons/valid-html401"
alt="Valid html 4.01!" height="31" width="88"></a>
</td>
</tr>
</table>
</td>
<td width="593" height="21" valign="top">
<table width="100%" cellspacing="25">
<tr>
<td><i><b>Please contact us with any suggestions, bugs, patches, comments, etc.:</b></i><br /><br />
<table border="0" width="100%" cellspacing="0" cellpadding="10">
<tr valign="top">
<td>Project home page:</td>
<td><a href="http://sourceforge.net/projects/cunit/">http://sourceforge.net/projects/cunit/</a></td>
</tr>
<tr valign="top">
<td>Bug Reports:</td>
<td><a href="http://sourceforge.net/tracker/?atid=407088&amp;group_id=32992&amp;func=browse">http://sourceforge.net/tracker/?atid=407088&amp;group_id=32992&amp;func=browse</a></td>
</tr>
<tr valign="top">
<td>Public forums:</td>
<td><a href="http://sourceforge.net/forum/?group_id=32992">http://sourceforge.net/forum/?group_id=32992</a></td>
</tr>
<tr valign="top">
<td>Project administrator:</td>
<td>
<a href="mailto:anilsaharan@users.sourceforge.net">anilsaharan@users.sourceforge.net</a>
<a href="mailto:cunit-admin@sourceforge.net">cunit-admin@sourceforge.net</a> or<br />
</td>
</tr>
<tr valign="top">
<td>Alternate contact:</td>
<td><a href="mailto:jds2@users.sourceforge.net">jds2@users.sourceforge.net</a></td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD html 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>CUnit Documentation</title>
<link rel="StyleSheet" href="CUnit_web.css" type="text/css">
</head>
<body>
<table border="0" width="732" cellspacing="0" cellpadding="0">
<tr>
<td width="131" style="border-bottom: thin maroon solid">&nbsp;</td>
<td width="593" style="border-bottom: thin maroon solid">
<H1 align="CENTER">CUnit</H1>
<H3 align="CENTER">A Unit Testing Framework for C</H3>
</td>
</tr>
<tr>
<td width="131" valign="top" style=" border-right: thin maroon solid">
<table border="0" width="100%" cellspacing="5" cellpadding="0">
<tr>
<td>&nbsp;</td>
</tr>
<tr>
<td><a href="index.html">Overview</a></td>
</tr>
<tr>
<td>Documentation</td>
</tr>
<tr>
<td><a href="screenshots.html">Screenshots</a></td>
</tr>
<tr>
<td><a href="contact.html">Contacts</a></td>
</tr>
<tr>
<td><a href="example.html">Example Code</a></td>
</tr>
<tr>
<td>&nbsp;</td>
</tr>
<tr>
<td><a href="http://sourceforge.net/projects/cunit/">Project Home</a></td>
</tr>
<tr>
<td valign="bottom" height="100"><a href="http://sourceforge.net">
<img SRC="http://sourceforge.net/sflogo.php?group_id=32992&amp;type=2"
width="125" height="37" border="0" alt="SourceForge.net Logo"></a></td>
</tr>
<tr>
<td valign="bottom" height="75"><a href="http://validator.w3.org/check?uri=referer">
<img border="0" src="http://www.w3.org/Icons/valid-html401"
alt="Valid html 4.01!" height="31" width="88"></a>
</td>
</tr>
</table>
</td>
<td width="593" height="21" valign="top">
<table width="100%" cellspacing="25">
<tr valign="top">
<td><i><b>The following documentation is available for CUnit:</b></i><br /><br />
<table border="0" width="100%" cellspacing="0" cellpadding="10">
<tr valign="top">
<td><a href="doc/index.html">CUnit Users Guide</a></td>
</tr>
<tr valign="top">
<td><a href="doxdocs/index.html">Programmers Reference (doxygen)</a></td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD html 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>CUnit Example</title>
<link rel="StyleSheet" href="CUnit_web.css" type="text/css">
</head>
<body>
<table border="0" width="732" cellspacing="0" cellpadding="0">
<tr>
<td width="131" style="border-bottom: thin maroon solid">&nbsp;</td>
<td width="593" style="border-bottom: thin maroon solid">
<H1 align="CENTER">CUnit</H1>
<H3 align="CENTER">A Unit Testing Framework for C</H3>
</td>
</tr>
<tr>
<td width="131" valign="top" style=" border-right: thin maroon solid">
<table border="0" width="100%" cellspacing="5" cellpadding="0">
<tr>
<td>&nbsp;</td>
</tr>
<tr>
<td><a href="index.html">Overview</a></td>
</tr>
<tr>
<td><a href="documentation.html">Documentation</a></td>
</tr>
<tr>
<td><a href="screenshots.html">Screenshots</a></td>
</tr>
<tr>
<td><a href="contact.html">Contacts</a></td>
</tr>
<tr>
<td>Example Code</td>
</tr>
<tr>
<td>&nbsp;</td>
</tr>
<tr>
<td><a href="http://sourceforge.net/projects/cunit/">Project Home</a></td>
</tr>
<tr>
<td valign="bottom" height="100"><a href="http://sourceforge.net">
<img SRC="http://sourceforge.net/sflogo.php?group_id=32992&amp;type=2"
width="125" height="37" border="0" alt="SourceForge.net Logo"></a></td>
</tr>
<tr>
<td valign="bottom" height="75"><a href="http://validator.w3.org/check?uri=referer">
<img border="0" src="http://www.w3.org/Icons/valid-html401"
alt="Valid html 4.01!" height="31" width="88"></a>
</td>
</tr>
</table>
</td>
<td width="593" height="21" valign="top">
<table width="100%" cellspacing="25">
<tr>
<td>
<pre><code><code class="comment">/*
* Simple example of a CUnit unit test.
*
* This program (crudely) demonstrates a very simple "black box"
* test of the standard library functions fprintf() and fread().
* It uses suite initialization and cleanup functions to open
* and close a common temporary file used by the test functions.
* The test functions then write to and read from the temporary
* file in the course of testing the library functions.
*
* The 2 test functions are added to a single CUnit suite, and
* then run using the CUnit Basic interface. The output of the
* program (on CUnit version 2.0-2) is:
*
* CUnit : A Unit testing framework for C.
* http://cunit.sourceforge.net/
*
* Suite: Suite_1
* Test: test of fprintf() ... passed
* Test: test of fread() ... passed
*
* --Run Summary: Type Total Ran Passed Failed
* suites 1 1 n/a 0
* tests 2 2 2 0
* asserts 5 5 5 0
*/</code>
<code class="preprocessor">
#include &lt;stdio.h&gt;
#include &lt;string.h&gt;
#include "CUnit/Basic.h"</code>
<code class="comment">/* Pointer to the file used by the tests. */</code>
<code class="keyword">static</code> FILE* temp_file = NULL;
<code class="comment">/* The suite initialization function.
* Opens the temporary file used by the tests.
* Returns zero on success, non-zero otherwise.
*/</code>
<code class="keyword">int</code> init_suite1(<code class="keyword">void</code>)
{
<code class="keyword">if</code> (NULL == (temp_file = fopen("temp.txt", "w+"))) {
<code class="keyword">return</code> -1;
}
<code class="keyword">else</code> {
<code class="keyword">return</code> 0;
}
}
<code class="comment">/* The suite cleanup function.
* Closes the temporary file used by the tests.
* Returns zero on success, non-zero otherwise.
*/</code>
<code class="keyword">int</code> clean_suite1(<code class="keyword">void</code>)
{
<code class="keyword">if</code> (0 != fclose(temp_file)) {
<code class="keyword">return</code> -1;
}
<code class="keyword">else</code> {
temp_file = NULL;
<code class="keyword">return</code> 0;
}
}
<code class="comment">/* Simple test of fprintf().
* Writes test data to the temporary file and checks
* whether the expected number of bytes were written.
*/</code>
<code class="keyword">void</code> testFPRINTF(<code class="keyword">void</code>)
{
<code class="keyword">int</code> i1 = 10;
<code class="keyword">if</code> (NULL != temp_file) {
CU_ASSERT(0 == fprintf(temp_file, ""));
CU_ASSERT(2 == fprintf(temp_file, "Q\n"));
CU_ASSERT(7 == fprintf(temp_file, "i1 = %d", i1));
}
}
<code class="comment">/* Simple test of fread().
* Reads the data previously written by testFPRINTF()
* and checks whether the expected characters are present.
* Must be run after testFPRINTF().
*/</code>
<code class="keyword">void</code> testFREAD(<code class="keyword">void</code>)
{
unsigned char buffer[20];
<code class="keyword">if</code> (NULL != temp_file) {
rewind(temp_file);
CU_ASSERT(9 == fread(buffer, sizeof(unsigned char), 20, temp_file));
CU_ASSERT(0 == strncmp(buffer, "Q\ni1 = 10", 9));
}
}
<code class="comment">/* The main() function for setting up and running the tests.
* Returns a CUE_SUCCESS on successful running, another
* CUnit error code on failure.
*/</code>
<code class="keyword">int</code> main()
{
CU_pSuite pSuite = NULL;
<code class="comment">/* initialize the CUnit test registry */</code>
<code class="keyword">if</code> (CUE_SUCCESS != CU_initialize_registry())
<code class="keyword">return</code> CU_get_error();
<code class="comment">/* add a suite to the registry */</code>
pSuite = CU_add_suite("Suite_1", init_suite1, clean_suite1);
<code class="keyword">if</code> (NULL == pSuite) {
CU_cleanup_registry();
<code class="keyword">return</code> CU_get_error();
}
<code class="comment">/* add the tests to the suite */
/* NOTE - ORDER IS IMPORTANT - MUST TEST fread() AFTER fprintf() */</code>
<code class="keyword">if</code> ((NULL == CU_add_test(pSuite, &quot;test of fprintf()&quot;, testFPRINTF)) ||
(NULL == CU_add_test(pSuite, &quot;test of fread()&quot;, testFREAD)))
{
CU_cleanup_registry();
<code class="keyword">return</code> CU_get_error();
}
<code class="comment">/* Run all tests using the CUnit Basic interface */</code>
CU_basic_set_mode(CU_BRM_VERBOSE);
CU_basic_run_tests();
CU_cleanup_registry();
<code class="keyword">return</code> CU_get_error();
}
</code></pre>
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD html 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>CUnit Home</title>
<link rel="StyleSheet" href="CUnit_web.css" type="text/css">
</head>
<body>
<table border="0" width="732" cellspacing="0" cellpadding="0">
<tr>
<td width="131" style="border-bottom: thin maroon solid">&nbsp;</td>
<td width="593" style="border-bottom: thin maroon solid">
<H1 align="CENTER">CUnit</H1>
<H3 align="CENTER">A Unit Testing Framework for C</H3>
</td>
</tr>
<tr>
<td width="131" valign="top" style=" border-right: thin maroon solid">
<table border="0" width="100%" cellspacing="5" cellpadding="0">
<tr>
<td>&nbsp;</td>
</tr>
<tr>
<td>Overview</td>
</tr>
<tr>
<td><a href="documentation.html">Documentation</a></td>
</tr>
<tr>
<td><a href="screenshots.html">Screenshots</a></td>
</tr>
<tr>
<td><a href="contact.html">Contacts</a></td>
</tr>
<tr>
<td><a href="example.html">Example Code</a></td>
</tr>
<tr>
<td>&nbsp;</td>
</tr>
<tr>
<td><a href="http://sourceforge.net/projects/cunit/">Project Home</a></td>
</tr>
<tr>
<td valign="bottom" height="100"><a href="http://sourceforge.net">
<img SRC="http://sourceforge.net/sflogo.php?group_id=32992&amp;type=2"
width="125" height="37" border="0" alt="SourceForge.net Logo"></a></td>
</tr>
<tr>
<td valign="bottom" height="75"><a href="http://validator.w3.org/check?uri=referer">
<img border="0" src="http://www.w3.org/Icons/valid-html401"
alt="Valid html 4.01!" height="31" width="88"></a>
</td>
</tr>
</table>
</td>
<td width="593" height="21" valign="top">
<table width="100%" cellspacing="25">
<tr>
<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CUnit is a lightweight system for writing,
administering, and running unit tests in C.&nbsp;&nbsp;It provides C