| 1 | /* |
| 2 | the DASM macro assembler (aka small systems cross assembler) |
| 3 | |
| 4 | Copyright (c) 1988-2002 by Matthew Dillon. |
| 5 | Copyright (c) 1995 by Olaf "Rhialto" Seibert. |
| 6 | Copyright (c) 2003-2008 by Andrew Davie. |
| 7 | Copyright (c) 2008 by Peter H. Froehlich. |
| 8 | |
| 9 | This program is free software; you can redistribute it and/or modify |
| 10 | it under the terms of the GNU General Public License as published by |
| 11 | the Free Software Foundation; either version 2 of the License, or |
| 12 | (at your option) any later version. |
| 13 | |
| 14 | This program is distributed in the hope that it will be useful, |
| 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 17 | GNU General Public License for more details. |
| 18 | |
| 19 | You should have received a copy of the GNU General Public License along |
| 20 | with this program; if not, write to the Free Software Foundation, Inc., |
| 21 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 22 | */ |
| 23 | |
| 24 | /** |
| 25 | * @file |
| 26 | * @brief Unit tests for errors module. |
| 27 | * @todo how do we keep panic* from aborting while unit test |
| 28 | * runs? or maybe it doesn't matter if we switch to Check? |
| 29 | */ |
| 30 | |
| 31 | #include "errors.h" |
| 32 | |
| 33 | #include "asm.h" |
| 34 | #include "util.h" |
| 35 | |
| 36 | #include <assert.h> |
| 37 | #include <stdlib.h> |
| 38 | #include <string.h> |
| 39 | |
| 40 | /* fakes for unit test */ |
| 41 | FILE *FI_listfile = NULL; |
| 42 | char *F_listfile = NULL; |
| 43 | INCFILE *pIncfile = NULL; |
| 44 | |
| 45 | int main(int argc, char *argv[]) |
| 46 | { |
| 47 | assert(argc == 1); |
| 48 | setprogname(argv[0]); |
| 49 | /* fake a current file */ |
| 50 | pIncfile = malloc(sizeof(INCFILE)); |
| 51 | pIncfile->next = NULL; |
| 52 | pIncfile->name = checked_strdup("someFileName"); |
| 53 | pIncfile->lineno = 47; |
| 54 | /* enable all messages */ |
| 55 | set_error_level(ERRORLEVEL_DEBUG); |
| 56 | /* test SUPER new API :-) */ |
| 57 | debug_fmt(WARNING_RANGE, "CRAZY", "DEBUG", 2, 14); |
| 58 | info_fmt(WARNING_RANGE, "CRAZY", "DEBUG", 2, 14); |
| 59 | notice_fmt(WARNING_RANGE, "CRAZY", "DEBUG", 2, 14); |
| 60 | warning_fmt(WARNING_RANGE, "CRAZY", "DEBUG", 2, 14); |
| 61 | error_fmt(WARNING_RANGE, "CRAZY", "DEBUG", 2, 14); |
| 62 | fatal_fmt(WARNING_RANGE, "CRAZY", "FATAL", 2, 14); |
| 63 | panic_fmt(WARNING_RANGE, "CRAZY", "DEBUG", 2, 14); |
| 64 | return EXIT_SUCCESS; |
| 65 | } |
| 66 | |
| 67 | /* vim: set tabstop=4 softtabstop=4 expandtab shiftwidth=4 autoindent: */ |