kaycxx-test
C++ unit test framework
Loading...
Searching...
No Matches
assert_not_null.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 <optional>
12#include <source_location>
13#include <string_view>
14
16#include <kaycxx/test/detail/nullable.hpp>
17
18namespace kaycxx::test {
19
31template <detail::nullable T>
33 T const& actual,
34 std::string_view reason = {},
35 std::optional<std::source_location> location = std::source_location::current()
36) {
37 if (actual == nullptr) {
38 throw assertion_error("Expected <null> not to be null", reason, "null", "null", location);
39 }
40}
41
42} // namespace kaycxx::test
Defines the assertion_error type.
Unit test framework functions and types.
Definition test.hpp:15
void assert_not_null(T const &actual, std::string_view reason={}, std::optional< std::source_location > location=std::source_location::current())
Asserts that the argument is not null.
Definition assert_not_null.hpp:32