Data Structures | Defines | Functions

shortcut.h File Reference

This graph shows which files directly or indirectly include this file:

Data Structures

struct  TestCase

Defines

#define TEST(testname)   void testname(struct TestCase *tc)
#define ASSERT_TRUE(condition, msg)   assert_true(condition, tc, msg)
#define ASSERT_FALSE(condition, msg)   assert_false(condition, tc, msg)
#define ASSERT_EQUALS(expected, actual)   assert_equals(expected, actual, tc, "")
#define ADD_TEST(testfunction)   add_test(testfunction, #testfunction)

Functions

const char * version ()
void assert_true (bool bool_expr, struct TestCase *tc, const char *msg)
void assert_false (bool bool_expr, struct TestCase *tc, const char *msg)
void assert_equals (const char *expected, char *actual, struct TestCase *tc, const char *msg)
void assert_equals (int expected, int actual, struct TestCase *tc, const char *msg)
int get_test_count ()
bool add_test (void(*test_function)(struct TestCase *tc), const char *test_case_name)
void run_tests ()

Define Documentation

#define ADD_TEST (   testfunction  )     add_test(testfunction, #testfunction)
#define ASSERT_EQUALS (   expected,
  actual 
)    assert_equals(expected, actual, tc, "")
#define ASSERT_FALSE (   condition,
  msg 
)    assert_false(condition, tc, msg)
#define ASSERT_TRUE (   condition,
  msg 
)    assert_true(condition, tc, msg)
#define TEST (   testname  )     void testname(struct TestCase *tc)

Function Documentation

bool add_test ( void(*)(struct TestCase *tc)  test_function,
const char *  test_case_name 
)

add_test creates a new test case and adds the a test function to this test case.

Parameters:
test_function Pointer to the test function to be added to the newly created test case.
test_case_name Name which should be assigned to the newly created test case.
void assert_equals ( int  expected,
int  actual,
struct TestCase tc,
const char *  msg 
)

Here is the call graph for this function:

void assert_equals ( const char *  expected,
char *  actual,
struct TestCase tc,
const char *  msg 
)

assert_equals checks whether two values are equal. Currently the following data formats are supported:

  • strings
  • integer
    Parameters:
    expected The expected string value
    actual The actual string value
    tc Pointer to the test case which states this assertion.
    msg Message to be printed if assertion evaluates to false.
    See also:
    assert
void assert_false ( bool  bool_expr,
struct TestCase tc,
const char *  msg 
)

assert_false does the same as assert() but the boolean expression has to evaluate to false. If it evaluates to true the assertion fails.

See also:
assert

Here is the call graph for this function:

void assert_true ( bool  bool_expr,
struct TestCase tc,
const char *  msg 
)

assert_true checks, whether a boolean expression passed is true or false. in case it is false the test case stating the assertion is marked as failed and msg is printed.

Parameters:
bool_expr Expression which is evaluated.
tc Pointer to the test case which states this assertion.
msg Message to be printed if assertion evaluates to false.
int get_test_count (  ) 
Returns:
The total number of test cases added to the test.
void run_tests (  ) 

Here is the call graph for this function:

const char* version (  ) 
Returns:
Version of shortcut as string
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines