os/ossrv/genericopenlibs/cppstdlib/test/runtime/src/uncaught_exception_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        : uncaught_exception_test.cpp
    15 // Part of     : standard c++ tests.
    16 // 
    17 //
    18 
    19 #include <exception>
    20 #include "test_decls.h"
    21 #include <cstddef>
    22 
    23 int glob_val = 0;
    24 class UserClass{
    25 public:
    26 	~UserClass(){
    27 		// This object is destroyed before the exception is caught.
    28 		bool uc = std::uncaught_exception();
    29 		if(uc == true)
    30 			glob_val = 1;
    31 	}
    32 };
    33 
    34 void foo() {
    35 
    36 	UserClass uc;
    37 	throw int (0);
    38 }
    39 int main()
    40 {
    41 	try{
    42 	foo();
    43 	}catch(...){
    44 	}
    45 	CPP_TESTS_ASSERT_ALLWAYS(glob_val == 1);
    46 	return 0;
    47 }
    48