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 115d38f7b6 Add stub run_tests
For when unit testing is disabled
2019-03-13 21:16:01 +00:00
examples/trivial_tests Print more information for test cases 2019-03-13 21:15:27 +00:00
README.md Initial commit 2019-03-12 23:27:00 +00:00
test.h Add stub run_tests 2019-03-13 21:16:01 +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
	// ...
	SHOULD_EQUAL(1, 0); // Fail
}

Run the test cases

In your main function, call run_tests:

int main() {
	// necessary setup code
	// ...
#ifdef UNIT_TEST
	run_tests();
	// cleanup
#endif
	// usual code
}