Gethos

Example Code

: : :
 

'C' Unit Testing Framework

An Example Test Suite

trivsuite.c

/* CUnitTester http://www.gethos.net/opensource/cunit
 * trivsuite.c -- an example test suite
 *
 * Copyright 2003 by Stewart Gebbie
 * For license terms, see the file COPYING in the top directory.
 */
/* $Id: cunit_examplecode.php,v 1.4 2004/04/09 13:58:53 gethos Exp $ */
#include "config.h"
#include "unittester.h"

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

/* an example test suite */

static int ATest (utest_info* info)
{
    UTEST_PASS;
}

static int BTest (utest_info* info)
{
    UTEST_ASSERT (false, "This is a Bad Test");

    UTEST_PASS;
}

static int CTest (utest_info* info)
{
    UTEST_FAIL ("This test is doomed to fail");

    UTEST_PASS;
}


/* suite description */
static utest_suite theSuite = {
    "Example::Dummy",   /* suite name   */
    NULL,           /* suite initialiser    */
    NULL,           /* suite finaliser      */
    NULL,           /* test setup           */
    NULL,           /* test teardown        */
    {
        {"Good Test", &ATest},  /* test name and test function */
        {"Bad Test", &BTest},   /* test name and test function */
        {"Fail Test", &CTest},  /* test name and test function */
        { "null", NULL}         /* a null function marks the list end */
    }
};

UTEST_REGISTER(theSuite);

 
: : :