| 1 | <HTML> |
| 2 | <HEAD> |
| 3 | <TITLE>CUnit - Managing Tests & Suites</TITLE> |
| 4 | <LINK REL=StyleSheet HREF="CUnit_doc.css" TYPE="text/css" TITLE="CUnit Basic Style" /> |
| 5 | </HEAD> |
| 6 | <BODY> |
| 7 | <DIV CLASS="NAVHEADER" > |
| 8 | <TABLE SUMMARY="Header navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0"> |
| 9 | <TR> |
| 10 | <TH COLSPAN="3" ALIGN="center"><H3>CUnit Progammers Guide</H3></TH> |
| 11 | </TR> |
| 12 | <TR> |
| 13 | <TD WIDTH="10%" ALIGN="left" VALIGN="bottom"><A HREF="test_registry.html" ACCESSKEY="P" >Prev</A></TD> |
| 14 | <TD WIDTH="80%" ALIGN="center" VALIGN="bottom"><A HREF="index.html" ACCESSKEY="H" >Home</A></TD> |
| 15 | <TD WIDTH="10%" ALIGN="right" VALIGN="bottom"><A HREF="running_tests.html" ACCESSKEY="N" >Next</A></TD> |
| 16 | </TR> |
| 17 | </TABLE> |
| 18 | <HR ALIGN="LEFT" WIDTH="100%"> |
| 19 | |
| 20 | <H2>4. Managing Tests & Suites</H2> |
| 21 | |
| 22 | In order for a test to be run by CUnit, it must be added to a test |
| 23 | collection (suite) which is registered with the |
| 24 | <A HREF="test_registry.html">test registry</A>. |
| 25 | |
| 26 | <H3 ID="synopsis">4.1. Synopsis</H3> |
| 27 | #include <<A HREF="headers/TestDB.h">CUnit/TestDB.h</A>> |
| 28 | (included automatically by <<A HREF="headers/CUnit.h">CUnit/CUnit.h</A>>) |
| 29 | <P /> |
| 30 | <PRE> |
| 31 | typedef struct <B CLASS="cite">CU_Suite</B> |
| 32 | typedef CU_Suite* <B CLASS="cite">CU_pSuite</B> |
| 33 | |
| 34 | typedef struct <B CLASS="cite">CU_Test</B> |
| 35 | typedef CU_Test* <B CLASS="cite">CU_pTest</B> |
| 36 | |
| 37 | typedef void (*<B CLASS="cite">CU_TestFunc</B>)(void) |
| 38 | typedef int (*<B CLASS="cite">CU_InitializeFunc</B>)(void) |
| 39 | typedef int (*<B CLASS="cite">CU_CleanupFunc</B>)(void) |
| 40 | |
| 41 | CU_pSuite <A HREF="#addsuite">CU_add_suite</A>(const char* strName, |
| 42 | CU_InitializeFunc pInit, |
| 43 | CU_CleanupFunc pClean); |
| 44 | |
| 45 | CU_pTest <A HREF="#addtest">CU_add_test</A>(CU_pSuite pSuite, |
| 46 | const char* strName, |
| 47 | CU_TestFunc pTestFunc); |
| 48 | |
| 49 | typedef struct <B CLASS="cite">CU_TestInfo</B> |
| 50 | typedef struct <B CLASS="cite">CU_SuiteInfo</B> |
| 51 | |
| 52 | CU_ErrorCode <A HREF="#regsuites">CU_register_suites</A>(CU_SuiteInfo suite_info[]); |
| 53 | CU_ErrorCode <A HREF="#regsuites">CU_register_nsuites</A>(int suite_count, ...); |
| 54 | |
| 55 | CU_ErrorCode <A HREF="#activation">CU_set_suite_active</A>(CU_pSuite pSuite, CU_BOOL fNewActive) |
| 56 | CU_ErrorCode <A HREF="#activation">CU_set_test_active</A>(CU_pTest, CU_BOOL fNewActive) |
| 57 | |
| 58 | CU_ErrorCode <A HREF="#modification">CU_set_suite_name</A>(CU_pSuite pSuite, const char *strNewName) |
| 59 | CU_ErrorCode <A HREF="#modification">CU_set_suite_initfunc</A>(CU_pSuite pSuite, CU_InitializeFunc pNewInit) |
| 60 | CU_ErrorCode <A HREF="#modification">CU_set_suite_cleanupfunc</A>(CU_pSuite pSuite, CU_CleanupFunc pNewClean) |
| 61 | |
| 62 | CU_ErrorCode <A HREF="#modification">CU_set_test_name</A>(CU_pTest pTest, const char *strNewName) |
| 63 | CU_ErrorCode <A HREF="#modification">CU_set_test_func</A>(CU_pTest pTest, CU_TestFunc pNewFunc) |
| 64 | |
| 65 | CU_pSuite <A HREF="#lookup">CU_get_suite</A>(const char* strName) |
| 66 | CU_pSuite <A HREF="#lookup">CU_get_suite_at_pos</A>(unsigned int pos) |
| 67 | unsigned int <A HREF="#lookup">CU_get_suite_pos</A>(CU_pSuite pSuite) |
| 68 | unsigned int <A HREF="#lookup">CU_get_suite_pos_by_name</A>(const char* strName) |
| 69 | |
| 70 | CU_pTest <A HREF="#lookup">CU_get_test</A>(CU_pSuite pSuite, const char *strName) |
| 71 | CU_pTest <A HREF="#lookup">CU_get_test_at_pos</A>(CU_pSuite pSuite, unsigned int pos) |
| 72 | unsigned int <A HREF="#lookup">CU_get_test_pos</A>(CU_pSuite pSuite, CU_pTest pTest) |
| 73 | unsigned int <A HREF="#lookup">CU_get_test_pos_by_name</A>(CU_pSuite pSuite, const char *strName) |
| 74 | </PRE> |
| 75 | |
| 76 | <H3 ID="addsuite">4.2. Adding Suites to the Registry</H3> |
| 77 | <P CLASS="indent2"><CITE>CU_pSuite <B>CU_add_suite</B>(const char* strName, CU_InitializeFunc pInit, CU_CleanupFunc pClean)</CITE></P> |
| 78 | <P CLASS="indent5">Creates a new test collection (suite) having |
| 79 | the specified name, initialization function, and cleanup function. |
| 80 | The new suite is registered with (and owned by) the |
| 81 | <A HREF="test_registry.html">test registry</A>, so the registry must be |
| 82 | <A HREF="test_registry.html#init">initialized</A> before adding any suites. |
| 83 | The current implementation does not support the creation of suites |
| 84 | independent of the test registry. This function may not be called |
| 85 | during a test run (i.e. from a test function or suite |
| 86 | initialization/cleanup function). |
| 87 | <BR /><BR /> |
| 88 | It is recommended that the suite's name be unique among all suites in |
| 89 | the registry. This facilitates suite lookup by name, which only finds |
| 90 | the first suite having a given name. The initialization and cleanup |
| 91 | functions are optional, and are passed as pointers to functions to be |
| 92 | called before and after running the tests contained in the suite. This |
| 93 | allows the suite to set up and tear down temporary fixtures to support |
| 94 | running the tests. These functions take no arguments and should return |
| 95 | zero if they are completed successfully (non-zero otherwise). If a |
| 96 | suite does not require one or both of these functions, pass |
| 97 | <CODE>NULL</CODE> to <CITE>CU_add_suite()</CITE>. |
| 98 | <BR /><BR /> |
| 99 | A pointer to the new suite is returned, which is needed for adding |
| 100 | tests to the suite. The pointer will be <CODE>NULL</CODE> if a fatal |
| 101 | error occurs. In addition, the framework |
| 102 | <A HREF="error_handling.html">error code</A> is set to one |
| 103 | of the following: |
| 104 | </P> |
| 105 | <P CLASS="indent10"> |
| 106 | <TABLE CELLPADDING=1> |
| 107 | <TR> |
| 108 | <TD><CITE>CUE_SUCCESS</CITE></TD> |
| 109 | <TD>suite creation was successful.</TD> |
| 110 | </TR> |
| 111 | <TR> |
| 112 | <TD><CITE>CUE_NOREGISTRY</CITE></TD> |
| 113 | <TD>Error: the registry has not been initialized.</TD> |
| 114 | </TR> |
| 115 | <TR> |
| 116 | <TD><CITE>CUE_NO_SUITENAME</CITE></TD> |
| 117 | <TD>Error: strName was <CODE>NULL</CODE>.</TD> |
| 118 | </TR> |
| 119 | <TR> |
| 120 | <TD><CITE>CUE_DUP_SUITE</CITE></TD> |
| 121 | <TD>Warning: the suite's name was not unique.</TD> |
| 122 | </TR> |
| 123 | <TR> |
| 124 | <TD><CITE>CUE_NOMEMORY</CITE></TD> |
| 125 | <TD>Error: memory allocation failed.</TD> |
| 126 | </TR> |
| 127 | </TABLE> |
| 128 | </P> |
| 129 | |
| 130 | <H3 ID="addtest">4.3. Adding Tests to Suites</H3> |
| 131 | <P CLASS="indent2"><CITE>CU_pTest <B>CU_add_test</B>(CU_pSuite pSuite, const char* strName, CU_TestFunc pTestFunc)</CITE></P> |
| 132 | <P CLASS="indent5">Creates a new test having the specified name and |
| 133 | test function, and registers it with the specified suite. The suite |
| 134 | must already have been created using <A HREF="#addsuite">CU_add_suite()</A>. |
| 135 | The current implementation does not support the creation of tests |
| 136 | independent of a registered suite. This function may not be called |
| 137 | during a test run (i.e. from a test function or suite |
| 138 | initialization/cleanup function). |
| 139 | <BR /><BR /> |
| 140 | It is recommended that the test's name be unique among all tests added |
| 141 | to a single suite. This facilitates lookup of the test by name, which |
| 142 | will find only the 1st test having a given name. The test function cannot |
| 143 | be <CODE>NULL</CODE>, and points to a function to be called when the test |
| 144 | is run. Test functions have neither arguments nor return values. |
| 145 | <BR /><BR /> |
| 146 | A pointer to the new test is returned. If a fatal error occurs during |
| 147 | creation of the test, <CODE>NULL</CODE> is returned. In addition. the |
| 148 | framework <A HREF="error_handling.html">error code</A> is set to one of |
| 149 | the following: |
| 150 | </P> |
| 151 | <P CLASS="indent10"> |
| 152 | <TABLE CELLPADDING=1> |
| 153 | <TR> |
| 154 | <TD><CITE>CUE_SUCCESS</CITE></TD> |
| 155 | <TD>suite creation was successful.</TD> |
| 156 | </TR> |
| 157 | <TR> |
| 158 | <TD><CITE>CUE_NOREGISTRY</CITE></TD> |
| 159 | <TD>Error: the registry has not been initialized.</TD> |
| 160 | </TR> |
| 161 | <TR> |
| 162 | <TD><CITE>CUE_NOSUITE</CITE></TD> |
| 163 | <TD>Error: the specified suite was <CODE>NULL</CODE> or invalid.</TD> |
| 164 | </TR> |
| 165 | <TR> |
| 166 | <TD><CITE>CUE_NO_TESTNAME</CITE></TD> |
| 167 | <TD>Error: strName was <CODE>NULL</CODE>.</TD> |
| 168 | </TR> |
| 169 | <TR> |
| 170 | <TD><CITE>CUE_NO_TEST</CITE></TD> |
| 171 | <TD>Error: pTestFunc was <CODE>NULL</CODE> or invalid.</TD> |
| 172 | </TR> |
| 173 | <TR> |
| 174 | <TD><CITE>CUE_DUP_TEST</CITE></TD> |
| 175 | <TD>Warning: the test's name was not unique.</TD> |
| 176 | </TR> |
| 177 | <TR> |
| 178 | <TD><CITE>CUE_NOMEMORY</CITE></TD> |
| 179 | <TD>Error: memory allocation failed.</TD> |
| 180 | </TR> |
| 181 | </TABLE> |
| 182 | </P> |
| 183 | |
| 184 | <H3 ID="shortcuts">4.4. Shortcut Methods for Managing Tests</H3> |
| 185 | <P CLASS="indent2"><CITE>#define <B>CU_ADD_TEST</B>(suite, test) (CU_add_test(suite, #test, (CU_TestFunc)test))</CITE></P> |
| 186 | <P CLASS="indent5">This macro automatically generates a unique test name |
| 187 | based on the test function name, and adds it to the specified suite. The return |
| 188 | value should be checked by the user to verify success.</P> |
| 189 | <P CLASS="indent2" ID="regsuites"> |
| 190 | <CITE>CU_ErrorCode <B>CU_register_suites</B>(CU_SuiteInfo suite_info[])</CITE><BR /> |
| 191 | <CITE>CU_ErrorCode <B>CU_register_nsuites</B>(int suite_count, ...)</CITE> |
| 192 | </P> |
| 193 | <P CLASS="indent5">For large test structures with many tests and suites, |
| 194 | managing test/suite associations and registration is tedious and error-prone. |
| 195 | CUnit provides a special registration system to help manage suites and tests. |
| 196 | Its primary benefit is to centralize the registration of suites and associated |
| 197 | tests, and to minimize the amount of error checking code the user needs to write. |
| 198 | <BR /><BR /> |
| 199 | Test cases are first grouped into arrays of <CITE>CU_TestInfo</CITE> instances |
| 200 | (defined in <<A HREF="headers/TestDB.h">CUnit/TestDB.h</A>>):</P> |
| 201 | <PRE CLASS="indent10"> |
| 202 | CU_TestInfo test_array1[] = { |
| 203 | { "testname1", test_func1 }, |
| 204 | { "testname2", test_func2 }, |
| 205 | { "testname3", test_func3 }, |
| 206 | CU_TEST_INFO_NULL, |
| 207 | }; |
| 208 | </PRE> |
| 209 | <P CLASS="indent5">Each array element contains the (unique) name and test |
| 210 | function for a single test case. The array must end with an element |
| 211 | holding <CODE>NULL</CODE> values, which the macro <CITE>CU_TEST_INFO_NULL</CITE> |
| 212 | conveniently defines. The test cases included in a single |
| 213 | <CITE>CU_TestInfo</CITE> array form the set of tests that will be registered |
| 214 | with a single test suite. |
| 215 | <BR /><BR /> |
| 216 | Suite information is then defined in one or more arrays of |
| 217 | <CITE>CU_SuiteInfo</CITE> instances (defined in |
| 218 | <<A HREF="headers/TestDB.h">CUnit/TestDB.h</A>>):</P> |
| 219 | <PRE CLASS="indent10"> |
| 220 | CU_SuiteInfo suites[] = { |
| 221 | { "suitename1", suite1_init-func, suite1_cleanup_func, test_array1 }, |
| 222 | { "suitename2", suite2_init-func, suite2_cleanup_func, test_array2 }, |
| 223 | CU_SUITE_INFO_NULL, |
| 224 | }; |
| 225 | </PRE> |
| 226 | <P CLASS="indent5">Each of these array elements contain the (unique) name, |
| 227 | suite initialization function, suite cleanup function, and |
| 228 | <CITE>CU_TestInfo</CITE> array for a single suite. As usual, |
| 229 | <CODE>NULL</CODE> may be used for the initialization or cleanup |
| 230 | function if the given suite does not need it. The array must end |
| 231 | with an all-<CODE>NULL</CODE> element, for which the macro |
| 232 | <CITE>CU_SUITE_INFO_NULL</CITE> may be used. |
| 233 | <BR /><BR /> |
| 234 | All suites defined in a <CITE>CU_SuiteInfo</CITE> array can then be |
| 235 | registered in a single statement:</P> |
| 236 | <P CLASS="indent10"> |
| 237 | <CODE>CU_ErrorCode error = CU_register_suites(suites);</CODE> |
| 238 | </P> |
| 239 | <P CLASS="indent5">If an error occurs during the registration of any suite or |
| 240 | test, an error code is returned. The error codes are the same as those returned |
| 241 | by normal <A HREF="#addsuite">suite registration</A> and |
| 242 | <A HREF="#addtest">test addition</A> operations. The function |
| 243 | <CITE>CU_register_nsuites()</CITE> is provided for situations in which |
| 244 | the user wishes to register multiple <CITE>CU_SuiteInfo</CITE> arrays |
| 245 | in a single statement:</P> |
| 246 | <P CLASS="indent10"> |
| 247 | <CODE>CU_ErrorCode error = CU_register_nsuites(2, suites1, suites2);</CODE> |
| 248 | </P> |
| 249 | <P CLASS="indent5"> |
| 250 | This function accepts a variable number of <CITE>CU_SuiteInfo</CITE> arrays. |
| 251 | The first argument indicates the actual number ot arrays being passed. |
| 252 | </P> |
| 253 | |
| 254 | <H3 ID="activation">4.5. Activation of Suites and Tests</H3> |
| 255 | <P CLASS="indent2"> |
| 256 | <CITE>CU_ErrorCode <B>CU_set_suite_active</B>(CU_pSuite pSuite, CU_BOOL fNewActive)</CITE><BR /> |
| 257 | <CITE>CU_ErrorCode <B>CU_set_test_active</B>(CU_pTest pTest, CU_BOOL fNewActive)</CITE> |
| 258 | </P> |
| 259 | <P CLASS="indent5">These functions may be used to deactivate or reactivate |
| 260 | individual tests and suites. A suite or test will not be executed during a |
| 261 | test run unless it is active. All suites and tests are active by default |
| 262 | upon creation. The current active state is available as <I>pSuite->fActive</I> |
| 263 | and <I>pTest->fActive</I>, respectively. The flag will be <CODE>CU_TRUE</CODE> |
| 264 | if active and <CODE>CU_FALSE</CODE> if not. This gives the client the ability to |
| 265 | choose subsets of tests to run dynamically. Note that it is a framework error |
| 266 | to deactivate a test or suite and then specifically request that it be |
| 267 | <A HREF="running_test/html#overview">run</A>. These functions return |
| 268 | <CODE>CUE_SUCCESS</CODE> on success, and <CODE>CUE_NOSUITE</CODE> (or |
| 269 | <CODE>CUE_NOTEST</CODE>) if the corresponding suite (or test) is <CODE>NULL</CODE>. |
| 270 | </P> |
| 271 | |
| 272 | <H3 ID="modification">4.6. Modifying Other Attributes of Suites and Tests</H3> |
| 273 | <P CLASS="indent2">Normally the attributes of suites and tests are set at creation time. |
| 274 | In some cases, a client may wish to manipulate these to modify the test structure |
| 275 | dynamically. The following functions are provided for this purpose, and should |
| 276 | be used instead of directly setting the value of the data structure members. All |
| 277 | return <CODE>CUE_SUCCESS</CODE> on success, and the indicated error code on failure. |
| 278 | <A HREF="#lookup">Lookup functions</A> are provided to assist clients in locating |
| 279 | specific tests and suites. |
| 280 | </P> |
| 281 | <P CLASS="indent2"> |
| 282 | <CITE>CU_ErrorCode <B>CU_set_suite_name</B>(CU_pSuite pSuite, const char *strNewName)</CITE><BR /> |
| 283 | <CITE>CU_ErrorCode <B>CU_set_test_name</B>(CU_pTest pTest, const char *strNewName)</CITE> |
| 284 | </P> |
| 285 | <P CLASS="indent5">These functions change the name of registered suites and tests. |
| 286 | The current names are available as the <I>pSuite->pName</I> and |
| 287 | <I>pTest->pName</I> data structure members. If the suite or test is <CODE>NULL</CODE>, |
| 288 | then <CODE>CUE_NOSUITE</CODE> or <CODE>CUE_NOTEST</CODE> is returned, respectively. If |
| 289 | strNewName is <CODE>NULL</CODE>, then <CODE>CUE_NO_SUITENAME</CODE> or |
| 290 | <CODE>CUE_NO_TESTNAME</CODE> is returned, respectively. |
| 291 | </P> |
| 292 | <P CLASS="indent2"> |
| 293 | <CITE>CU_ErrorCode <B>CU_set_suite_initfunc</B>(CU_pSuite pSuite, CU_InitializeFunc pNewInit)</CITE><BR /> |
| 294 | <CITE>CU_ErrorCode <B>CU_set_suite_cleanupfunc</B>(CU_pSuite pSuite, CU_CleanupFunc pNewClean)</CITE> |
| 295 | </P> |
| 296 | <P CLASS="indent5">These functions change the initialization and cleanup |
| 297 | functions for a registered suite. The current functions are available as the |
| 298 | <I>pSuite->pInitializeFunc</I> and <I>pSuite->pCleanupFunc</I> data structure |
| 299 | members. If the suite is <CODE>NULL</CODE> then <CODE>CUE_NOSUITE</CODE> is |
| 300 | returned. |
| 301 | </P> |
| 302 | <P CLASS="indent2"> |
| 303 | <CITE>CU_ErrorCode <B>CU_set_test_func</B>(CU_pTest pTest, CU_TestFunc pNewFunc)</CITE> |
| 304 | </P> |
| 305 | <P CLASS="indent5">This function changes the test function for a registered test. |
| 306 | The current test function is available as the <I>pTest->pTestFunc</I> data |
| 307 | structure member. If either pTest or pNewFunc is <CODE>NULL</CODE>, then |
| 308 | <CODE>CUE_NOTEST</CODE> is returned. |
| 309 | </P> |
| 310 | |
| 311 | <H3 ID="lookup">4.7. Lookup of Individual Suites and Tests</H3> |
| 312 | <P CLASS="indent2">In most cases, clients will have references to registered |
| 313 | suites and tests as pointers returned from <A HREF="#addsuite">CU_add_suite()</A> |
| 314 | and <A HREF="#addtest">CU_add_test()</A>. Occassionally, a client may need to be |
| 315 | able to retrieve a reference to a suite or test. The following functions are |
| 316 | provided to assist clients with this when the client has some information about |
| 317 | the entity (name or order of registration). In cases where nothing is known about |
| 318 | the suite or test, the client will need to iterate the internal data structures to |
| 319 | enumerate the suites and tests. This is not directly supported in the client API. |
| 320 | </P> |
| 321 | <P CLASS="indent2"> |
| 322 | <CITE>CU_pSuite <B>CU_get_suite</B>(const char* strName)</CITE><BR /> |
| 323 | <CITE>CU_pSuite <B>CU_get_suite_at_pos</B>(unsigned int pos)</CITE><BR /> |
| 324 | <CITE>unsigned int <B>CU_get_suite_pos</B>(CU_pSuite pSuite)</CITE><BR /> |
| 325 | <CITE>unsigned int <B>CU_get_suite_pos_by_name</B>(const char* strName)</CITE> |
| 326 | </P> |
| 327 | <P CLASS="indent5">These functions facilitate lookup of suites registered in the |
| 328 | active <A HREF="test_registry.html">test registry</A>. The first 2 functions allow |
| 329 | lookup of the suite by name or position and return <CODE>NULL</CODE> if the suite cannot |
| 330 | be found. The position is a 1-based index in the range |
| 331 | [1 .. <A HREF="test_registry.html#otherfuncs">CU_get_registry()</A>->uiNumberOfSuites]. |
| 332 | This may be helpful when suites having duplicate names are registered, in which case |
| 333 | lookup by name can only retrieve the 1st suite having that name. The second 2 functions |
| 334 | help the client identify the position of a registered suite. These return 0 if the suite |
| 335 | cannot be found. In addition, all these functions set the CUnit error state to |
| 336 | <CODE>CUE_NOREGISTRY</CODE> if the registry is not <A HREF="test_registry.html#init"> |
| 337 | initialized</A>. As appropriate, <CODE>CUE_NO_SUITENAME</CODE> is set if <CODE>strName</CODE> |
| 338 | is <CODE>NULL</CODE>, and <CODE>CUE_NOSUITE</CODE> is set if <CODE>pSuite</CODE> |
| 339 | is <CODE>NULL</CODE>. |
| 340 | </P> |
| 341 | <P CLASS="indent2"> |
| 342 | <CITE>CU_pTest <B>CU_get_test</B>(CU_pSuite pSuite, const char *strName)</CITE><BR /> |
| 343 | <CITE>CU_pTest <B>CU_get_test_at_pos</B>(CU_pSuite pSuite, unsigned int pos)</CITE><BR /> |
| 344 | <CITE>unsigned int <B>CU_get_test_pos</B>(CU_pSuite pSuite, CU_pTest pTest)</CITE><BR /> |
| 345 | <CITE>unsigned int <B>CU_get_test_pos_by_name</B>(CU_pSuite pSuite, const char *strName)</CITE> |
| 346 | </P> |
| 347 | <P CLASS="indent5">These functions facilitate lookup of tests registered in suites. The first |
| 348 | 2 functions allow lookup of the test by name or position and return <CODE>NULL</CODE> if the |
| 349 | test cannot found. The position is a 1-based index in the range [1 .. pSuite->uiNumberOfSuites]. |
| 350 | This may be helpful when tests having duplicate names are registered, in which case |
| 351 | lookup by name can only retrieve the 1st test having that name. The second 2 functions |
| 352 | help the client identify the position of a test in a suite. These return 0 if the test |
| 353 | cannot be found. In addition, all these functions set the CUnit error state to |
| 354 | <CODE>CUE_NOREGISTRY</CODE> if the registry is not <A HREF="test_registry.html#init"> |
| 355 | initialized</A>, and to <CODE>CUE_NOSUITE</CODE> if <CODE>pSuite</CODE> is <CODE>NULL</CODE>. |
| 356 | As appropriate, <CODE>CUE_NO_TESTNAME</CODE> is set if <CODE>strName</CODE> is |
| 357 | <CODE>NULL</CODE>, and <CODE>CUE_NOTEST</CODE> is set if <CODE>pTest</CODE> is <CODE>NULL</CODE>. |
| 358 | </P> |
| 359 | |
| 360 | <H3 ID="deprecated">4.8. Deprecated v1 Data Types & Functions</H3> |
| 361 | The following data types and functions are deprecated as of version 2. |
| 362 | To use these deprecated names, user code must be compiled with |
| 363 | <CITE>USE_DEPRECATED_CUNIT_NAMES</CITE> defined. |
| 364 | <P /> |
| 365 | <B>#include <<A HREF="headers/TestDB.h">CUnit/TestDB.h</A>></B> |
| 366 | (included automatically by <A HREF="headers/CUnit.h">CUnit/CUnit.h</A>>). |
| 367 | <P /> |
| 368 | <TABLE CELLPADDING=5 BORDER=2> |
| 369 | <TR VALIGN="top"> |
| 370 | <TD><B>Deprecated Name</B></TD> |
| 371 | <TD><B>Equivalent New Name</B></TD> |
| 372 | </TR> |
| 373 | <TR VALIGN="top"> |
| 374 | <TD><CODE>TestFunc</CODE></TD> |
| 375 | <TD><A HREF="#synopsis">CU_TestFunc</A></TD> |
| 376 | </TR> |
| 377 | <TR VALIGN="top"> |
| 378 | <TD><CODE>InitializeFunc</CODE></TD> |
| 379 | <TD><A HREF="#synopsis">CU_InitializeFunc</A></TD> |
| 380 | </TR> |
| 381 | <TR VALIGN="top"> |
| 382 | <TD><CODE>CleanupFunc</CODE></TD> |
| 383 | <TD><A HREF="#synopsis">CU_CleanupFunc</A></TD> |
| 384 | </TR> |
| 385 | <TR VALIGN="top"> |
| 386 | <TD><CODE>_TestCase</CODE></TD> |
| 387 | <TD><A HREF="#synopsis">CU_Test</A></TD> |
| 388 | </TR> |
| 389 | <TR VALIGN="top"> |
| 390 | <TD><CODE>PTestCase</CODE></TD> |
| 391 | <TD><A HREF="#synopsis">CU_pTest</A></TD> |
| 392 | </TR> |
| 393 | <TR VALIGN="top"> |
| 394 | <TD><CODE>_TestGroup</CODE></TD> |
| 395 | <TD><A HREF="#synopsis">CU_Suite</A></TD> |
| 396 | </TR> |
| 397 | <TR VALIGN="top"> |
| 398 | <TD><CODE>PTestGroup</CODE></TD> |
| 399 | <TD><A HREF="#synopsis">CU_pSuite</A></TD> |
| 400 | </TR> |
| 401 | <TR VALIGN="top"> |
| 402 | <TD><CODE>add_test_group()</CODE></TD> |
| 403 | <TD><A HREF="#addsuite">CU_add_suite()</A></TD> |
| 404 | </TR> |
| 405 | <TR VALIGN="top"> |
| 406 | <TD><CODE>add_test_case()</CODE></TD> |
| 407 | <TD><A HREF="#addtest">CU_add_test()</A></TD> |
| 408 | </TR> |
| 409 | <TR VALIGN="top"> |
| 410 | <TD><CODE>ADD_TEST_TO_GROUP()</CODE></TD> |
| 411 | <TD><A HREF="#shortcuts">CU_ADD_TEST()</A></TD> |
| 412 | </TR> |
| 413 | <TR VALIGN="top"> |
| 414 | <TD><CODE>test_case_t</CODE></TD> |
| 415 | <TD><A HREF="#regsuites">CU_TestInfo</A></TD> |
| 416 | </TR> |
| 417 | <TR VALIGN="top"> |
| 418 | <TD><CODE>test_group_t</CODE></TD> |
| 419 | <TD><A HREF="#regsuites">CU_SuiteInfo</A></TD> |
| 420 | </TR> |
| 421 | <TR VALIGN="top"> |
| 422 | <TD><CODE>test_suite_t</CODE></TD> |
| 423 | <TD>no equivalent - use <A HREF="#regsuites">CU_SuiteInfo</A></TD> |
| 424 | </TR> |
| 425 | <TR VALIGN="top"> |
| 426 | <TD><CODE>TEST_CASE_NULL</CODE></TD> |
| 427 | <TD><A HREF="#regsuites">CU_TEST_INFO_NULL</A></TD> |
| 428 | </TR> |
| 429 | <TR VALIGN="top"> |
| 430 | <TD><CODE>TEST_GROUP_NULL</CODE></TD> |
| 431 | <TD><A HREF="#regsuites">CU_SUITE_INFO_NULL</A></TD> |
| 432 | </TR> |
| 433 | <TR VALIGN="top"> |
| 434 | <TD><CODE>test_group_register</CODE></TD> |
| 435 | <TD><A HREF="#regsuites">CU_register_suites()</A></TD> |
| 436 | </TR> |
| 437 | <TR VALIGN="top"> |
| 438 | <TD><CODE>test_suite_register</CODE></TD> |
| 439 | <TD>no equivalent - use <A HREF="#regsuites">CU_register_suites()</A></TD> |
| 440 | </TR> |
| 441 | </TABLE> |
| 442 | |
| 443 | <DIV CLASS="NAVFOOTER"> |
| 444 | <HR ALIGN="LEFT" WIDTH="100%"> |
| 445 | <TABLE SUMMARY="Footer navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0"> |
| 446 | <TR> |
| 447 | <TD WIDTH="33%" ALIGN="left" VALIGN="top"><A HREF="test_registry.html" ACCESSKEY="P">Prev</A></TD> |
| 448 | <TD WIDTH="34%" ALIGN="center" VALIGN="top"><A HREF="index.html" ACCESSKEY="H" >Home</A></TD> |
| 449 | <TD WIDTH="33%" ALIGN="right" VALIGN="top"><A HREF="running_tests.html" ACCESSKEY="N" >Next</A></TD> |
| 450 | </TR> |
| 451 | <TR> |
| 452 | <TD WIDTH="33%" ALIGN="left" VALIGN="top">The Test Registry</TD> |
| 453 | <TD WIDTH="34%" ALIGN="center" VALIGN="top"> </TD> |
| 454 | <TD WIDTH="33%" ALIGN="right" VALIGN="top">Running Tests</TD> |
| 455 | </TR> |
| 456 | </TABLE> |
| 457 | </DIV> |
| 458 | |
| 459 | </BODY> |
| 460 | </HTML> |