v1.0.0
Summary of main changes:
- Renamed to snitch.
- Switched license from MIT to BSL.
- New features:
- Custom reporters and more control on default report output.
- Advanced test filtering (wildcards, exclusions, multiple filters, ...).
- Support for test fixtures.
SECTION()
.CAPTURE()
andINFO()
.TEMPLATE_TEST_CASE()
.REQUIRE_THAT()
andCHECK_THAT()
.REQUIRE_FALSE()
andCHECK_FALSE()
.- Special tags from Catch2 (
[.]
/[!mayfail]
/[!shouldfail]
) - New option to disable colors in default report output.
- Header-only version of the library:
snitch_all.hpp
. - Configuration header
snitch_config.hpp
, containing build-time configuration (useful when not using CMake).
- Notable improvements:
CHECK()
andREQUIRE()
to evaluate their operands only once.CHECK()
andREQUIRE()
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).- All check macros can now be called in other functions (a test case must still be running on the current thread).
- Matchers can now also be used as
REQUIRE(obj == matcher)
andREQUIRE(obj != matcher)
. TEMPLATE_LIST_TEST_CASE()
no longer requiresstd::tuple
(any type list will do).- Added unit tests for snitch, using both doctest and snitch as testing frameworks.
- Despite all the improvements and new features, compilation time has not increased significantly.
Detailed changelog.
Fixes #6:
- Promoted
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. - Added
snitch::event
namespace, events, and thedata
type to hold all possible events. - Added
registry::print_callback
to customize the function that prints output messages (default it to use standard output). - Added
registry::report_callback
to customize the function that formats test messages (default or if null, use snitch format). - Measure the time taken by each test, will be reported only if verbosity is
high
by default. - Added an example reporter callback for Teamcity.
Fixes #7:
- Add
SECTION()
to nest test code and share set-up/tear-down logic, as in Catch2.
Fixes #8:
- Add a new member to
registry
,with_color
, which istrue
if color should be used in messages andfalse
otherwise. - Add a new command line parameter
--color
, to enable/disable color in messages. - Add a new configuration pre-processor variable
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 useregistry::with_color
.
Fixes #9.
- Added
CAPTURE()
andINFO()
.
Fixes #13:
CHECK()
andREQUIRE()
will only evaluate operands once instead of twice.
Fixes #17:
small_string
andsmall_vector
are now zero-initialised. This has a small runtime cost, but prevents any UB, which allows these classes to be used inconstexpr
context.
Fixes #25:
- snitch no longer refers to
std::tuple
explicitly, and instead just asks for a template type list of any kind. This allows not including<tuple>
and instantiatingstd::tuple<...>
machinery, for faster compilation.
Fixes #28:
- Catch2 has
REQUIRE_FALSE()
andCHECK_FALSE()
, which make sense and are useful. Now we have them too.
Fixes #29:
- Catch2 defines special tags,
[.]
,[!mayfail]
,[!shouldfail]
. This brings a lot of power to the tag system, so now we have this too.
Fixes #31:
- snitch check macros used to rely on a hidden local test function parameter, which prevented using these macros outside of a test body. Now we use thread-local state, which can be queried from anywhere with little measured overhead, so check macros can be called deep inside nested utility check functions.
Fixes #42:
- Catch2 supports
TEST_CASE("test name")
without specifying tags, for conciseness when tags aren't necessary. Now we support this too.
Fixes #43:
- Some types are weird, and cannot be decomposed inside a
REQUIRE()
orCHECK()
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:
- Fixed
REQUIRE()
andCHECK()
not able to use customappend()
function if the function is not declared in thesnitch::
namespace. - Fixed
REQUIRE()
andCHECK()
unable to compare function pointers. - Fixed assertion count only incremented in
REQUIRE()
andCHECK()
and not in other check macros. - Fixed const-correctness of CLI parsing API.
- Fixed remaining warnings on
-Wall -Wextra
and/W4
. - Fixed
registry::configure
andregistry::run_tests
calling member functions from the globalsnitch::tests
registry rather than fromthis
, orconsole_print
rather thanregistry::print
. - Fixed
registry::list_all_tests
andregistry::list_tests_with_tag
missing the newline character for non-typed-tests. - (utilities) Fixed
append()
adding null-terminating character after appending numbers.
Other miscellaneous changes:
snitch.hpp
now includessnitch_config.hpp
to reduce the risk of mismatched configuration with implementation.- Brought the main command-line interface functions to the
snitch::cli
namespace for public use. - Refactored testing macros to speed up compilation and reduce code duplication.
- Refactored test name, type, and tags into
test_id
for public use. - Renamed
SNITCH_MAX_MATCHER_MSG_LENGTH
toSNITCH_MAX_MESSAGE_LENGTH
, and expand its impact to all messages that get written to a temporary buffer for printing. - Do not include
<exception>
when exceptions are disabled. REQUIRE*()
andFAIL()
macros now callstd::terminate()
when exceptions are disabled.- Added
SNITCH_WITH_TIMINGS
to enable/disable test timing (enabled by default). - Added
is_any_of
to builtin matchers. - Added
SNITCH_VERSION
,SNITCH_FULL_VERSION
,SNITCH_VERSION_MAJOR
,SNITCH_VERSION_MINOR
,SNITCH_VERSION_PATCH
. - The default reporter will print the snitch version number when beginning tests.
- Added
snitch::cli::get_option()
ansnitch::cli::get_positional_argument()
to the public API. - Added
snitch::cli::console_print
to customize the default (no registry) print location. - (utilities) Added
pop_back()
tosmall_vector
. - (utilities) Moved all
small_*
types and related helper functions to thesnitch
namespace for public use. - (utilities) Added
small_function
to store user callbacks. - (utilities) Added
replace_all
to replace all occurrences in a small string. - (utilities) Added immutable
small_vector_span<const T>
andsmall_string_view
. - (utilities) Added
append_or_truncate()
. - (utilities) Added
operator[]
tosmall_string
. - (docs) Added benchmark against Boost UT.
- (docs) Clarify the way in which custom types can be made serializable, and added documentation to README.
- (docs) Added example CMake usage instructions.
- (docs) Clarified what happens when a test with sections is aborted.
- (docs) Added information on recommended
clang-format
set up. - (internal) Moved all test state into a new struct
test_run
, instantiated when a test is run, rather than in the persistenttest_case
. This reduces binary size, results in minor speed up, simplifies the code a bit, and reduces reliance on global registry. - (internal) Added unit tests to test the testing framework :) This is using doctest, in case snitch breaks and fails to report it to itself, but the tests are also run using snitch to test snitch, just because we can.
- (internal) Updated clang-format to version 15.
- (CI) Added coverage check to CI.
- (CI) Added tests runs.
- (CI) Added builds with timings and exceptions disabled.