Tchatator413
TripEnArvor instant messaging protocol - JSON-based
|
Quick unit testing library. More...
#include <stdbool.h>
#include <stdio.h>
Go to the source code of this file.
Data Structures | |
struct | test |
Represents a test suite with a name and a collection of test cases. More... | |
struct | _stbtest_case |
Macros | |
#define | STB_TEST_DEFINITION |
Defines modifier keywords for the definitions. Example value: static inline. | |
#define | _STBTEST_ATTR_FORMAT(archetype, string_index, first_to_check) |
#define | test_fail(test, name, ...) _stbtest_test_case(__LINE__, __FILE_NAME__, (test), false, "(fail)", (name)__VA_OPT__(, ) __VA_ARGS__) |
Add a test case that is always a failure. | |
#define | test_case(test, expr, name, ...) _stbtest_test_case(__LINE__, __FILE_NAME__, (test), (expr), #expr, (name)__VA_OPT__(, ) __VA_ARGS__) |
Add a test case. | |
#define | test_case_wide(test, expr, name, ...) _stbtest_test_case(__LINE__, __FILE_NAME__, (test), (expr), NULL, (name)__VA_OPT__(, ) __VA_ARGS__) |
Add a test case with the expr and name columns merged. | |
Functions | |
STB_TEST_DEFINITION struct test | test_start (char const *name) |
Start a new test suite with the given name. | |
STB_TEST_DEFINITION bool | _stbtest_test_case (unsigned line, char const *file, struct test *test, bool ok, char const *expr, char const *fmt_name,...) _STBTEST_ATTR_FORMAT(printf |
STB_TEST_DEFINITION bool STB_TEST_DEFINITION bool | test_end (struct test *test, FILE *output) |
Finish a test suite and prints the results to the provided output stream. | |
Quick unit testing library.
See README.md for details and usage.
Definition in file stb_test.h.
#define _STBTEST_ATTR_FORMAT | ( | archetype, | |
string_index, | |||
first_to_check | |||
) |
Definition at line 23 of file stb_test.h.
#define STB_TEST_DEFINITION |
Defines modifier keywords for the definitions. Example value: static inline.
Definition at line 14 of file stb_test.h.
#define test_case | ( | test, | |
expr, | |||
name, | |||
... | |||
) | _stbtest_test_case(__LINE__, __FILE_NAME__, (test), (expr), #expr, (name)__VA_OPT__(, ) __VA_ARGS__) |
Add a test case.
Definition at line 51 of file stb_test.h.
#define test_case_wide | ( | test, | |
expr, | |||
name, | |||
... | |||
) | _stbtest_test_case(__LINE__, __FILE_NAME__, (test), (expr), NULL, (name)__VA_OPT__(, ) __VA_ARGS__) |
Add a test case with the expr and name columns merged.
Definition at line 53 of file stb_test.h.
#define test_fail | ( | test, | |
name, | |||
... | |||
) | _stbtest_test_case(__LINE__, __FILE_NAME__, (test), false, "(fail)", (name)__VA_OPT__(, ) __VA_ARGS__) |
Add a test case that is always a failure.
Definition at line 49 of file stb_test.h.
STB_TEST_DEFINITION bool STB_TEST_DEFINITION bool test_end | ( | struct test * | test, |
FILE * | output | ||
) |
Finish a test suite and prints the results to the provided output stream.
This function takes a struct test
instance and an output stream, and prints the results of the test suite to the output stream. It includes information about the number of successful and failed test cases, as well as the names and file locations of the failed test cases.
test
Dereferencing test
after calling this function is undefined behavior.test | The test suite to be finished. |
output | The output stream to print the results to. |
true
if all test cases passed false
otherwise. STB_TEST_DEFINITION struct test test_start | ( | char const * | name | ) |
Start a new test suite with the given name.
This function creates a new struct test
instance with the provided name and an empty list of test cases.
name | The name of the test suite. |
struct test
instance.