Commit Graph

4445 Commits

Author SHA1 Message Date
Martin Hořeňovský
b7d70ddcd6
Ensure we always read 32 bit seed from std::random_device 2023-12-10 21:37:12 +01:00
Martin Hořeňovský
a6f22c5169
Remove static instance of std::random_device in Benchmark::analyse_samples 2023-12-10 21:22:43 +01:00
Martin Hořeňovský
1887d42e3d
Use our PCG32 RNG instead of mt19937 in Benchmark::analyse_samples 2023-12-10 21:18:23 +01:00
Martin Hořeňovský
1774dbfd53
Make it clearer that the JSON reporter is WIP 2023-12-10 21:04:56 +01:00
Martin Hořeňovský
cb07ff9a7e
Fix uniform_floating_point_distribution for unit ranges 2023-12-10 19:53:46 +01:00
Martin Hořeňovský
ae4fe16b81
Make the user-facing random Generators reproducible
Thanks to the new distributions, this is almost trivial change.
2023-12-10 19:53:44 +01:00
Martin Hořeňovský
28c66fdc5a
Make uniform_floating_point_distribution reproducible
By moving to use our `uniform_integer_distribution`, which is
reproducible across different platforms, instead of the stdlib
one which is not, we can provide reproducible results for `float`s
and `double`s. Still no reproducibility for `long double`s, because
those are too different across different platforms.
2023-12-10 19:53:41 +01:00
Martin Hořeňovský
ed9d672b5c
Add uniform_integer_distribution 2023-12-10 19:53:39 +01:00
Martin Hořeňovský
04a829b0e1
Add helpers for implementing uniform integer distribution
* Utility for extended mult n x n bits -> 2n bits
* Utility to adapt output from URBG to target (unsigned) integral
  type
* Utility to reorder signed values into unsigned type while keeping
  the order.
2023-12-10 19:53:36 +01:00
Martin Hořeňovský
ab1b079e4d
Add uniform_floating_point_distribution 2023-12-10 18:44:12 +01:00
Martin Hořeňovský
d139b4ff7c
Add implementation of helpers for uniform float distribution
Specifically we add
 * `gamma(a, b)`, which returns the magnitude of largest 1-ULP
   step in range [a, b].
 * `count_equidistant_float(a, b, distance)`, which returns the
   number of equi-distant floats in range [a, b].
2023-12-10 18:44:10 +01:00
Martin Hořeňovský
bfd9f0f5a6
Move nextafter polyfill to polyfills.hpp 2023-12-10 18:44:06 +01:00
Martin Hořeňovský
9a1e73568c
Add test showing literals and complex generators in one GENERATE 2023-12-10 18:32:45 +01:00
Ikko Eltociear Ashimine
21d2da23bc Fix typo in tostring.md
specialiation -> specialization
2023-12-09 21:00:24 +01:00
Martin Hořeňovský
d1d7414eb9
Always run apt-get update before apt-get install
The base images for GitHub Actions are updated weekly, but
sometimes that is not enough to be able to install the packages
we require. The recommended fix for this is to always run
`apt-get update` before `apt-get install`.
2023-12-09 12:05:45 +01:00
Martin Hořeňovský
dacbf4fd6c
Drop VS 2017 support
We do not support specific compilers, but rather compilers with
reasonable quality of their C++14 support. While developing the
new random generators, I ran into issues with VS2017 where it
rejects perfectly valid C++14 code, **and** the error does not
point me in the right direction to try and work around the issue.

