Mercurial > hg > octave-lyh > gnulib-hg
changeset 9281:11622c689309
Test for __fpending function.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Wed, 03 Oct 2007 23:36:11 +0200 |
parents | a1f6fe4c68c1 |
children | 9a26e94f946a |
files | ChangeLog modules/fpending-tests tests/test-fpending.c |
diffstat | 3 files changed, 66 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2007-10-03 Bruno Haible <bruno@clisp.org> + + * tests/test-fpending.c: New file, mostly copied + from coreutils/lib/t-fpending.c. + * modules/fpending-tests: New file. + 2007-10-03 Bruno Haible <bruno@clisp.org> Port the stdio extensions to QNX (untested).
new file mode 100644 --- /dev/null +++ b/modules/fpending-tests @@ -0,0 +1,10 @@ +Files: +tests/test-fpending.c + +Depends-on: + +configure.ac: + +Makefile.am: +TESTS += test-fpending +check_PROGRAMS += test-fpending
new file mode 100644 --- /dev/null +++ b/tests/test-fpending.c @@ -0,0 +1,50 @@ +/* Ensure that __fpending works. + + Copyright (C) 2004, 2007 Free Software Foundation, Inc. + + 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 3 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. If not, see <http://www.gnu.org/licenses/>. + + Written by Jim Meyering. */ + +#include <config.h> + +#include "fpending.h" + +#include <stdio.h> +#include <stdlib.h> + +#define ASSERT(expr) \ + do \ + { \ + if (!(expr)) \ + { \ + fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \ + abort (); \ + } \ + } \ + while (0) + +int +main () +{ + ASSERT (__fpending (stdout) == 0); + + fputs ("foo", stdout); + ASSERT (__fpending (stdout) == 3); + + fflush (stdout); + ASSERT (__fpending (stdout) == 0); + + exit (0); +}