1
0
Fork 0
mirror of https://github.com/yshui/picom.git synced 2024-11-11 13:51:02 -05:00
A lightweight compositor for X11
Find a file
Yuxuan Shui cf253e12f3 test.h: Update README
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-03-18 22:41:00 +00:00
examples/trivial_tests test.h: add out parameter to return whether tests were run 2019-03-18 21:57:10 +00:00
meson.build Add a meson.build to test.h 2019-03-18 21:46:23 +00:00
README.md test.h: Update README 2019-03-18 22:41:00 +00:00
test.h test.h: add TEST_STREQUAL 2019-03-18 22:30:16 +00:00

test.h

A very simple, light weight, header only C unit test framework.

Features

  • Easy to use, no dependencies, no setup needed.
  • Keep test cases close to the code they test.
  • Automatic registration of the test cases.

Setup

Just include the header

#include "test.h"

To enable the test cases in your code, compile your program with -DUNIT_TEST.

Defining test cases

TEST_CASE(test_case_name) {
	// Your code here
	// ...
	TEST_EQUAL(1, 0); // Fail
}

Run the test cases

In your main function, call run_tests:

int main(int argc, char *const *argv) {
	// necessary setup code
	// ...
	if (!run_tests(argc, argv, NULL)) {
		// test failed
		abort();
	}
	// cleanup
	// usual code
}

Then, run your program with ./program --unittest.