# Cintltst Test Suite Documentation

Copyright (C) 1998-2000, International Business Machines Corporation and others. All Rights Reserved.

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.
"cintltst"
or
"cintltst -all"

### C Test FrameWork

#### Purpose:

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, "demo.c" is included at the end of this document. For more information regarding C test framework, please see the directory \intlwork\source\tools\ctestfw.

#### Writing Test Functions

The format of the test functions is like the following,

    void some_test()

    {

    }

Output from the test is accomplished with three printf-like functions:

    void log_err ( const char *fmt, ... );

    void log_info ( const char *fmt, ... );

    void log_verbose ( const char *fmt, ... );

log_info() simply writes to the console, for informational messages.
log_verbose() 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.
log_error() 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.

#### Building a tree of tests

To use the tests you must link them into a hierarchical structure. The root of the structure will be allocated for you.

    TestNode *root = NULL; /* empty */

    addTest( &root, &some_test, "/test");

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.
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.

#### Running the tests

A subtree may be extracted from another tree of tests for programmatic running of subtests

    TestNode* sub;

    sub = getTest(root, "/mytests");

And a tree of tests may be run simply by:

    runTests( root ); /* or 'sub' */

Similarly, showTests() will list out the tests.
However, it is easier to simply run at the command prompt with the Usage specified below.

#### Globals

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.
ERROR_COUNT contains the number of times log_err was called. runTests resets it to zero before running the tests.
VERBOSITY should be 1 to allow log_verbose() data to be displayed otherwise 0 (default).

### Building

To compile this test suite using MSVC, follow the instructions in icu/source/readme.html#HowToInstall for building the "allC" workspace. This builds the libraries as well as the cintltst executable.

### Executing

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:
"cintltst".

### Usage

    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

    ###

##### /******************** sample ctestfw test ********************
********* Simply link this with libctestfw or ctestfw.dll ****
************************* demo.c *****************************/

    #include "stdlib.h"

    #include "ctest.h"

    #include "stdio.h"

    #include "string.h"

    /**

    * 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 );

    }

ReadMe for IBM's International Classes for Unicode C API