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 : uncaught_exception_test.cpp sl@0: // Part of : standard c++ tests. sl@0: // sl@0: // sl@0: sl@0: #include sl@0: #include "test_decls.h" sl@0: #include sl@0: sl@0: int glob_val = 0; sl@0: class UserClass{ sl@0: public: sl@0: ~UserClass(){ sl@0: // This object is destroyed before the exception is caught. sl@0: bool uc = std::uncaught_exception(); sl@0: if(uc == true) sl@0: glob_val = 1; sl@0: } sl@0: }; sl@0: sl@0: void foo() { sl@0: sl@0: UserClass uc; sl@0: throw int (0); sl@0: } sl@0: int main() sl@0: { sl@0: try{ sl@0: foo(); sl@0: }catch(...){ sl@0: } sl@0: CPP_TESTS_ASSERT_ALLWAYS(glob_val == 1); sl@0: return 0; sl@0: } sl@0: