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_LINE
and__builtin_FUNCTION
( gcc and clang )- for the custom
source_location
impl :/
- 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 |
Builds
toolchain | public-0.16.0 |
---|---|
target | aarch64-linux-gnu |
tgt config | linux_debian_12-clang_15 |
timestamp | 2024-03-28 10:26:29 UTC (09:47:29 hours ago) |
result | error (update) | log | rebuild |
toolchain | public-0.16.0 |
---|---|
target | aarch64-linux-gnu |
tgt config | linux_debian_11-gcc_12 |
timestamp | 2024-03-28 10:20:26 UTC (09:53:32 hours ago) |
result | error (update) | log | rebuild |
toolchain | public-0.16.0 |
---|---|
target | x86_64-linux-gnu |
tgt config | linux_debian_12-clang_15.0_libc++ |
timestamp | 2024-03-28 00:13:12 UTC (20:00:45 hours ago) |
result | success | log | rebuild |
toolchain | public-0.16.0 |
---|---|
target | x86_64-freebsd13.2 |
tgt config | freebsd_13-clang_14.0-static_O3 |
timestamp | 2024-03-28 00:12:46 UTC (20:01:11 hours ago) |
result | success | log | rebuild |
toolchain | public-0.16.0 |
---|---|
target | x86_64-freebsd13.2 |
tgt config | freebsd_13-clang_14.0-O3 |
timestamp | 2024-03-28 00:12:34 UTC (20:01:24 hours ago) |
result | success | log | rebuild |
toolchain | public-0.16.0 |
---|---|
target | x86_64-freebsd13.2 |
tgt config | freebsd_13-clang_14.0 |
timestamp | 2024-03-28 00:11:47 UTC (20:02:11 hours ago) |
result | success | log | rebuild |
toolchain | public-0.16.0 |
---|---|
target | x86_64-freebsd12.4 |
tgt config | freebsd_12-clang_13.0 |
timestamp | 2024-03-28 00:10:50 UTC (20:03:07 hours ago) |
result | success | log | rebuild |
toolchain | public-0.16.0 |
---|---|
target | x86_64-apple-darwin22.5.0 |
tgt config | macos_13-gcc_13_homebrew-static_O3 |
timestamp | 2024-03-27 11:50:34 UTC (01 08:23:24 days ago) |
result | error (update) | log | rebuild |
toolchain | public-0.16.0 |
---|---|
target | x86_64-apple-darwin22.5.0 |
tgt config | macos_13-gcc_13_homebrew-O3 |
timestamp | 2024-03-27 11:49:55 UTC (01 08:24:02 days ago) |
result | error (update) | log | rebuild |
toolchain | public-0.16.0 |
---|---|
target | x86_64-apple-darwin22.5.0 |
tgt config | macos_13-gcc_13_homebrew |
timestamp | 2024-03-27 11:49:15 UTC (01 08:24:42 days ago) |
result | error (update) | log | rebuild |
toolchain | public-0.16.0 |
---|---|
target | x86_64-apple-darwin22.5.0 |
tgt config | macos_13-clang_14.0-static_O3 |
timestamp | 2024-03-27 11:12:51 UTC (01 09:01:07 days ago) |
result | error (update) | log | rebuild |
toolchain | public-0.16.0 |
---|---|
target | x86_64-apple-darwin22.5.0 |
tgt config | macos_13-clang_14.0-O3 |
timestamp | 2024-03-27 11:12:12 UTC (01 09:01:46 days ago) |
result | error (update) | log | rebuild |
toolchain | public-0.16.0 |
---|---|
target | x86_64-apple-darwin22.5.0 |
tgt config | macos_13-clang_14.0 |
timestamp | 2024-03-27 11:11:32 UTC (01 09:02:26 days ago) |
result | error (update) | log | rebuild |
toolchain | public-0.16.0 |
---|---|
target | x86_64-apple-darwin22.5.0 |
tgt config | macos_13-clang_15.0-static_O3 |
timestamp | 2024-03-27 11:07:07 UTC (01 09:06:50 days ago) |
result | error (update) | log | rebuild |
toolchain | public-0.16.0 |
---|---|
target | x86_64-apple-darwin22.5.0 |
tgt config | macos_13-clang_15.0-O3 |
timestamp | 2024-03-27 11:06:25 UTC (01 09:07:33 days ago) |
result | error (update) | log | rebuild |
toolchain | public-0.16.0 |
---|---|
target | x86_64-apple-darwin22.5.0 |
tgt config | macos_13-clang_15.0 |
timestamp | 2024-03-27 11:05:45 UTC (01 09:08:12 days ago) |
result | error (update) | log | rebuild |
toolchain | public-0.16.0 |
---|---|
target | x86_64-linux-gnu |
tgt config | linux_fedora_38-gcc_13-bindist |
timestamp | 2024-03-27 10:59:24 UTC (01 09:14:34 days ago) |
result | error (update) | log | rebuild |
toolchain | public-0.16.0 |
---|---|
target | x86_64-linux-gnu |
tgt config | linux_debian_12-clang_16.0_libc++-O3 |
timestamp | 2024-03-27 10:58:20 UTC (01 09:15:38 days ago) |
result | error (update) | log | rebuild |
toolchain | public-0.16.0 |
---|---|
target | x86_64-linux-gnu |
tgt config | linux_debian_12-clang_16.0_libc++-static_O3 |
timestamp | 2024-03-27 10:58:15 UTC (01 09:15:43 days ago) |
result | error (update) | log | rebuild |
toolchain | public-0.16.0 |
---|---|
target | x86_64-linux-gnu |
tgt config | linux_debian_12-clang_16.0 |
timestamp | 2024-03-27 10:58:07 UTC (01 09:15:51 days ago) |
result | error (update) | log | rebuild |
toolchain | public-0.16.0 |
---|---|
target | x86_64-linux-gnu |
tgt config | linux_debian_12-clang_16.0_libc++ |
timestamp | 2024-03-27 10:55:54 UTC (01 09:18:04 days ago) |
result | error (update) | log | rebuild |
toolchain | public-0.16.0 |
---|---|
target | x86_64-linux-gnu |
tgt config | linux_debian_12-clang_16.0-static_O3 |
timestamp | 2024-03-27 10:55:43 UTC (01 09:18:15 days ago) |
result | error (update) | log | rebuild |
toolchain | public-0.16.0 |
---|---|
target | x86_64-linux-gnu |
tgt config | linux_debian_12-clang_16.0-O3 |
timestamp | 2024-03-27 10:55:21 UTC (01 09:18:37 days ago) |
result | error (update) | log | rebuild |
toolchain | public-0.16.0 |
---|---|
target | x86_64-microsoft-win32-msvc14.3 |
tgt config | windows_10-clang_16.0_llvm_msvc_17.6-O2 |
timestamp | 2024-03-27 10:47:59 UTC (01 09:25:59 days ago) |
result | error (update) | log | rebuild |
toolchain | public-0.16.0 |
---|---|
target | x86_64-microsoft-win32-msvc14.3 |
tgt config | windows_10-clang_16.0_llvm_msvc_17.6 |
timestamp | 2024-03-27 10:47:34 UTC (01 09:26:24 days ago) |
result | error (update) | log | rebuild |
toolchain | public-0.16.0 |
---|---|
target | x86_64-microsoft-win32-msvc14.3 |
tgt config | windows_10-clang_16.0_llvm_msvc_17.6-static_O2 |
timestamp | 2024-03-27 10:47:09 UTC (01 09:26:48 days ago) |
result | error (update) | log | rebuild |
toolchain | public-0.16.0 |
---|---|
target | x86_64-w64-mingw32 |
tgt config | windows_10-gcc_12.2_mingw_w64-static_O2 |
timestamp | 2024-03-27 10:46:56 UTC (01 09:27:02 days ago) |
result | error (update) | log | rebuild |
toolchain | public-0.16.0 |
---|---|
target | x86_64-w64-mingw32 |
tgt config | windows_10-gcc_12.2_mingw_w64-O2 |
timestamp | 2024-03-27 10:46:05 UTC (01 09:27:52 days ago) |
result | error (update) | log | rebuild |
toolchain | public-0.16.0 |
---|---|
target | x86_64-microsoft-win32-msvc14.3 |
tgt config | windows_10-msvc_17.6 |
timestamp | 2024-03-27 10:45:32 UTC (01 09:28:26 days ago) |
result | error (update) | log | rebuild |
toolchain | public-0.16.0 |
---|---|
target | x86_64-w64-mingw32 |
tgt config | windows_10-gcc_12.2_mingw_w64 |
timestamp | 2024-03-27 10:45:23 UTC (01 09:28:35 days ago) |
result | error (update) | log | rebuild |
toolchain | public-0.16.0 |
---|---|
target | x86_64-microsoft-win32-msvc14.3 |
tgt config | windows_10-msvc_17.6-static_O2 |
timestamp | 2024-03-27 10:45:13 UTC (01 09:28:45 days ago) |
result | error (update) | log | rebuild |
toolchain | public-0.16.0 |
---|---|
target | x86_64-microsoft-win32-msvc14.3 |
tgt config | windows_10-msvc_17.6-O2 |
timestamp | 2024-03-27 10:44:48 UTC (01 09:29:09 days ago) |
result | error (update) | log | rebuild |
toolchain | public-0.16.0 |
---|---|
target | x86_64-linux-gnu |
tgt config | linux_fedora_37-gcc_12.2-bindist |
timestamp | 2024-03-27 10:39:30 UTC (01 09:34:28 days ago) |
result | error (update) | log | rebuild |
toolchain | public-0.16.0 |
---|---|
target | x86_64-linux-gnu |
tgt config | linux_debian_12-gcc_13.1-ndebug_O3 |
timestamp | 2024-03-27 10:38:21 UTC (01 09:35:37 days ago) |
result | error (update) | log | rebuild |
toolchain | public-0.16.0 |
---|---|
target | x86_64-linux-gnu |
tgt config | linux_debian_12-gcc_13.1-O3 |
timestamp | 2024-03-27 10:37:38 UTC (01 09:36:20 days ago) |
result | error (update) | log | rebuild |
toolchain | public-0.16.0 |
---|---|
target | aarch64-linux-gnu |
tgt config | linux_debian_12-gcc_13-ndebug_O3 |
timestamp | 2024-03-27 10:36:28 UTC (01 09:37:30 days ago) |
result | error (update) | log | rebuild |
toolchain | public-0.16.0 |
---|---|
target | x86_64-linux-gnu |
tgt config | linux_debian_12-gcc_13.1-static_O3 |
timestamp | 2024-03-27 10:36:20 UTC (01 09:37:38 days ago) |
result | error (update) | log | rebuild |
toolchain | public-0.16.0 |
---|---|
target | aarch64-linux-gnu |
tgt config | linux_debian_12-gcc_13-O3 |
timestamp | 2024-03-27 10:36:06 UTC (01 09:37:52 days ago) |
result | error (update) | log | rebuild |
toolchain | public-0.16.0 |
---|---|
target | x86_64-linux-gnu |
tgt config | linux_debian_12-gcc_12-bindist |
timestamp | 2024-03-27 10:35:59 UTC (01 09:37:59 days ago) |
result | error (update) | log | rebuild |
toolchain | public-0.16.0 |
---|---|
target | aarch64-linux-gnu |
tgt config | linux_debian_12-gcc_13-static_O3 |
timestamp | 2024-03-27 10:34:31 UTC (01 09:39:27 days ago) |
result | error (update) | log | rebuild |
toolchain | public-0.16.0 |
---|---|
target | x86_64-microsoft-win32-msvc14.3 |
tgt config | windows_10-clang_15.0_msvc_msvc_17.6 |
timestamp | 2024-03-27 10:34:28 UTC (01 09:39:30 days ago) |
result | error (update) | log | rebuild |
toolchain | public-0.16.0 |
---|---|
target | x86_64-linux-gnu |
tgt config | linux_debian_12-gcc_13.1 |
timestamp | 2024-03-27 10:34:22 UTC (01 09:39:35 days ago) |
result | error (update) | log | rebuild |
toolchain | public-0.16.0 |
---|---|
target | aarch64-linux-gnu |
tgt config | linux_debian_12-gcc_13 |
timestamp | 2024-03-27 10:34:00 UTC (01 09:39:58 days ago) |
result | error (update) | log | rebuild |
toolchain | public-0.16.0 |
---|---|
target | x86_64-microsoft-win32-msvc14.3 |
tgt config | windows_10-msvc_17.5 |
timestamp | 2024-03-27 10:32:12 UTC (01 09:41:46 days ago) |
result | error (update) | log | rebuild |
toolchain | public-0.16.0 |
---|---|
target | x86_64-linux-gnu |
tgt config | linux_debian_12-clang_15.0 |
timestamp | 2024-03-27 10:28:31 UTC (01 09:45:26 days ago) |
result | error (update) | log | rebuild |
toolchain | public-0.16.0 |
---|---|
target | x86_64-linux-gnu |
tgt config | linux_debian_11-gcc_12.1 |
timestamp | 2024-03-27 10:28:09 UTC (01 09:45:49 days ago) |
result | error (update) | log | rebuild |
toolchain | public-0.16.0 |
---|---|
target | aarch64-linux-gnu |
tgt config | linux_debian_12-clang_15_libc++ |
timestamp | 2024-03-27 09:53:40 UTC (01 10:20:18 days ago) |
result | success | log | rebuild |
toolchain | public-0.16.0 |
---|---|
target | aarch64-linux-gnu |
tgt config | linux_debian_12-clang_16_libc++-static_O3 |
timestamp | 2024-03-26 12:04:53 UTC (02 08:09:05 days ago) |
result | error (update) | log | rebuild |
toolchain | public-0.16.0 |
---|---|
target | aarch64-linux-gnu |
tgt config | linux_debian_12-clang_16_libc++ |
timestamp | 2024-03-26 12:04:12 UTC (02 08:09:46 days ago) |
result | error (update) | log | rebuild |
toolchain | public-0.16.0 |
---|---|
target | aarch64-linux-gnu |
tgt config | linux_debian_12-clang_16-static_O3 |
timestamp | 2024-03-26 12:03:37 UTC (02 08:10:21 days ago) |
result | error (update) | log | rebuild |
toolchain | public-0.16.0 |
---|---|
target | aarch64-linux-gnu |
tgt config | linux_debian_12-clang_16_libc++-O3 |
timestamp | 2024-03-26 12:03:02 UTC (02 08:10:56 days ago) |
result | error (update) | log | rebuild |
toolchain | public-0.16.0 |
---|---|
target | aarch64-linux-gnu |
tgt config | linux_debian_12-clang_16 |
timestamp | 2024-03-26 12:01:06 UTC (02 08:12:51 days ago) |
result | error (update) | log | rebuild |
toolchain | public-0.16.0 |
---|---|
target | aarch64-linux-gnu |
tgt config | linux_debian_12-clang_16-O3 |
timestamp | 2024-03-26 11:59:57 UTC (02 08:14:01 days ago) |
result | error (update) | log | rebuild |