pest is macro free otherwise simplistic c++17 unit testing
antibloat & turbo simplistic header only cxx unit testing & benchmarking thingy.
implemented this because a hackable solution for unit testing was needed not causing excessive compile times once you have more than one assertion.
- reduced sloc
- easy to understand and hack
- does not suffer from extraordinarily compile time bloat
- does not suffer from extraordinarily compiled binary bloat
- macro free
pest includes a xoshiro prng and a zipfian distribution helper class:
#include <pest/xoshiro.hxx>#include <pest/zipfian-distribution.hxx>
requires
- c++17
__builtin_FILE,__builtin_LINEand__builtin_FUNCTION( gcc and clang )- for the custom
source_locationimpl :/
- for the custom
examples
unit tests ( using emptyspace::pest )
source file ...
#include <pest/pest.hxx>
namespace {
emptyspace::pest::suite basic( "pest self test", []( auto& test ) {
using namespace emptyspace::pest;
test( "true equal_to true", []( auto& expect ) {
expect( true, equal_to( true ) );
} );
test( "vector<> equal_to initializer_list<>", []( auto& expect ) {
auto const inputs = std::vector<int>{ 3, 4, 7 };
expect( inputs, equal_to( { 3, 4, 7 } ) );
} );
} );
} // namespace
int main() {
basic( std::clog );
return 0;
}
... and example output
# assuming the example from above is in `example.cxx`
pest $ clang++10 -I. -std=c++17 example.cxx -o ex
pest $ ./ex
[suite <pest self test> | true equal_to true]
[suite <pest self test> | vector<> equal_to initializer_list<>]
[suite <pest self test> | summary]
total assertions failed = 0
total assertions pass = 2
total assertions skipped = 0
total uncaught exceptions = 0
total tests = 2
benchmarks ( using emptyspace::pnch )
suppose we want to benchmark the strftime function ...
#include <pest/pnch.hxx>
#include <ctime>
int main() {
emptyspace::pnch::config cfg;
std::size_t n = 0;
char buffer[128];
cfg.run(
"strftime",
[&]() {
auto stamp1 = std::chrono::system_clock::now();
auto epoch = std::chrono::system_clock::to_time_t( stamp1 );
auto gmtime = std::gmtime( &epoch );
n += std::strftime( buffer, 64, "%Y.%m.%d:%T.", gmtime );
} )
.touch( n )
.report_to( std::cerr );
return n > 0;
}
... could lead to the following output
[benchmark | strftime]
stats/total = 2.27702e+09
stats/average = 990.007
stats/stddev = 7.18419
development & packaging
build2 is used for life cycle management. for using without build2
just drop the header into your project.
cloning the repository and running the test driver test/unit/driver.cxx
$ git clone https://github.com/stackless-goto/pest
$ cd pest
$ bdep init -C @clang10 cc config.cxx=clang++10
$ bdep test
test tests/unit/testscript{testscript}@../pest-clang10/pest/tests/unit/ ../pest-clang10/pest/tests/unit/exe{driver}
declaring pest as dependency in a build2 project:
TODO
references
similar libraries. might be better suited ...
unit test helpers
- ~martinmoene/lest ( small-ish, compile-time and binary bloat )
- ~jimporter/mettle ( big-ish, compile-time bloat )
benchmark helpers
mirrors
license
choose between UNLICENSE or LICENSE freely. zipfian and xoshiro are derived work and
therefore -- as indicated in the corresponding source files -- MIT licensed.
support and blame-game
magenbluten < mb [at] 64k.by > :: https://64k.by
| version | 1.0.1 |
|---|---|
| license | public domain |
| repository | https://pkg.cppget.org/1/stable |
| download | pest-1.0.1.tar.gz |
| sha256 | cc4e2c83c78cd5d86d6412c6cc29558e17304f2b93728978719da6a9d42d9fde |
| project | pest |
|---|---|
| url | hub.darcs.net/magenbluten/pest |
| mb@64k.by |
Requires (1)
| c++17 |
Reviews
| fail | 0 |
|---|---|
| pass | 1 |
Builds
| toolchain | public-0.18.1 |
|---|---|
| target | x86_64-apple-darwin23.5.0 |
| tgt config | macos_14-clang_15.0-static_O3 |
| timestamp | 2026-09-29 13:15:49 UTC (17:59:24 hours ago) |
| result | error (update) | log | rebuild |
| toolchain | public-0.18.1 |
|---|---|
| target | x86_64-apple-darwin23.5.0 |
| tgt config | macos_14-clang_15.0-O3 |
| timestamp | 2026-09-29 13:14:55 UTC (18:00:18 hours ago) |
| result | error (update) | log | rebuild |
| toolchain | public-0.18.1 |
|---|---|
| target | x86_64-apple-darwin23.5.0 |
| tgt config | macos_14-clang_15.0 |
| timestamp | 2026-09-29 13:13:59 UTC (18:01:14 hours ago) |
| result | error (update) | log | rebuild |
| toolchain | public-0.18.1 |
|---|---|
| target | x86_64-linux-gnu |
| tgt config | linux_fedora_44-gcc_16-bindist |
| timestamp | 2026-09-28 12:03:37 UTC (01 19:11:35 days ago) |
| result | error (update) | log | rebuild |
| toolchain | public-0.18.1 |
|---|---|
| target | x86_64-linux-gnu |
| tgt config | linux_fedora_43-gcc_15-bindist |
| timestamp | 2026-09-27 11:09:22 UTC (02 20:05:51 days ago) |
| result | error (update) | log | rebuild |
| toolchain | public-0.18.1 |
|---|---|
| target | x86_64-linux-gnu |
| tgt config | linux_debian_13-clang_22_libc++-O3 |
| timestamp | 2026-09-27 10:49:47 UTC (02 20:25:26 days ago) |
| result | error (update) | log | rebuild |
| toolchain | public-0.18.1 |
|---|---|
| target | x86_64-linux-gnu |
| tgt config | linux_debian_13-clang_22_libc++-static_O3 |
| timestamp | 2026-09-27 10:49:12 UTC (02 20:26:01 days ago) |
| result | error (update) | log | rebuild |
| toolchain | public-0.18.1 |
|---|---|
| target | x86_64-linux-gnu |
| tgt config | linux_debian_13-clang_22-static_O3 |
| timestamp | 2026-09-27 10:48:28 UTC (02 20:26:45 days ago) |
| result | error (update) | log | rebuild |
| toolchain | public-0.18.1 |
|---|---|
| target | x86_64-linux-gnu |
| tgt config | linux_debian_13-clang_22_libc++ |
| timestamp | 2026-09-27 10:48:26 UTC (02 20:26:47 days ago) |
| result | error (update) | log | rebuild |
| toolchain | public-0.18.1 |
|---|---|
| target | x86_64-linux-gnu |
| tgt config | linux_debian_13-clang_22-O3 |
| timestamp | 2026-09-27 10:48:12 UTC (02 20:27:01 days ago) |
| result | error (update) | log | rebuild |
| toolchain | public-0.18.1 |
|---|---|
| target | x86_64-linux-gnu |
| tgt config | linux_debian_13-clang_22 |
| timestamp | 2026-09-27 10:47:44 UTC (02 20:27:29 days ago) |
| result | error (update) | log | rebuild |
| toolchain | public-0.18.1 |
|---|---|
| target | x86_64-linux-gnu |
| tgt config | linux_ubuntu_24.04-gcc_13-bindist |
| timestamp | 2026-09-27 10:39:38 UTC (02 20:35:35 days ago) |
| result | error (update) | log | rebuild |
| toolchain | public-0.18.1 |
|---|---|
| target | x86_64-linux-gnu |
| tgt config | linux_debian_13-gcc_16-ndebug_O3 |
| timestamp | 2026-09-27 10:38:18 UTC (02 20:36:55 days ago) |
| result | error (update) | log | rebuild |
| toolchain | public-0.18.1 |
|---|---|
| target | x86_64-linux-gnu |
| tgt config | linux_debian_13-gcc_16-O3 |
| timestamp | 2026-09-27 10:38:02 UTC (02 20:37:11 days ago) |
| result | error (update) | log | rebuild |
| toolchain | public-0.18.1 |
|---|---|
| target | x86_64-linux-gnu |
| tgt config | linux_debian_13-gcc_16-static_O3 |
| timestamp | 2026-09-27 10:38:00 UTC (02 20:37:13 days ago) |
| result | error (update) | log | rebuild |
| toolchain | public-0.18.1 |
|---|---|
| target | x86_64-linux-gnu |
| tgt config | linux_debian_13-gcc_16 |
| timestamp | 2026-09-27 10:36:47 UTC (02 20:38:26 days ago) |
| result | error (update) | log | rebuild |
| toolchain | public-0.18.1 |
|---|---|
| target | x86_64-freebsd15.0 |
| tgt config | freebsd_15-clang_19-static_O3 |
| timestamp | 2026-09-27 10:31:40 UTC (02 20:43:33 days ago) |
| result | error (update) | log | rebuild |
| toolchain | public-0.18.1 |
|---|---|
| target | x86_64-freebsd15.0 |
| tgt config | freebsd_15-clang_19-O3 |
| timestamp | 2026-09-27 10:31:37 UTC (02 20:43:36 days ago) |
| result | error (update) | log | rebuild |
| toolchain | public-0.18.1 |
|---|---|
| target | aarch64-linux-gnu |
| tgt config | linux_debian_12-clang_18_libc++-static_O3 |
| timestamp | 2026-09-27 10:31:26 UTC (02 20:43:47 days ago) |
| result | error (update) | log | rebuild |
| toolchain | public-0.18.1 |
|---|---|
| target | aarch64-linux-gnu |
| tgt config | linux_debian_12-clang_18_libc++-O3 |
| timestamp | 2026-09-27 10:31:08 UTC (02 20:44:05 days ago) |
| result | error (update) | log | rebuild |
| toolchain | public-0.18.1 |
|---|---|
| target | x86_64-freebsd15.0 |
| tgt config | freebsd_15-clang_19 |
| timestamp | 2026-09-27 10:31:07 UTC (02 20:44:06 days ago) |
| result | error (update) | log | rebuild |
| toolchain | public-0.18.1 |
|---|---|
| target | aarch64-linux-gnu |
| tgt config | linux_debian_12-clang_18_libc++ |
| timestamp | 2026-09-27 10:30:46 UTC (02 20:44:27 days ago) |
| result | error (update) | log | rebuild |
| toolchain | public-0.18.1 |
|---|---|
| target | aarch64-linux-gnu |
| tgt config | linux_debian_12-clang_18-static_O3 |
| timestamp | 2026-09-27 10:30:26 UTC (02 20:44:47 days ago) |
| result | error (update) | log | rebuild |
| toolchain | public-0.18.1 |
|---|---|
| target | aarch64-linux-gnu |
| tgt config | linux_debian_12-clang_18-O3 |
| timestamp | 2026-09-27 10:29:45 UTC (02 20:45:27 days ago) |
| result | error (update) | log | rebuild |
| toolchain | public-0.18.1 |
|---|---|
| target | x86_64-linux-gnu |
| tgt config | linux_debian_13-gcc_14-bindist |
| timestamp | 2026-09-27 10:29:21 UTC (02 20:45:51 days ago) |
| result | error (update) | log | rebuild |
| toolchain | public-0.18.1 |
|---|---|
| target | aarch64-linux-gnu |
| tgt config | linux_debian_12-clang_18 |
| timestamp | 2026-09-27 10:29:21 UTC (02 20:45:51 days ago) |
| result | error (update) | log | rebuild |
| toolchain | public-0.18.1 |
|---|---|
| target | x86_64-apple-darwin22.5.0 |
| tgt config | macos_13-clang_15.0 |
| timestamp | 2026-09-27 10:29:00 UTC (02 20:46:13 days ago) |
| result | error (update) | log | rebuild |
| toolchain | public-0.18.1 |
|---|---|
| target | x86_64-linux-gnu |
| tgt config | linux_debian_13-clang_21_libc++ |
| timestamp | 2026-09-27 10:27:51 UTC (02 20:47:21 days ago) |
| result | error (update) | log | rebuild |
| toolchain | public-0.18.1 |
|---|---|
| target | x86_64-linux-gnu |
| tgt config | linux_debian_13-clang_21 |
| timestamp | 2026-09-27 10:27:34 UTC (02 20:47:39 days ago) |
| result | error (update) | log | rebuild |
| toolchain | public-0.18.1 |
|---|---|
| target | x86_64-linux-gnu |
| tgt config | linux_debian_13-gcc_15-O3 |
| timestamp | 2026-09-27 10:26:32 UTC (02 20:48:41 days ago) |
| result | error (update) | log | rebuild |
| toolchain | public-0.18.1 |
|---|---|
| target | x86_64-linux-gnu |
| tgt config | linux_debian_13-gcc_15 |
| timestamp | 2026-09-27 10:25:46 UTC (02 20:49:27 days ago) |
| result | error (update) | log | rebuild |
| toolchain | public-0.18.1 |
|---|---|
| target | x86_64-freebsd14.1 |
| tgt config | freebsd_14-clang_18 |
| timestamp | 2026-09-27 10:24:09 UTC (02 20:51:04 days ago) |
| result | error (update) | log | rebuild |
| toolchain | public-0.18.1 |
|---|---|
| target | x86_64-microsoft-win32-msvc14.3 |
| tgt config | windows_10-msvc_17 |
| timestamp | 2026-09-26 11:22:15 UTC (03 19:52:58 days ago) |
| result | error (update) | log | rebuild |
| toolchain | public-0.18.1 |
|---|---|
| target | aarch64-linux-gnu |
| tgt config | linux_debian_12-gcc_14-static_O3 |
| timestamp | 2026-09-26 10:28:17 UTC (03 20:46:56 days ago) |
| result | error (update) | log | rebuild |
| toolchain | public-0.18.1 |
|---|---|
| target | aarch64-linux-gnu |
| tgt config | linux_debian_12-gcc_14-ndebug_O3 |
| timestamp | 2026-09-26 10:27:45 UTC (03 20:47:28 days ago) |
| result | error (update) | log | rebuild |
| toolchain | public-0.18.1 |
|---|---|
| target | aarch64-linux-gnu |
| tgt config | linux_debian_12-gcc_14-O3 |
| timestamp | 2026-09-26 10:27:10 UTC (03 20:48:03 days ago) |
| result | error (update) | log | rebuild |
| toolchain | public-0.18.1 |
|---|---|
| target | aarch64-linux-gnu |
| tgt config | linux_debian_12-gcc_14 |
| timestamp | 2026-09-26 10:26:39 UTC (03 20:48:33 days ago) |
| result | error (update) | log | rebuild |
| toolchain | public-0.18.1 |
|---|---|
| target | aarch64-linux-gnu |
| tgt config | linux_debian_12-gcc_13 |
| timestamp | 2026-09-24 10:12:07 UTC (05 21:03:06 days ago) |
| result | error (update) | log | rebuild |
| toolchain | public-0.18.1 |
|---|---|
| target | x86_64-microsoft-win32-msvc14.5 |
| tgt config | windows_10-clang_21_msvc_18-O2 |
| timestamp | 2026-09-23 10:18:55 UTC (06 20:56:18 days ago) |
| result | error (update) | log | rebuild |
| toolchain | public-0.18.1 |
|---|---|
| target | x86_64-microsoft-win32-msvc14.5 |
| tgt config | windows_10-clang_21_msvc_18-static_O2 |
| timestamp | 2026-09-23 10:18:55 UTC (06 20:56:18 days ago) |
| result | error (update) | log | rebuild |
| toolchain | public-0.18.1 |
|---|---|
| target | x86_64-microsoft-win32-msvc14.5 |
| tgt config | windows_10-clang_21_msvc_18 |
| timestamp | 2026-09-23 10:17:47 UTC (06 20:57:25 days ago) |
| result | error (update) | log | rebuild |
| toolchain | public-0.18.1 |
|---|---|
| target | x86_64-microsoft-win32-msvc14.5 |
| tgt config | windows_10-msvc_18-static_O2 |
| timestamp | 2026-09-23 10:17:05 UTC (06 20:58:08 days ago) |
| result | error (update) | log | rebuild |
| toolchain | public-0.18.1 |
|---|---|
| target | x86_64-microsoft-win32-msvc14.5 |
| tgt config | windows_10-msvc_18-O2 |
| timestamp | 2026-09-23 10:17:04 UTC (06 20:58:09 days ago) |
| result | error (update) | log | rebuild |
| toolchain | public-0.18.1 |
|---|---|
| target | x86_64-microsoft-win32-msvc14.5 |
| tgt config | windows_10-msvc_18 |
| timestamp | 2026-09-23 10:16:05 UTC (06 20:59:08 days ago) |
| result | error (update) | log | rebuild |
| toolchain | public-0.18.1 |
|---|---|
| target | x86_64-w64-mingw32 |
| tgt config | windows_10-gcc_15.2_mingw_w64-static_O2 |
| timestamp | 2026-09-20 10:20:35 UTC (09 20:54:38 days ago) |
| result | error (update) | log | rebuild |
| toolchain | public-0.18.1 |
|---|---|
| target | x86_64-w64-mingw32 |
| tgt config | windows_10-gcc_15.2_mingw_w64-O2 |
| timestamp | 2026-09-20 10:19:39 UTC (09 20:55:34 days ago) |
| result | error (update) | log | rebuild |
| toolchain | public-0.18.1 |
|---|---|
| target | x86_64-w64-mingw32 |
| tgt config | windows_10-gcc_15.2_mingw_w64 |
| timestamp | 2026-09-20 10:18:41 UTC (09 20:56:32 days ago) |
| result | error (update) | log | rebuild |
| toolchain | public-0.18.1 |
|---|---|
| target | x86_64-linux-gnu |
| tgt config | linux_ubuntu_26.04-gcc_15-bindist |
| timestamp | 2026-09-20 10:12:46 UTC (09 21:02:27 days ago) |
| result | error (update) | log | rebuild |
| toolchain | public-0.18.1 |
|---|---|
| target | x86_64-apple-darwin23.5.0 |
| tgt config | macos_14-gcc_14_homebrew-static_O3 |
| timestamp | 2026-09-17 11:05:24 UTC (12 20:09:49 days ago) |
| result | error (update) | log | rebuild |
| toolchain | public-0.18.1 |
|---|---|
| target | x86_64-apple-darwin23.5.0 |
| tgt config | macos_14-gcc_14_homebrew-O3 |
| timestamp | 2026-09-17 11:04:38 UTC (12 20:10:34 days ago) |
| result | error (update) | log | rebuild |
| toolchain | public-0.18.1 |
|---|---|
| target | x86_64-apple-darwin23.5.0 |
| tgt config | macos_14-gcc_14_homebrew |
| timestamp | 2026-09-17 11:03:54 UTC (12 20:11:19 days ago) |
| result | error (update) | log | rebuild |