assert.c 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. #include <stdio.h>
  25. #include <stdlib.h>
  26. #include <assert.h>
  27. #include <signal.h>
  28. #include "../testsuite.h"
  29. int got_abort;
  30. void aborthandler(int junk)
  31. {
  32. got_abort=1;
  33. }
  34. int main( int argc, char **argv)
  35. {
  36. signal(SIGABRT, aborthandler);
  37. init_testsuite("Testing functions defined in assert.h:\n\t");
  38. got_abort=0;
  39. assert(0==0);
  40. TEST_NUMERIC(got_abort, 0);
  41. #define NDEBUG
  42. got_abort=0;
  43. printf("Don't worry -- This next test is supposed to print an assert message:\n");
  44. fprintf(stderr, "\t");
  45. assert(0==1);
  46. TEST_NUMERIC(got_abort, 0);
  47. #undef NDEBUG
  48. got_abort=0;
  49. assert(0==1);
  50. TEST_NUMERIC(got_abort, 1);
  51. exit(0);
  52. }