From 7573ff58ab24b5f6cbcec41ef7a0e31de81c2135 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Fri, 9 Mar 2007 00:55:00 +0000 Subject: [PATCH] Tests for module 'fseterr'. --- ChangeLog | 3 +++ modules/fseterr-tests | 11 +++++++++++ tests/test-fseterr.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 59 insertions(+) create mode 100644 modules/fseterr-tests create mode 100644 tests/test-fseterr.c diff --git a/ChangeLog b/ChangeLog index 8b308c17b..9fcb2f9b2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2007-03-08 Bruno Haible + * modules/fseterr-tests: New file. + * tests/test-fseterr.c: New file. + * modules/fseterr: New file. * lib/fseterr.h: New file. * lib/fseterr.c: New file. diff --git a/modules/fseterr-tests b/modules/fseterr-tests new file mode 100644 index 000000000..ce2332f4c --- /dev/null +++ b/modules/fseterr-tests @@ -0,0 +1,11 @@ +Files: +tests/test-fseterr.c + +Depends-on: + +configure.ac: + +Makefile.am: +TESTS += test-fseterr +check_PROGRAMS += test-fseterr + diff --git a/tests/test-fseterr.c b/tests/test-fseterr.c new file mode 100644 index 000000000..966b2f9d5 --- /dev/null +++ b/tests/test-fseterr.c @@ -0,0 +1,45 @@ +/* Test setting the error indicator of a stream. + Copyright (C) 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 2, 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, write to the Free Software Foundation, + Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ + +/* Written by Bruno Haible , 2007. */ + +#include + +#include "fseterr.h" + +#include +#include + +int +main () +{ + /* All streams are initially created with the error indicator cleared. */ + if (ferror (stdout)) + abort (); + + /* Verify that fseterr() works. */ + fseterr (stdout); + if (!ferror (stdout)) + abort (); + + /* Verify fseterr's effect can be undone by clearerr(). */ + clearerr (stdout); + if (ferror (stdout)) + abort (); + + return 0; +} -- 2.11.0