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