A minimal unit testing framework. More...
Classes | |
| struct | sourcemeta::core::TestAbortError |
Functions | |
| SOURCEMETA_CORE_TEST_EXPORT auto | sourcemeta::core::test_register (std::string_view suite, std::string_view name, std::string_view file, int line, std::function< void()> body) -> int |
| SOURCEMETA_CORE_TEST_EXPORT auto | sourcemeta::core::test_register (std::string_view name, std::function< void()> body, std::source_location location=std::source_location::current()) -> int |
| SOURCEMETA_CORE_TEST_EXPORT auto | sourcemeta::core::test_report_failure (std::string_view file, int line, std::string_view message) -> void |
| SOURCEMETA_CORE_TEST_EXPORT auto | sourcemeta::core::test_suite_from_path (std::string_view path) -> std::string |
| SOURCEMETA_CORE_TEST_EXPORT auto | sourcemeta::core::test_run (int argc, char **argv) -> int |
| SOURCEMETA_CORE_TEST_EXPORT auto | sourcemeta::core::test_stringify_difference (std::string_view actual, std::string_view expected) -> std::string |
A minimal unit testing framework.
This functionality is included as follows:
| struct sourcemeta::core::TestAbortError |
| SOURCEMETA_CORE_TEST_EXPORT auto sourcemeta::core::test_register | ( | std::string_view | name, |
| std::function< void()> | body, | ||
| std::source_location | location = std::source_location::current() ) -> int |
Register a test case whose suite and source location are taken from the call site. Intended for suites that discover their cases at runtime.
| SOURCEMETA_CORE_TEST_EXPORT auto sourcemeta::core::test_register | ( | std::string_view | suite, |
| std::string_view | name, | ||
| std::string_view | file, | ||
| int | line, | ||
| std::function< void()> | body ) -> int |
Register a test by name with a callable body. Returns a dummy value so it can be used to initialise a namespace-scope variable.
| SOURCEMETA_CORE_TEST_EXPORT auto sourcemeta::core::test_report_failure | ( | std::string_view | file, |
| int | line, | ||
| std::string_view | message ) -> void |
Print a failure at the given location and abort the current test.
| SOURCEMETA_CORE_TEST_EXPORT auto sourcemeta::core::test_run | ( | int | argc, |
| char ** | argv ) -> int |
Run every registered test, optionally filtered, and return a process exit code.
| SOURCEMETA_CORE_TEST_EXPORT auto sourcemeta::core::test_stringify_difference | ( | std::string_view | actual, |
| std::string_view | expected ) -> std::string |
Render the differences between two strings in the unified format, or nothing if showing both values as they are is just as informative.
| SOURCEMETA_CORE_TEST_EXPORT auto sourcemeta::core::test_suite_from_path | ( | std::string_view | path | ) | -> std::string |
Derive a suite name from a source file path by taking its stem and stripping a trailing _test suffix.