Arene Base
Fundamental Utilities For Safety Critical C++
Loading...
Searching...
No Matches
property_summary.hpp
Go to the documentation of this file.
1// Copyright 2026, Toyota Motor Corporation
2//
3// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
4
5#ifndef INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_TESTING_PROPERTY_SUMMARY_HPP_
6#define INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_TESTING_PROPERTY_SUMMARY_HPP_
7
10#include "arene/base/stdlib_choice/cstddef.hpp"
11#include "arene/base/stdlib_choice/cstdint.hpp"
13// IWYU pragma: no_include "testlibs/minitest/assertion_strings.hpp"
14// IWYU pragma: no_include "testlibs/minitest/source_location.hpp"
15
16namespace arene {
17namespace base {
18namespace testing {
19
20/// @brief result of a property run
21///
22/// Aggregates the statistics gathered during a property run along with
23/// the first counterexample encountered, if any.
27 bool failed;
30
31 /// @brief stream a human-readable report of a @c property_summary
32 /// @tparam Ostream output stream type supporting @c operator<< for strings,
33 /// integers, and booleans
34 /// @param out destination stream
35 /// @param summary the summary to format
36 /// @return reference to @c out, to support chaining
37 ///
38 /// @attention Output formatting may change at any time. If consistent output
39 /// formatting is needed, please implement a newtype formatter.
40 template <class Ostream, constraints<typename Ostream::char_type, typename Ostream::traits_type> = nullptr>
41 friend constexpr auto operator<<(Ostream& out, property_summary const& summary) -> Ostream& {
42 out //
43 << "PROPERTY " << (summary.failed ? "FAIL" : "PASS") //
44 << "\nseed: " << summary.seed //
45 << "\nsuccesses: " << summary.successes //
46 << "\ndiscards: " << summary.discards;
47
48 if (summary.failed) {
49 if (summary.first_failure.has_value()) {
50 auto const& error = *summary.first_failure;
51 out << "\nproperty not satisfied [" << error.location.file << ":" << error.location.line //
52 << "]\nARENE_PROP_ASSERT(" << error.strings.arg1 << ")";
53 } else {
54 out << "\nreached max discards";
55 }
56 }
57
58 return out;
59 }
60};
61
62} // namespace testing
63} // namespace base
64} // namespace arene
65#endif // INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_TESTING_PROPERTY_SUMMARY_HPP_
Implementation of std::optional for pre-C++17 compilers, and which replaces defined undefined behavio...
Definition optional.hpp:122
Definition customization.hpp:31
Definition accumulate.hpp:37
Definition accumulate.hpp:36
::size_t size_t
A type suitable for holding the size of an object.
Definition cstddef.hpp:29
::uint64_t uint64_t
A 64-bit unsigned integer type.
Definition cstdint.hpp:47
result of a property run
Definition property_summary.hpp:24
std::size_t successes
Definition property_summary.hpp:25
optional< property_error > first_failure
Definition property_summary.hpp:29
std::uint64_t seed
Definition property_summary.hpp:28
std::size_t discards
Definition property_summary.hpp:26
bool failed
Definition property_summary.hpp:27
friend constexpr auto operator<<(Ostream &out, property_summary const &summary) -> Ostream &
stream a human-readable report of a property_summary
Definition property_summary.hpp:41