src/test/assert.h
author Tero Marttila <terom@fixme.fi>
Mon, 04 May 2009 20:55:04 +0300
branchnew-transport
changeset 168 a58ad50911fc
child 194 808b1b047620
permissions -rw-r--r--
refactor test.c into tests/*
#ifndef TEST_ASSERT_H
#define TEST_ASSERT_H

/**
 * @file
 *
 * Various general assert-condition tests used to fail tests
 */
#include "../error.h"
#include "../log.h"

/*
 * Also accept the existance of the system assert() function
 */
#include <assert.h>
#include <stdbool.h>

/**
 * Assert that the given condition is true, and fail with the given error if not
 */
void assert_true (bool cond, const char *msg);

/**
 * Assert that the given pointer value is NULL.
 */
void assert_null (const void *ptr);

/**
 * Assert that the given NUL-terminated string matches the given target string exactly.
 */
void assert_strcmp (const char *is, const char *should_be);

/**
 * Assert that the first \a n chars of the first string matches the second string exactly.
 */
void assert_strncmp (const char *is, const char *should_be, size_t n);

/**
 * Assert that the given \a str is \a n chars long.
 */
void assert_strlen (const char *str, size_t n);

/**
 * Assert that the given \a str is NULL.
 */
void assert_strnull (const char *str);

/**
 * Assert that the given error code is SUCCESS.
 */
void assert_success (err_t err);

/**
 * Assert that the given actual error code \a err matches the expected error code \target.
 */
void assert_err (err_t err, err_t target);

/**
 * Assert that the given actual error \a is matches the expected error \a should_be
 */ 
void assert_error (error_t *is, error_t *should_be);

#endif