kaycxx-test
C++ unit test framework
Loading...
Searching...
No Matches
kaycxx
test
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
15
#include <
kaycxx/test/assertion_error.hpp
>
16
#include <kaycxx/test/detail/nullable.hpp>
17
18
namespace
kaycxx::test
{
19
31
template
<detail::nullable T>
32
void
assert_not_null
(
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
assertion_error.hpp
Defines the assertion_error type.
kaycxx::test
Unit test framework functions and types.
Definition
test.hpp:15
kaycxx::test::assert_not_null
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
Generated by
1.9.8