lake/test
2022-02-21 19:35:59 -08:00
..
laketest.c Use clang-format to enforce code style 2022-02-21 19:29:17 -08:00
laketest.h Use clang-format to enforce code style 2022-02-21 19:29:17 -08:00
Makefile fix a copy/paste bug 2015-07-31 16:26:13 -07:00
Readme.md fatten up test library 2011-04-24 14:45:46 -07:00
test_comment.c Use clang-format to enforce code style 2022-02-21 19:29:17 -08:00
test_dlist.c Use clang-format to enforce code style 2022-02-21 19:29:17 -08:00
test_env.c Use clang-format to enforce code style 2022-02-21 19:29:17 -08:00
test_eval.c Use clang-format to enforce code style 2022-02-21 19:29:17 -08:00
test_fn.c Use clang-format to enforce code style 2022-02-21 19:29:17 -08:00
test_int.c Fix a warning and use a better hash name 2022-02-21 19:35:59 -08:00
test_lake.c Use clang-format to enforce code style 2022-02-21 19:29:17 -08:00
test_list.c Use clang-format to enforce code style 2022-02-21 19:29:17 -08:00
test_parse.c Use clang-format to enforce code style 2022-02-21 19:29:17 -08:00
test_primitive.c Use clang-format to enforce code style 2022-02-21 19:29:17 -08:00
test_str.c Use clang-format to enforce code style 2022-02-21 19:29:17 -08:00
test_sym.c Use clang-format to enforce code style 2022-02-21 19:29:17 -08:00

Running Tests

From the root or test directory, run all tests:

$ make test

From the test directory run individual tests:

$ make test_eval && ./test_eval

Test Suite

A custom, minimal test framework based on MinUnit. The entire framework is ~30 lines. Its use is very simple:

// Shared state comes in handy
static this_t *this;

// Tests are just like MinUnit except we use lt_assert
static char *test_this(void)
{
    lt_assert("this should not be NULL", this != NULL);
    ...
    return 0;
}

static char *test_that(void)
{
    lt_assert("that should be greater than zero", this->that > 0);
    return 0;
}

int main(int argc, char const *argv[])
{
    // do your setup
    this = create_this();
    
    // run the tests exiting with 0 if all passed, non-zero if any failed
    return !lt_run_tests("Description", (test_fn[]){
        test_this,
        ...
        test_that,
        NULL         // this terminator is important
    });
}