kaycxx-test
C++ unit test framework
Loading...
Searching...
No Matches
assert_greater.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 <format>
12#include <optional>
13#include <source_location>
14#include <string_view>
15#include <utility>
16
18#include <kaycxx/test/detail/ordered_value.hpp>
19#include <kaycxx/test/detail/to_string.hpp>
20
21namespace kaycxx::test {
22
38template <detail::ordered_value T>
40 T const& actual,
41 T const& expected,
42 std::string_view reason = {},
43 std::optional<std::source_location> location = std::source_location::current()
44) {
45 if (!(actual > expected)) {
46 auto actual_string = detail::to_string(actual);
47 auto expected_string = detail::to_string(expected);
48 auto message = std::format("Expected <{}> to be greater than <{}>", actual_string, expected_string);
49 throw assertion_error(
50 message,
51 reason,
52 std::move(actual_string),
53 std::move(expected_string),
54 location
55 );
56 }
57}
58
59} // namespace kaycxx::test
Defines the assertion_error type.
Unit test framework functions and types.
Definition test.hpp:15
void assert_greater(T const &actual, T const &expected, std::string_view reason={}, std::optional< std::source_location > location=std::source_location::current())
Asserts that the actual value is greater than the expected value.
Definition assert_greater.hpp:39