<!-- 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_x64(); |
| 50 | constexpr auto func{&alloc_pt}; |
| 51 | |
| 52 | bsl::ut_scenario{"success"} = [&]() noexcept { |
| 53 | bsl::ut_given{} = [&]() noexcept { |
| 54 | pdt_t mut_pdt{}; |
| 55 | bsl::ut_when{} = [&]() noexcept { |
| 56 | bsl::ut_then{} = [&]() noexcept { |
| 57 | bsl::ut_check(nullptr != func(&mut_pdt, {})); |
| 58 | }; |
| 59 | bsl::ut_cleanup{} = [&]() noexcept { |
| 60 | free_pdt(&mut_pdt); |
| 61 | helpers::reset_x64(); |
| 62 | }; |
| 63 | }; |
| 64 | }; |
| 65 | }; |
| 66 | |
| 67 | bsl::ut_scenario{"already present"} = [&]() noexcept { |
| 68 | bsl::ut_given{} = [&]() noexcept { |
| 69 | pdt_t mut_pdt{}; |
| 70 | bsl::ut_when{} = [&]() noexcept { |
| 71 | mut_pdt.entires[0].p = bsl::safe_u64::magic_1().get(); |
| 72 | bsl::ut_then{} = [&]() noexcept { |
| 73 | bsl::ut_check(nullptr == func(&mut_pdt, {})); |
| 74 | }; |
| 75 | bsl::ut_cleanup{} = [&]() noexcept { |
| 76 | helpers::reset_x64(); |
| 77 | }; |
| 78 | }; |
| 79 | }; |
| 80 | }; |
| 81 | |
| 82 | bsl::ut_scenario{"platform_alloc fails"} = [&]() noexcept { |
| 83 | bsl::ut_given{} = [&]() noexcept { |
| 84 | pdt_t mut_pdt{}; |
| 85 | bsl::ut_when{} = [&]() noexcept { |
| 86 | helpers::g_mut_platform_alloc = 1; |
| 87 | bsl::ut_then{} = [&]() noexcept { |
| 88 | bsl::ut_check(nullptr == func(&mut_pdt, {})); |
| 89 | }; |
| 90 | bsl::ut_cleanup{} = [&]() noexcept { |
| 91 | helpers::reset_x64(); |
| 92 | }; |
| 93 | }; |
| 94 | }; |
| 95 | }; |
| 96 | |
| 97 | bsl::ut_scenario{"platform_virt_to_phys fails"} = [&]() noexcept { |
| 98 | bsl::ut_given{} = [&]() noexcept { |
| 99 | pdt_t mut_pdt{}; |
| 100 | bsl::ut_when{} = [&]() noexcept { |
| 101 | helpers::g_mut_platform_virt_to_phys = 1; |
| 102 | bsl::ut_then{} = [&]() noexcept { |
| 103 | bsl::ut_check(nullptr == func(&mut_pdt, {})); |