os/ossrv/genericopenlibs/cppstdlib/test/runtime/src/oper_new_test.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     4 // under the terms of "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 // Name        : oper_new_test.cpp
    15 // Part of     : standard c++ tests.
    16 // 
    17 //
    18 
    19 #include <e32std.h>
    20 
    21 #include <new>
    22 #include "test_decls.h"
    23 
    24 #define ONE_HUGE_VALUE	0xA00000
    25 
    26 int glob_val = 0;
    27 
    28 int* bar()
    29 {
    30 	User::__DbgSetBurstAllocFail(EFalse, RAllocator::EBurstFailNext, 1, KMaxTUint16);
    31 	int *ptr = new int[ONE_HUGE_VALUE];
    32 	return ptr;
    33 }
    34 
    35 int main()
    36 {
    37 		int *ptr;
    38 	try {
    39 		while( (ptr = bar()) != NULL) {
    40 			ptr = bar();
    41 		}
    42 	}catch(std::bad_alloc ba) {
    43 		glob_val = 1;
    44 	}
    45 	catch(...){
    46 	}
    47 
    48 	ptr = ptr;
    49 	CPP_TESTS_ASSERT_ALLWAYS( glob_val == 1);
    50 
    51 	return 0;
    52 }