kaycxx-test
C++ unit test framework
Loading...
Searching...
No Matches
skip.hpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2026 Klaus Reimer <k@ailis.de>
2// SPDX-License-Identifier: MIT
3
4#pragma once
5
11#include <functional>
12#include <string>
13#include <string_view>
14
15namespace kaycxx::test {
16
21public:
27 explicit skip_condition(std::string_view reason = "");
28
35 skip_condition(std::move_only_function<bool()> condition, std::string_view reason = "");
36
43
49 std::string const& reason() const noexcept;
50
51private:
53 std::move_only_function<bool()> condition_;
54
56 std::string reason_;
57};
58
65skip_condition skip(std::string_view reason = "");
66
74skip_condition skip_if(std::move_only_function<bool()> condition, std::string_view reason = "");
75
83skip_condition skip_unless(std::move_only_function<bool()> condition, std::string_view reason = "");
84
85} // namespace kaycxx::test
Condition used by a test case to decide whether it should be skipped before running hooks and test co...
Definition skip.hpp:20
skip_condition(std::move_only_function< bool()> condition, std::string_view reason="")
Creates a dynamic skip condition.
bool should_skip()
Checks if the test should be skipped.
std::string const & reason() const noexcept
Returns the skip reason.
skip_condition(std::string_view reason="")
Creates a condition that always skips the test.
Unit test framework functions and types.
Definition test.hpp:15
skip_condition skip_unless(std::move_only_function< bool()> condition, std::string_view reason="")
Creates a condition that skips the test unless the callback returns true.
skip_condition skip_if(std::move_only_function< bool()> condition, std::string_view reason="")
Creates a condition that skips the test when the callback returns true.
skip_condition skip(std::string_view reason="")
Creates a condition that always skips the test.