infallible_new_false.cpp 399 B

123456789101112131415161718192021222324
  1. #include <memory>
  2. #include "test/jemalloc_test.h"
  3. TEST_BEGIN(test_failing_alloc) {
  4. bool saw_exception = false;
  5. try {
  6. /* Too big of an allocation to succeed. */
  7. void *volatile ptr = ::operator new((size_t)-1);
  8. (void)ptr;
  9. } catch (...) {
  10. saw_exception = true;
  11. }
  12. expect_true(saw_exception, "Didn't get a failure");
  13. }
  14. TEST_END
  15. int
  16. main(void) {
  17. return test(
  18. test_failing_alloc);
  19. }