It is time for VS2017 to go.
2023-12-08 23:54:00 +01:00
Pablo Duboue
0520ff4436 [DOC] Replaced broken link (fixes #2770)
The original link is no longer available but a fork is still on GitHub.
2023-12-02 22:05:48 +01:00
SupSuper
4a7be16c8c Fix compilation on Xbox platforms
Xbox does not support getenv
2023-12-02 22:03:48 +01:00
Martin Hořeňovský
32d9ae24bc
JSONWriter deals in StringRefs instead of std::strings
Together with liberal use of `_sr` UDL to compile-time convert
string literals into StringRefs, this will reduce the number of
allocation and remove most of the strcpy calls inherent in
converting string lits into `std::string`s.
2023-11-17 09:54:03 +01:00
Sergei Iskakov
de7ba4e889 fn need to be in parenthesis
Otherwise intel c++ 19.1 cause an error
"expression preceding parentheses of apparent call must have (pointer-to-) function type CATCH2"
2023-11-16 12:33:35 +01:00
Martin Hořeňovský
733b901dd2
Fix special character escaping in JsonWriter 2023-11-14 23:35:22 +01:00
Beartama
7bf136b501
Add JSON reporter (#2706)
Co-authored-by: Martin Hořeňovský <martin.horenovsky@gmail.com>
2023-11-14 22:52:15 +01:00
Gerald Senarclens de Grancy
2c68a0d05f lifted suggested version
Did this, because with 3.0.1, the files
- catch_xmlwriter.cpp
- catch_string_manip.hpp
- catch_test_case_info.hpp

were missing

This led to some obvious and some obscure compile errors when compiling
with g++ 13.2.0 (std c++17 or c++20)
One of these errors being "Elaborated-type-specifier for a scoped enum
must not use the ‘class’ keyword"

Since this is a rather bad experience and debugging it is
time-consuming, I suggest to simply boost the recommended version in the
snippet which is likely copied by new Catch2 users
2023-11-14 17:10:31 +01:00
Krzysiek Karbowiak
01cac90c62
Bump up actions/checkout version to v4 (#2760) 2023-11-09 10:31:49 +01:00
Krzysiek Karbowiak
b735dfce2d
Increase build parallelism on macOS (#2759)
Co-authored-by: Martin Hořeňovský <martin.horenovsky@gmail.com>
2023-11-07 22:17:47 +01:00
Martin Hořeňovský
caffe79a31
Fix missing include in catch_message.hpp
Because the issue comes from the expansions of `UNSCOPED_INFO`,
surrogate TUs could not catch this bug, and in common usage, the
include transitively comes from `catch_test_macros.hpp`.

Fixes #2758
2023-11-04 00:33:18 +01:00
Chris Thrasher
a8cf3e6710 Mark CATCH_CONFIG_ options as advanced
These options are rather low-level and don't need to be seen in the
CMake cache unless you opt into seeing all other advanced options.

This removes a lot of cache entries from the screen when using a GUI
or TUI to view the cache thus making it easier for users to focus on
the cache variables they're more likely to change on a frequent
basis.
2023-10-31 17:27:46 -06:00
Martin Hořeňovský
79d39a1954
Fix tests for C++23's multi-arg index operator
Closes #2744
2023-10-28 21:49:58 +02:00
Martin Hořeňovský
6ebc013b8c
Fix UDL definitions for C++23
Technically, the declaration should not have a space between
the quotes and the underscore, because `_foo` is a reserved
identifier, but `""_foo` is not. In general it works, but newer
Clang versions warn about this, because WG21 wants to deprecate
and later remove this form completely.
2023-10-28 21:35:03 +02:00
Alex Merry
966d361551 Improve formatting of test specification docs
The existing formatting created one-element lists separated by paragraphs, when it would make more sense to have the paragraphs that are providing more information about one of those list entries be part of the list entry itself.

I think this makes the documentation easier to read in both markdown and html form, and should also improve the structure for assistive technologies.
2023-10-24 16:01:56 +02:00
Per Lundberg
766541d12d why-catch.md: Add JetBrains survey link 2023-09-27 20:14:35 +02:00
Holger Kaelberer
7b793314e5
Catch.cmake: Support CMake multi-config with PRE_TEST discovery mode (#2739)
Closes #2746 

---------

Co-authored-by: Holger Kaelberer <Holger.Kaelberer@bmw.de>
2023-09-25 19:40:35 +02:00
Christian Tacke
0fb817e41f fix some bugprone-macro-parentheses warnings
When using the public headers of catch2 in another project
that uses clang-tidy with some checks enabled, then some
warnings in catch2's headers are also reported.

This fixes a bunch of bugprone-macro-parentheses warnings.

See: https://clang.llvm.org/extra/clang-tidy/checks/bugprone/macro-parentheses.html
2023-09-25 10:56:45 +02:00
Martin Hořeňovský
f161110be4
Merge pull request #2747 from xandox/devel
correct argument references in CatchAddTests.cmake
2023-09-25 10:52:10 +02:00
Ilya Arzhannikov
db495acdbb
correct argument references in CatchAddTests.cmake 2023-09-20 15:47:11 +02:00
Martin Hořeňovský
9c541ca72e
Add test for multiple streaming parts in UNSCOPED_INFO 2023-09-17 10:44:31 +02:00
Martin Hořeňovský
92672591c1
Make jackknife TU-local to stats.cpp 2023-09-16 21:29:47 +02:00
Martin Hořeňovský
56fcd584c1
Make directCompare TU-local to stats.cpp 2023-09-16 21:18:44 +02:00
Jonathan Allen Grant
aafe09bc1c
Update meson.build to fix #2722 (#2742) 2023-09-13 10:06:14 +02:00
Martin Hořeňovský
47a2c96938
Reduce the number of templates in Benchmarking
The basic idea was to reduce the number of things dependent on the `Clock`
type. To that end, I replaced `Duration<Clock>` with `IDuration` typedef
for `std::nanoseconds`, and `FloatDuration<Clock>` with `FDuration`
typedef for `Duration<double, std::nano>`. We can generally assume that
any clock's duration can be expressed in nanoseconds, as long as we insert
`duration_cast`s into the right places.

Note that we cannot remove all dependence on `Clock` as a template
arguments, because functions that actually measure the elapsed time have
to use the Clock.

We also changed some template function arguments to pass plain function
pointers, so that the actual implementation can be placed into a cpp file.
2023-09-08 10:04:31 +02:00
Martin Hořeňovský
fb96279aed
Remove superfluous stdlib includes from catch_benchmark.hpp 2023-09-08 10:04:24 +02:00
Martin Hořeňovský
e14a08d734
Remove unused typedef from Benchmark::Environment 2023-09-08 10:04:22 +02:00
Martin Hořeňovský
9bba07cb87
Replace vector iterator args in benchmarks with ptr args 2023-09-08 10:04:19 +02:00
Martin Hořeňovský
b4ffba5087
Update sample output in docs/benchmarks.md 2023-09-08 10:04:17 +02:00
Martin Jeřábek
3a5cde55b7 implement stringify for std::nullopt_t 2023-08-30 16:21:02 +02:00
Martin Hořeňovský
2a19ae16b8
Rewrite commandline test spec docs
Closes #2738
2023-08-30 16:18:34 +02:00
Martin Hořeňovský
f24d39e42b
Support C arrays and ADL ranges in from_range generator
Closes #2737
2023-08-29 15:38:13 +02:00
Martin Hořeňovský
85eb4652b4
Add nice license headers to files in examples/ and fuzzing/
Related to #2730
2023-08-24 16:34:31 +02:00
Ryan Pavlik
5bba3e4038 Edited amalgamated file generator, to block REUSE from getting confused
It struggled with the copyright lines included as string literals.
2023-08-19 14:31:27 +02:00
Martin Hořeňovský
e09de7222c
Small cleanup in XML reporter 2023-08-14 12:41:52 +02:00