A unit testing framework for C. Uses glib.
C Perl
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
test
.gitignore
COPYING
Makefile
README
assert.c
bogotest.7.txt
bogotest.h
data.c
internal.h
lib.mk
main.c
runner.c

README

Bogus Testing Framework - a unit testing framework for C
* vim:ft=text:

This framework was written to take the best ideas from CUnit, Check, and the
various xUnit systems.  Features include:
 * Fixtures with setup and teardown functions
 * Forking - each test runs in its own process
 * Pre-written main function - all you write are tests

The basic idea: write your tests using the various BT_ASSERT macros.  Define an
array, bogotest_suites, of BTSuiteInfo structures defining your test suites.
Link against libbogotest.a, and run the resulting program.

Note that bogotest uses glib, so the link line also needs the appropriate
libraries for glib 2.x.

REQUIREMENTS

BogoTest requires GCC and GNU make to build.

BOGOTEST COMMAND LINE OPTIONS

BogoTest's main function currently recognizes two command line options. '-v'
turns on verbose output.  '-F' disables forking (useful for debugging a failing
test).

GENERAL HINTS

I find it useful to just clone the bogotest tree in to a subdirectory
of my project's source tree and reference it there.  Mercurial
submodules can work well for this.

INSTALLATION

If you really feel like installing the library somehow, you can type `make
install` to install it to $PREFIX (defaults to /usr/local).

EXAMPLE

The following is a complete single test case in BogoTest:

===8<===== BEGIN CODE =======

#include <bogotest.h>

typedef struct fixture {
    int a;
    int b;
} fixture_t;

void* fixture_create(void)
{
    return g_new0(fixture_t, 1);
}
void fixture_destroy(fixture_t *fix)
{
    g_free(fix);
}

void test_equal(fixture_t *fix)
{
    fix->a = 42;
    fix->b = 42;
    BT_ASSERT(fix->a == fix->b);
    BT_ASSERT_EQUAL(fix->a, 42);
}

BTTestInfo tests[] = {
    { "test equal ints", test_equal },
    BT_TEST_INFO_NULL
};

BTFixtureInfo fixtures[] = {
    { fixture_create, fixture_destroy, tests },
    BT_FIXTURE_INFO_NULL
};

BTSuiteInfo bogotest_suites[] = {
    { "example tests", fixtures },
    BT_SUITE_INFO_NULL
};

==8<======= END CODE ========