Skip to content
jctest

jctest

jctest provides single-header C11 and C++11 test frameworks implementing a GTest-like API. The libraries were built as lightweight replacements for googletest and similar C frameworks.

License jc_test.h size Version GitHub stars

Use jc_test.h from C and jc_test.hpp from C++. A C++ translation unit that still includes jc_test.h is forwarded to jc_test.hpp for compatibility. The implementations are separate runtimes and cannot both define JC_TEST_IMPLEMENTATION in the same executable.

Minimal C example

#define JC_TEST_IMPLEMENTATION
#include <jc_test.h>

TEST(Math, Multiply)
{
    ASSERT_EQ(4, 2 * 2);
}

int main(int argc, char** argv)
{
    jc_test_init(&argc, argv);
    return jc_test_run_all();
}

Minimal C++ example

#define JC_TEST_IMPLEMENTATION
#include <jc_test.hpp>

TEST(MyTest, Multiplication) {
    ASSERT_EQ(4, 2 * 2);
}
TEST(MyTest, Division) {
    ASSERT_EQ(2, 4 / 2);
}

int main(int argc, char *argv[]) {
    // Parses and removes any jc_test specific arguments
    jc_test_init(&argc, argv);
    // ... Do your test initialization
    return jc_test_run_all();
}

Failures are reported immediately. At the end of a long run, every failed check is repeated with its full test name and source location before the totals.

An example where all tests pass
An example where all tests pass
An example of how failing tests look
An example of how failing tests look
Last updated on