Lightweight C++20 testing framework.
BSL-1.0 License
Bot releases are hidden (Show)
Small changes and bug fixes:
REQUIRE_THROWS_*
macros in case no exception is thrown.CONSTEVAL_*
macros were evaluating their expressions at runtime if the expression was not decomposable.--color never
was specified.CHECK*
or REQUIRE*
call that triggered the exception. If the exception is not triggered inside a check macro, then the file/line of the enclosing SECTION
is used instead. If no section is used, then the assertion reverts to the previous behavior (file/line of the test case). See #141.small_function
into function_ref
(thanks @tocic)Published by cschreib about 1 year ago
Small changes and bug fixes:
Published by cschreib about 1 year ago
Small changes and bug fixes:
snitch::snitch-header-only
.--warn-uninitialized -Werror=dev
.Published by cschreib about 1 year ago
Main changes:
REQUIRE_NOTHROW(EXPR)
and CHECK_NOTHROW(EXPR)
.SUCCEED(MESSAGE)
.REGISTER_REPORTER(...)
(from Catch2) for registering multiple reporters that can be selected from the command line.--out
to save test report to a file.--list-tests
(#114).test_run_started
event.As a result, the following Catch2 IDE integrations now work with snitch:
Small changes and bug fixes:
small_function
copy construction from a non-const object was ambiguous.const char*
equal to nullptr
.[!mayfail]
and [!shouldfail]
as actual failures.registry::print
and all reporters was too easily truncated; the risk of this is now largely reduced.--list-tests
did not contain the full test name.append()
function for serialisationsmall_vector_span<const T>
was unsafe when not initialized with a valid backing small_vector
.small_function
compilation error when assigning a member function (or stateful lambda) when the function parameters contain l-value references.file_writer
.mock_framework
in tests by ~x3.Published by cschreib over 1 year ago
Small changes and bug fixes:
snitch_registry.hpp
header in the installed package.Thanks @tocic for the swift bug reports!
Published by cschreib over 1 year ago
Main changes:
CONSTEVAL_*
and CONSTEXPR_*
macros for compile-time (or combined compile- and run-time) testing.SKIP_CHECK()
to mark a test case as skipped without aborting (useful only if exceptions are turned off).Small changes and bug fixes:
REQUIRE
, CHECK
, REQUIRE_FALSE
, and CHECK_FALSE
REQUIRE_THAT
and CHECK_THAT
would not compileREQUIRE_THROWS_MATCHES
and CHECK_THROWS_MATCHES
std::exception
-Wpedantic
SNITCH_MAX_MESSAGE_LENGTH
.snitch::small_function
to have stronger invariants (always contains a function to call).snitch_all
target being sometimes out of date when building tests.std::terminate
with a customizable assertion handler. This terminates by default, so behavior is unchanged, but can be made to throw instead for testing.noexcept
to the whole code. This led to a minor but measurable performance degradation of compilation time.Published by cschreib almost 2 years ago
Summary of main changes:
SECTION()
.CAPTURE()
and INFO()
.TEMPLATE_TEST_CASE()
.REQUIRE_THAT()
and CHECK_THAT()
.REQUIRE_FALSE()
and CHECK_FALSE()
.[.]
/[!mayfail]
/[!shouldfail]
)snitch_all.hpp
.snitch_config.hpp
, containing build-time configuration (useful when not using CMake).CHECK()
and REQUIRE()
to evaluate their operands only once.CHECK()
and REQUIRE()
to support expressions that cannot be decomposed.TEST_CASE*()
macros to no longer require a trailing semicolon after the test body.TEST_CASE()
no longer requires tags to be provided (matches Catch2).REQUIRE(obj == matcher)
and REQUIRE(obj != matcher)
.TEMPLATE_LIST_TEST_CASE()
no longer requires std::tuple
(any type list will do).Detailed changelog.
Fixes #6:
registry::verbose
from a boolean to an enum similar to Catch2. Custom reports may be affected by this variable if they choose to use it.snitch::event
namespace, events, and the data
type to hold all possible events.registry::print_callback
to customize the function that prints output messages (default it to use standard output).registry::report_callback
to customize the function that formats test messages (default or if null, use snitch format).high
by default.Fixes #7:
SECTION()
to nest test code and share set-up/tear-down logic, as in Catch2.Fixes #8:
registry
, with_color
, which is true
if color should be used in messages and false
otherwise.--color
, to enable/disable color in messages.SNITCH_DEFAULT_WITH_COLOR
to change the default behavior of snitch regarding whether color codes are used in the standard output. Custom reporters may be affected by this variable if they choose to use registry::with_color
.Fixes #9.
CAPTURE()
and INFO()
.Fixes #13:
CHECK()
and REQUIRE()
will only evaluate operands once instead of twice.Fixes #17:
small_string
and small_vector
are now zero-initialised. This has a small runtime cost, but prevents any UB, which allows these classes to be used in constexpr
context.Fixes #25:
std::tuple
explicitly, and instead just asks for a template type list of any kind. This allows not including <tuple>
and instantiating std::tuple<...>
machinery, for faster compilation.Fixes #28:
REQUIRE_FALSE()
and CHECK_FALSE()
, which make sense and are useful. Now we have them too.Fixes #29:
[.]
, [!mayfail]
, [!shouldfail]
. This brings a lot of power to the tag system, so now we have this too.Fixes #31:
Fixes #42:
TEST_CASE("test name")
without specifying tags, for conciseness when tags aren't necessary. Now we support this too.Fixes #43:
REQUIRE()
or CHECK()
macro because of special rules, or reliance on specific chains of implicit conversions. Now snitch will support these types, and simply will skip decomposing the expression when it is unable to do it.Other bug fixes:
REQUIRE()
and CHECK()
not able to use custom append()
function if the function is not declared in the snitch::
namespace.REQUIRE()
and CHECK()
unable to compare function pointers.REQUIRE()
and CHECK()
and not in other check macros.-Wall -Wextra
and /W4
.registry::configure
and registry::run_tests
calling member functions from the global snitch::tests
registry rather than from this
, or console_print
rather than registry::print
.registry::list_all_tests
and registry::list_tests_with_tag
missing the newline character for non-typed-tests.append()
adding null-terminating character after appending numbers.Other miscellaneous changes:
snitch.hpp
now includes snitch_config.hpp
to reduce the risk of mismatched configuration with implementation.snitch::cli
namespace for public use.test_id
for public use.SNITCH_MAX_MATCHER_MSG_LENGTH
to SNITCH_MAX_MESSAGE_LENGTH
, and expand its impact to all messages that get written to a temporary buffer for printing.<exception>
when exceptions are disabled.REQUIRE*()
and FAIL()
macros now call std::terminate()
when exceptions are disabled.SNITCH_WITH_TIMINGS
to enable/disable test timing (enabled by default).is_any_of
to builtin matchers.SNITCH_VERSION
, SNITCH_FULL_VERSION
, SNITCH_VERSION_MAJOR
, SNITCH_VERSION_MINOR
, SNITCH_VERSION_PATCH
.snitch::cli::get_option()
an snitch::cli::get_positional_argument()
to the public API.snitch::cli::console_print
to customize the default (no registry) print location.pop_back()
to small_vector
.small_*
types and related helper functions to the snitch
namespace for public use.small_function
to store user callbacks.replace_all
to replace all occurrences in a small string.small_vector_span<const T>
and small_string_view
.append_or_truncate()
.operator[]
to small_string
.clang-format
set up.test_run
, instantiated when a test is run, rather than in the persistent test_case
. This reduces binary size, results in minor speed up, simplifies the code a bit, and reduces reliance on global registry.Published by cschreib about 2 years ago
Small changes and bug fixes:
.config
and find module.Published by cschreib about 2 years ago
Small changes and bug fixes:
SNATCH_WITH_EXCEPTIONS
to enable/disable exceptions in the implementation.SNATCH_WITH_SHORTHAND_MACROS
to enable/disable short macro names. Unless this is set to 1
(the default), all test macros will use the SNATCH_
prefix.try
/catch
blocks when exceptions are not available.Published by cschreib about 2 years ago
Small changes and bug fixes:
small_vector
and small_string
not fully constexpr
compatible.Published by cschreib about 2 years ago
First release!