blob: 9daf181bd763b8194a3f42543fb7eaa40320f049 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
// Copyright (c) 2026 Progmasoft.
// SPDX-License-Identifier: LGPL-3.0-or-later
#pragma once
#include <Progmasoft/Catch3/Generator.hpp>
namespace Progmasoft::Catch3 {
/// Generates booleans and shrinks true to the simplest value, false.
[[nodiscard]] inline Generator<bool> Boolean() {
return MakeGenerator<bool>(
[]( Random& random ) { return ( random.Next() & 1U ) != 0; },
[]( const bool& value ) {
return value ? std::vector<bool>{ false } : std::vector<bool>{};
} );
}
} // namespace Progmasoft::Catch3
|