OSDN Git Service

b63903e8980a5d477d8fa916da4e8631259a9e11
[uclinux-h8/uclibc-ng.git] / test / assert / assert.c
1 /* vi: set sw=4 ts=4: */
2 /*
3  * Test application for functions defined in ctype.h
4  *
5  * Copyright (C) 2000 by Lineo, inc. and Erik Andersen
6  * Copyright (C) 2000,2001 by Erik Andersen <andersen@uclibc.org>
7  * Written by Erik Andersen <andersen@uclibc.org>
8  *
9  * This program is free software; you can redistribute it and/or modify it
10  * under the terms of the GNU Library General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or (at your
12  * option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful, but WITHOUT
15  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License
17  * for more details.
18  *
19  * You should have received a copy of the GNU Library General Public License
20  * along with this program; if not, write to the Free Software Foundation,
21  * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22  *
23  */
24
25 #include <stdio.h>
26 #include <stdlib.h>
27 #include <assert.h>
28 #include <signal.h>
29 #include "../testsuite.h"
30
31 int got_abort;
32
33 void aborthandler(int junk)
34 {
35         got_abort=1;
36 }
37
38 int main( int argc, char **argv)
39 {
40         signal(SIGABRT, aborthandler);
41         
42         init_testsuite("Testing functions defined in assert.h:\n\t");
43
44         got_abort=0;
45         assert(0==0);
46         TEST_NUMERIC(got_abort, 0);
47
48 #define  NDEBUG
49         got_abort=0;
50         printf("Don't worry -- This next test is supposed to print an assert message:\n");
51         fprintf(stderr, "\t");
52         assert(0==1);
53         TEST_NUMERIC(got_abort, 0);
54
55 #undef  NDEBUG
56         got_abort=0;
57         assert(0==1);
58         TEST_NUMERIC(got_abort, 1);
59
60         exit(0);
61 }