summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorDaiki Ueno <ueno@gnu.org>2020-05-27 08:14:44 +0200
committerDaiki Ueno <ueno@gnu.org>2020-05-27 14:14:00 +0200
commite4a38aadac2e90c6dfb317d0845746c200cf6697 (patch)
tree6ac9cb8b1f598dac5f9ccb36b7952cff3549b85f /tests
parente93bdf684a7ed2c9229c0f113e33dc639f1050d7 (diff)
downloadgnulib-e4a38aadac2e90c6dfb317d0845746c200cf6697.tar.gz
read-file: add flags to modify reading behavior
* lib/read-file.h (RF_BINARY): New define. (fread_file, read_file): Take FLAGS argument. (read_binary_file): Remove. * lib/read-file.c (internal_read_file): Merge into ... (read_file): ... here. * modules/read-file-tests (Files): Add "tests/macros.h". * tests/test-read-file.c (main): Refactor using ASSERT macro. * NEWS: Mention this change.
Diffstat (limited to 'tests')
-rw-r--r--tests/test-read-file.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/tests/test-read-file.c b/tests/test-read-file.c
index 930cf4acb0..84b9049940 100644
--- a/tests/test-read-file.c
+++ b/tests/test-read-file.c
@@ -23,11 +23,13 @@
#include <stdlib.h>
#include <sys/stat.h>
+#include "macros.h"
+
#define FILE1 "/etc/resolv.conf"
#define FILE2 "/dev/null"
int
-main (void)
+test_read_file (int flags)
{
struct stat statbuf;
int err = 0;
@@ -37,7 +39,7 @@ main (void)
if (stat (FILE1, &statbuf) >= 0)
{
size_t len;
- char *out = read_file (FILE1, &len);
+ char *out = read_file (FILE1, flags, &len);
if (!out)
{
@@ -80,7 +82,7 @@ main (void)
if (stat (FILE2, &statbuf) >= 0)
{
size_t len;
- char *out = read_file (FILE2, &len);
+ char *out = read_file (FILE2, flags, &len);
if (!out)
{
@@ -109,3 +111,12 @@ main (void)
return err;
}
+
+int
+main (void)
+{
+ ASSERT (!test_read_file (0));
+ ASSERT (!test_read_file (RF_BINARY));
+
+ return 0;
+}