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