ooc 1.3
Object Oriented tollkit fo ANSI C

testcase.h File Reference

TestCase class - base class for unit testing. More...

#include <stdio.h>
#include "exception.h"
Include dependency graph for testcase.h:

Data Structures

struct  TestCaseMethod
 Test method order table. More...
struct  TestCaseVtable
 TestCase virtual functions. More...

Defines

Test method definitions.

Components defining test methods and execution of them.

#define TEST(name)
 A test method order table entry.
TestCase assertions.

These macros can be used in the test methods and in before(), after(), before_class(), after_class() methods.

If the assertion fails, the unit test run will report a fail message indicating the source file name and the line number in the source file. The test run will continue with the next statement.

#define fail()
 Unconditional fail.
#define assertTrue(expr)
 Fail if not TRUE.
#define assertFalse(expr)
 Fail if not FALSE.
#define assertNull(expr)
 Fail if not NULL.
#define assertNotNull(expr)
 Fail if NULL.
#define assertZero(expr)
 Fail if not 0.
#define assertNotZero(expr)
 Fail if 0L.
#define failMsg(msg)
 Unconditional fail with a specific message.
#define assertTrueMsg(expr, msg)
 Fail if not TRUE with a specific message.
#define assertFalseMsg(expr, msg)
 Fail if not FALSE with a specific message.
#define assertNullMsg(expr, msg)
 Fail if not NULL with a specific message.
#define assertNotNullMsg(expr, msg)
 Fail if NULL with a specific message.
#define assertZeroMsg(expr, msg)
 Fail if not 0 with a specific message.
#define assertNotZeroMsg(expr, msg)
 Fail if 0 with a specific message.

Functions

int testcase_run (TestCase)
 Run the TestCase.

Detailed Description

TestCase class - base class for unit testing.

TestCase is a base class for unit testing. All of your Unit tests inherits TestCase. The process to create a new unit test in your project:

  1. Create a new test class with:
     $ ooc --new MyTest --template test 
    
  2. Override the necessary virtual methods
  3. implement your test methods
  4. create the test methods table
  5. compile your test file as executable (you can use the makefile template from ooc/template/unit folder)
  6. run the test file

Define Documentation

#define assertFalse (   expr)

Fail if not FALSE.

Reports a failed status if not FALSE and continues.

#define assertFalseMsg (   expr,
  msg 
)

Fail if not FALSE with a specific message.

Reports a failed status with the message if not FALSE and continues.

Note:
The message must be a char* and will not be freed.
#define assertNotNull (   expr)

Fail if NULL.

Reports a failed status if NULL and continues.

#define assertNotNullMsg (   expr,
  msg 
)

Fail if NULL with a specific message.

Reports a failed status with the message if NULL and continues.

Note:
The message must be a char* and will not be freed.
#define assertNotZero (   expr)

Fail if 0L.

Reports a failed status if 0 and continues.

#define assertNotZeroMsg (   expr,
  msg 
)

Fail if 0 with a specific message.

Reports a failed status with the message if 0 and continues.

Note:
The message must be a char* and will not be freed.
#define assertNull (   expr)

Fail if not NULL.

Reports a failed status if not NULL and continues.

#define assertNullMsg (   expr,
  msg 
)

Fail if not NULL with a specific message.

Reports a failed status with the message if not NULL and continues.

Note:
The message must be a char* and will not be freed.
#define assertTrue (   expr)

Fail if not TRUE.

Reports a failed status if not TRUE and continues.

#define assertTrueMsg (   expr,
  msg 
)

Fail if not TRUE with a specific message.

Reports a failed status with the message if not TRUE and continues.

Note:
The message must be a char* and will not be freed.
#define assertZero (   expr)

Fail if not 0.

Reports a failed status if not 0 and continues.

#define assertZeroMsg (   expr,
  msg 
)

Fail if not 0 with a specific message.

Reports a failed status with the message if not 0 and continues.

Note:
The message must be a char* and will not be freed.
#define fail ( )

Unconditional fail.

Reports a failed status and continues.

#define failMsg (   msg)

Unconditional fail with a specific message.

Reports a failed status with the message and continues.

Note:
The message must be a char* and will not be freed.
#define TEST (   name)

A test method order table entry.

This macro places a test method entry point into the test method order table. The test methods will be executed in the order they apper in the table.

Parameters:
nameThe name of the test method.
See also:
TestCaseMethod
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines