MCPcopy Create free account
hub / github.com/Bareflank/hypervisor / tests

Function tests

loader/tests/src/test_alloc_mk_args.cpp:45–80  ·  view source on GitHub ↗

<!-- description --> @brief Used to execute the actual checks. We put the checks in this function so that we can validate the tests both at compile-time and at run-time. If a bsl::ut_check fails, the tests will either fail fast at run-time, or will produce a compile-time error. <!-- inputs/outputs --> @return Always returns bsl::exit_success.

Source from the content-addressed store, hash-verified

43 /// @return Always returns bsl::exit_success.
44 ///
45 [[nodiscard]] constexpr auto
46 tests() noexcept -> bsl::exit_code
47 {
48 helpers::init();
49 constexpr auto func{&alloc_mk_args};
50
51 bsl::ut_scenario{"success"} = [&]() noexcept {
52 bsl::ut_given{} = [&]() noexcept {
53 mk_args_t *pmut_mut_args{};
54 bsl::ut_then{} = [&]() noexcept {
55 helpers::ut_check(func(&pmut_mut_args));
56 };
57 bsl::ut_cleanup{} = [&]() noexcept {
58 free_mk_args(&pmut_mut_args);
59 helpers::reset();
60 };
61 };
62 };
63
64 bsl::ut_scenario{"platform_alloc fails"} = [&]() noexcept {
65 bsl::ut_given{} = [&]() noexcept {
66 mk_args_t *pmut_mut_args{};
67 bsl::ut_when{} = [&]() noexcept {
68 helpers::g_mut_platform_alloc = 1;
69 bsl::ut_then{} = [&]() noexcept {
70 helpers::ut_fails(func(&pmut_mut_args));
71 };
72 bsl::ut_cleanup{} = [&]() noexcept {
73 helpers::reset();
74 };
75 };
76 };
77 };
78
79 return helpers::fini();
80 }
81}
82
83/// <!-- description -->

Callers 1

mainFunction · 0.70

Calls 6

initFunction · 0.85
ut_checkFunction · 0.85
free_mk_argsFunction · 0.85
resetFunction · 0.85
ut_failsFunction · 0.85
finiFunction · 0.85

Tested by

no test coverage detected