Read-only mirrors. Development, issues and pull requests are on GitHub.

summaryrefslogtreecommitdiffhomepage
path: root/src/Progmasoft/Catch3/Generators/Boolean.hpp
blob: 3f88192728d448a12666fe371f90db83489a62e0 (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: MPL-2.0 WITH AdditionRef-Progmasoft-Exception-1.1
#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