<!-- 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.
| 44 | /// @return Always returns bsl::exit_success. |
| 45 | /// |
| 46 | [[nodiscard]] constexpr auto |
| 47 | tests() noexcept -> bsl::exit_code |
| 48 | { |
| 49 | helpers::init(); |
| 50 | constexpr auto func{&alloc_mk_page_pool}; |
| 51 | |
| 52 | bsl::ut_scenario{"success"} = [&]() noexcept { |
| 53 | bsl::ut_given{} = [&]() noexcept { |
| 54 | mutable_span_t mut_pool{}; |
| 55 | bsl::ut_then{} = [&]() noexcept { |
| 56 | helpers::ut_check(func({}, &mut_pool)); |
| 57 | }; |
| 58 | bsl::ut_cleanup{} = [&]() noexcept { |
| 59 | free_mk_page_pool(&mut_pool); |
| 60 | helpers::reset(); |
| 61 | }; |
| 62 | }; |
| 63 | }; |
| 64 | |
| 65 | bsl::ut_scenario{"success with pages set"} = [&]() noexcept { |
| 66 | bsl::ut_given{} = [&]() noexcept { |
| 67 | mutable_span_t mut_pool{}; |
| 68 | constexpr auto pages{5_u32}; |
| 69 | bsl::ut_then{} = [&]() noexcept { |
| 70 | helpers::ut_check(func(pages.get(), &mut_pool)); |
| 71 | }; |
| 72 | bsl::ut_cleanup{} = [&]() noexcept { |
| 73 | free_mk_page_pool(&mut_pool); |
| 74 | helpers::reset(); |
| 75 | }; |
| 76 | }; |
| 77 | }; |
| 78 | |
| 79 | bsl::ut_scenario{"platform_alloc fails"} = [&]() noexcept { |
| 80 | bsl::ut_given{} = [&]() noexcept { |
| 81 | mutable_span_t mut_pool{}; |
| 82 | bsl::ut_when{} = [&]() noexcept { |
| 83 | helpers::g_mut_platform_alloc = 1; |
| 84 | bsl::ut_then{} = [&]() noexcept { |
| 85 | helpers::ut_fails(func({}, &mut_pool)); |
| 86 | }; |
| 87 | bsl::ut_cleanup{} = [&]() noexcept { |
| 88 | helpers::reset(); |
| 89 | }; |
| 90 | }; |
| 91 | }; |
| 92 | }; |
| 93 | |
| 94 | return helpers::fini(); |
| 95 | } |
| 96 | } |
| 97 | |
| 98 | /// <!-- description --> |