/***{{{******************************************************************* * This file is part of libco - object library for C * * Copyright (c) 2002 Peter Rockai (yenar) * * * * This program is free software; you can redistribute it and/or * * modify it under the terms of the GNU General Public * * License as published by the Free Software Foundation; either * * version 2 of the License, or (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * * General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; see the file COPYING. If not, write to * * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, * * Boston, MA 02111-1307, USA. * *******************************************************************}}}***/ /* {{{ file description */ /** \file libco_vector.c * \brief Test libco's vector object. */ /* }}} */ /* {{{ includes */ #include "co_exception.h" #include "test_util.h" /* }}} */ #include "exception.cometa" /* {{{ */ void testf (int i) { COX_RETHROW (i); } /* }}} */ /* {{{ */ int main (void) { int i; int handled = 0; void *test; co_super sup = co_init (); __co_file_init_exception_c (sup); //cox_init (); //libco_init (); for (i = 0; i < 100; i ++) { COX_TRY { COX_TRY { handled = 0; CO_DEBUG2 (2, "malloc...\n"); test = cox_malloc (1024 * 1024); testf (4); cox_del (test); CO_DEBUG2 (3, "ok: malloc\n"); } COX_CATCH (err) { CO_DEBUG (1, "got error %d", err); if (err != 4) error (1, "wrong error number!"); handled = 1; //printf ("1: error %d!\n", err); } COX_CATCH_END; if (! handled) error (2, "exception not handled!"); CO_DEBUG2 (2, "malloc2...\n"); test = cox_malloc (1024 * 1024); CO_DEBUG2 (3, "ok: malloc2\n"); cox_del (test); testf (3); COX_THROW (undef); } COX_CATCH (err) { CO_DEBUG (1, "got error %d", err); //printf ("2: error %d!\n", err); } COX_CATCH_END; } CO_M (sup, destroy, 0); return 0; } /* }}} */