sl@0: // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0: // All rights reserved.
sl@0: // This component and the accompanying materials are made available
sl@0: // under the terms of "Eclipse Public License v1.0"
sl@0: // which accompanies this distribution, and is available
sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0: //
sl@0: // Initial Contributors:
sl@0: // Nokia Corporation - initial contribution.
sl@0: //
sl@0: // Contributors:
sl@0: //
sl@0: // Description:
sl@0: // Name        : oper_new_test.cpp
sl@0: // Part of     : standard c++ tests.
sl@0: // 
sl@0: //
sl@0: 
sl@0: #include <e32std.h>
sl@0: 
sl@0: #include <new>
sl@0: #include "test_decls.h"
sl@0: 
sl@0: #define ONE_HUGE_VALUE	0xA00000
sl@0: 
sl@0: int glob_val = 0;
sl@0: 
sl@0: int* bar()
sl@0: {
sl@0: 	User::__DbgSetBurstAllocFail(EFalse, RAllocator::EBurstFailNext, 1, KMaxTUint16);
sl@0: 	int *ptr = new int[ONE_HUGE_VALUE];
sl@0: 	return ptr;
sl@0: }
sl@0: 
sl@0: int main()
sl@0: {
sl@0: 		int *ptr;
sl@0: 	try {
sl@0: 		while( (ptr = bar()) != NULL) {
sl@0: 			ptr = bar();
sl@0: 		}
sl@0: 	}catch(std::bad_alloc ba) {
sl@0: 		glob_val = 1;
sl@0: 	}
sl@0: 	catch(...){
sl@0: 	}
sl@0: 
sl@0: 	ptr = ptr;
sl@0: 	CPP_TESTS_ASSERT_ALLWAYS( glob_val == 1);
sl@0: 
sl@0: 	return 0;
sl@0: }