assert.c 968 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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. * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
  10. */
  11. #include <stdio.h>
  12. #include <stdlib.h>
  13. #include <assert.h>
  14. #include <signal.h>
  15. #include "../testsuite.h"
  16. int got_abort;
  17. void aborthandler(int junk)
  18. {
  19. got_abort=1;
  20. }
  21. int main( int argc, char **argv)
  22. {
  23. signal(SIGABRT, aborthandler);
  24. init_testsuite("Testing functions defined in assert.h:\n\t");
  25. got_abort=0;
  26. assert(0==0);
  27. TEST_NUMERIC(got_abort, 0);
  28. #define NDEBUG
  29. got_abort=0;
  30. printf("Don't worry -- This next test is supposed to print an assert message:\n");
  31. fprintf(stderr, "\t");
  32. assert(0==1);
  33. TEST_NUMERIC(got_abort, 0);
  34. #undef NDEBUG
  35. got_abort=0;
  36. assert(0==1);
  37. TEST_NUMERIC(got_abort, 1);
  38. exit(0);
  39. }