From 7cf4aa222ab5cbda4bf8a6ffc968a85304cc8333 Mon Sep 17 00:00:00 2001 From: Thomas Schmucker Date: Thu, 2 Jul 2020 09:12:20 +0200 Subject: csv-read() sollte bei Dateiende EOF liefern, statt -1. Damit wird der Clientcode lesbarer und verständlicher. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- csv-test.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'csv-test.c') diff --git a/csv-test.c b/csv-test.c index c5152ea..552bbb8 100644 --- a/csv-test.c +++ b/csv-test.c @@ -39,7 +39,7 @@ test_line_endings1(void) assert( strcmp(csv_field(&csv, 1), "E") == 0 ); assert( strcmp(csv_field(&csv, 2), "F") == 0 ); - assert( csv_read(&csv, f) == -1 ); + assert( csv_read(&csv, f) == EOF ); FMEMCLOSE(f); } @@ -67,7 +67,7 @@ test_line_endings2(void) assert( strcmp(csv_field(&csv, 1), "E") == 0 ); assert( strcmp(csv_field(&csv, 2), "F") == 0 ); - assert( csv_read(&csv, f) == -1 ); + assert( csv_read(&csv, f) == EOF ); FMEMCLOSE(f); } @@ -216,7 +216,7 @@ test_empty_fields(void) assert( strcmp(csv_field(&csv, 2), "") == 0 ); // EOF - assert( csv_read(&csv, f) == -1 ); + assert( csv_read(&csv, f) == EOF ); FMEMCLOSE(f); } @@ -365,7 +365,7 @@ test_simple_fields(void) assert( strcmp(csv_field(&csv, 2), "C") == 0 ); // EOF - assert( csv_read(&csv, f) == -1 ); + assert( csv_read(&csv, f) == EOF ); FMEMCLOSE(f); } @@ -388,7 +388,7 @@ test_quoted_fields(void) assert( strcmp(csv_field(&csv, 3), "foo \"baz\" bar") == 0 ); assert( strcmp(csv_field(&csv, 4), "foo \"baz\", bar") == 0 ); - assert( csv_read(&csv, f) == -1 ); + assert( csv_read(&csv, f) == EOF ); FMEMCLOSE(f); } @@ -407,7 +407,7 @@ test_wrong_quoted_field(void) assert( csv_nfields(&csv) == 1 ), assert( strcmp(csv_field(&csv, 0), "foo") == 0 ); - assert( csv_read(&csv, f) == -1 ); + assert( csv_read(&csv, f) == EOF ); FMEMCLOSE(f); } @@ -471,7 +471,7 @@ test_read_error(void) switch ( setjmp(env) ) { case CSV_ERR_OK: - assert( csv_read(&csv, f) == -1 ); + assert( csv_read(&csv, f) == EOF ); break; case CSV_ERR_IO_READ: -- cgit v1.3