|
8 | 8 | #include <cstddef> |
9 | 9 | #include <cstring> |
10 | 10 |
|
| 11 | +namespace { |
11 | 12 | bool fail{}; |
12 | 13 |
|
| 14 | +} |
| 15 | + |
| 16 | +// NOLINTNEXTLINE(hicpp-no-malloc) |
13 | 17 | auto operator new(::std::size_t size) -> void* { return fail ? throw ::std::bad_alloc() : ::std::malloc(size); } |
14 | 18 |
|
15 | | -auto operator delete(void* ptr) noexcept -> void { ::std::free(ptr); } |
16 | | -auto operator delete(void* ptr, ::std::size_t) noexcept -> void { ::std::free(ptr); } |
| 19 | +auto operator delete(void* ptr) noexcept -> void { ::std::free(ptr); } // NOLINT(hicpp-no-malloc) |
| 20 | +auto operator delete(void* ptr, ::std::size_t) noexcept -> void { ::std::free(ptr); } // NOLINT(hicpp-no-malloc) |
17 | 21 |
|
18 | 22 | TEST(stopsource_cons) { |
19 | 23 | // Reference: [stopsource.cons] p1 |
20 | 24 | ::test_std::stop_source source; |
21 | | - ASSERT(source.stop_possible()); |
22 | | - ASSERT((not source.stop_requested())); |
| 25 | + try { |
| 26 | + ASSERT(source.stop_possible()); |
| 27 | + ASSERT((not source.stop_requested())); |
| 28 | + } catch (...) { |
| 29 | + ASSERT(nullptr == "can't be reached"); // NOLINT(cert-dcl03-c,hicpp-static-assert,misc-static-assert) |
| 30 | + } |
23 | 31 |
|
24 | 32 | // Reference: [stopsource.cons] p3 |
25 | 33 | fail = true; |
26 | 34 | try { |
27 | | - ::test_std::stop_source(); |
28 | | - ASSERT(nullptr == "can't be reached"); |
| 35 | + ::test_std::stop_source source{}; |
| 36 | + test::use(source); |
| 37 | + ASSERT(nullptr == "can't be reached"); // NOLINT(cert-dcl03-c,hicpp-static-assert,misc-static-assert) |
29 | 38 | } catch (const ::std::bad_alloc&) { |
30 | | - ASSERT(nullptr != "bad_alloc was thrown"); |
| 39 | + ASSERT(nullptr != "bad_alloc was thrown"); // NOLINT(cert-dcl03-c,hicpp-static-assert,misc-static-assert) |
| 40 | + } catch (...) { |
| 41 | + ASSERT(nullptr == "can't be reached"); // NOLINT(cert-dcl03-c,hicpp-static-assert,misc-static-assert) |
31 | 42 | } |
32 | 43 | } |
0 commit comments