| </<!DOCTYPE> |
| <html> |
| |
| <head> |
| <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> |
| <meta name="GENERATOR" content="Microsoft FrontPage 3.0"> |
| <title>CintlTst Test Suite Doumentation</title> |
| </head> |
| |
| <body bgcolor="#FFFFFF"> |
| |
| <h1>Cintltst Test Suite Documentation</h1> |
| |
| <hr> |
| |
| <p>COPYRIGHT:<br> |
| (C) Copyright Taligent, Inc., 1997<br> |
| (C) Copyright International Business Machines Corporation, 1999<br> |
| Licensed Material - Program-Property of IBM - All Rights Reserved.<br> |
| US Government Users Restricted Rights - Use, duplication, or disclosure<br> |
| restricted by GSA ADP Schedule Contract with IBM Corp.</p> |
| |
| <hr> |
| |
| <p>The cintltst Test Suite contains all the tests for IBM's International Classes for |
| Unicode C API. These tests may be automatically run by typing "cintltst" or |
| "cintltst -all" at the command line. It depends on the C Test Framework. <br> |
| "cintltst"<br> |
| or<br> |
| "cintltst -all"</p> |
| |
| <h3>C Test FrameWork</h3> |
| |
| <h4>Purpose:</h4> |
| |
| <p>To enable the writing of tests entirely in C. The Framework has been designed to make |
| creating tests or converting old ones as simple as possible, with a minimum of framework |
| overhead. A sample test file, <a href="#demo.c">"demo.c"</a> is included at the |
| end of this document. For more information regarding C test framework, please see the |
| directory \intlwork\source\tools\ctestfw.</p> |
| |
| <h4>Writing Test Functions</h4> |
| |
| <p>The format of the test functions is like the following,</p> |
| |
| <pre>void some_test() |
| { |
| }</pre> |
| |
| <p>Output from the test is accomplished with three printf-like functions:</p> |
| |
| <pre>void log_err ( const char *fmt, ... ); |
| void log_info ( const char *fmt, ... ); |
| void log_verbose ( const char *fmt, ... );</pre> |
| |
| <p><strong>log_info() </strong>simply writes to the console, for informational messages.<br> |
| <strong>log_verbose()</strong> writes to the console ONLY if the VEBOSE flag is turned on |
| (or the -v option to the command line). It's useful for debugging. By default, VERBOSE |
| flag is turned OFF.<br> |
| <strong>log_error()</strong> is what should be called when a test failure is detected. The |
| error will be then logged and error count will be incremented by one.<br> |
| </p> |
| |
| <h4>Building a tree of tests</h4> |
| |
| <p>To use the tests you must link them into a hierarchical structure. The root of the |
| structure will be allocated for you.</p> |
| |
| <pre>TestNode *root = NULL; /* empty */ |
| addTest( &root, &some_test, "/test");</pre> |
| |
| <p>The function pointer and an absolute 'path' to the test are supplied. Paths may be up |
| to 127 chars in length and may be used to group tests.<br> |
| <br> |
| The calls to addTest should be placed in a function or a hierarchy of functions (perhaps |
| mirroring the paths), please see the following demo.c example for more details.<br> |
| </p> |
| |
| <h4>Running the tests</h4> |
| |
| <p>A subtree may be extracted from another tree of tests for programmatic running of |
| subtests</p> |
| |
| <pre>TestNode* sub; |
| sub = getTest(root, "/mytests");</pre> |
| |
| <p>And a tree of tests may be run simply by:</p> |
| |
| <pre>runTests( root ); /* or 'sub' */</pre> |
| |
| <p>Similarly, showTests() will list out the tests.<br> |
| <br> |
| However, it is easier to simply run at the command prompt with the Usage specified below.<br> |
| </p> |
| |
| <h4>Globals</h4> |
| |
| <p>The command line parser will manage resetting the error count, and printing a summary |
| of the failed tests. But if you call runTest directly, for instance, you will need to |
| manage these yourself.<br> |
| <strong>ERROR_COUNT</strong> contains the number of times log_err was called. runTests |
| resets it to zero before running the tests.<br> |
| <strong>VERBOSITY</strong> should be 1 to allow log_verbose() data to be displayed |
| otherwise 0 (default).<br> |
| </p> |
| |
| <h3>Building</h3> |
| |
| <p>To compile this test suite using MSVC, follow the instructions in <a |
| href="../readme.html#HowToInstall">icu/source/readme.html#HowToInstall</a> for building |
| the "allC" workspace. This builds the libraries as well as the cintltst |
| executable.</p> |
| |
| <h3>Executing</h3> |
| |
| <p>To run the test suite from the command line, change directories to |
| "icu/source/test/cintltst/Debug" for the debug build, (or |
| "icu/source/test/cintltst/Release" for the releawse build) then type:<br> |
| "cintltst".</p> |
| |
| <h3>Usage</h3> |
| |
| <pre>Type "cintltest -h" to see the usage: |
| |
| ### Syntax: |
| ### Usage: [ -l ] [ -v ] [ -verbose] [-a] [ -all] [-n] \n [ -no_err_msg] [ -h ] [ /path/to/test ] |
| ### -l To get a list of test names |
| ### -all To run all the test |
| ### -a To run all the test(same a -all) |
| ### -verbose To turn ON verbosity |
| ### -v To turn ON verbosity(same as -verbose) |
| ### -h To print this message |
| ### -n To turn OFF printing error messages |
| ### -no_err_msg (same as -n) |
| ### -[/subtest] To run a subtest |
| ### For example to run just the utility tests type: cintltest /tsutil) |
| ### To run just the locale test type: cintltst /tsutil/loctst |
| ### </pre> |
| |
| <p><br> |
| <a name="demo.c"></a></p> |
| |
| <h5><big>/******************** sample ctestfw test ********************<br> |
| ********* Simply link this with libctestfw or ctestfw.dll ****<br> |
| ************************* demo.c *****************************/<br> |
| </big></h5> |
| |
| <pre> |
| </pre> |
| |
| <pre>#include "stdlib.h" |
| #include "ctest.h" |
| #include "stdio.h" |
| #include "string.h" |
| |
| </pre> |
| |
| <pre>/** |
| * Some sample dummy tests. |
| * the statics simply show how often the test is called. |
| */ |
| void mytest() |
| { |
| static i = 0; |
| log_info("I am a test[%d]\n", i++); |
| } |
| |
| void mytest_err() |
| { |
| static i = 0; |
| log_err("I am a test containing an error[%d]\n", i++); |
| log_err("I am a test containing an error[%d]\n", i++); |
| } |
| |
| void mytest_verbose() |
| { |
| /* will only show if verbose is on (-v) */ |
| log_verbose("I am a verbose test, blabbing about nothing at all.\n"); |
| } |
| |
| /** |
| * Add your tests from this function |
| */ |
| |
| void add_tests( TestNode** root ) |
| { |
| addTest(root, &mytest, "/apple/bravo" ); |
| addTest(root, &mytest, "/a/b/c/d/mytest"); |
| addTest(root, &mytest_err, "/d/e/f/h/junk"); |
| addTest(root, &mytest, "/a/b/c/d/another"); |
| addTest(root, &mytest, "/a/b/c/etest"); |
| addTest(root, &mytest_err, "/a/b/c"); |
| addTest(root, &mytest, "/bertrand/andre/damiba"); |
| addTest(root, &mytest_err, "/bertrand/andre/OJSimpson"); |
| addTest(root, &mytest, "/bertrand/andre/juice/oj"); |
| addTest(root, &mytest, "/bertrand/andre/juice/prune"); |
| addTest(root, &mytest_verbose, "/verbose"); |
| |
| } |
| |
| int main(int argc, const char *argv[]) |
| { |
| TestNode *root = NULL; |
| |
| add_tests(&root); /* address of root ptr- will be filled in */ |
| |
| /* Run the tests. An int is returned suitable for the OS status code. |
| (0 for success, neg for parameter errors, positive for the # of |
| failed tests) */ |
| return processArgs( root, argc, argv ); |
| } |
| |
| </pre> |
| |
| <p><a href="../readme.html">ReadMe for </a><a href="../readme.html#API">IBM's |
| International Classes for Unicode C API</a></p> |
| |
| <hr> |
| </body> |
| </html> |