]> Kevux Git Server - fll/commitdiff
Bugfix: The FILE type may not have a known storage size and use F_type_output_d.
authorKevin Day <thekevinday@gmail.com>
Mon, 25 Apr 2022 00:52:48 +0000 (19:52 -0500)
committerKevin Day <thekevinday@gmail.com>
Mon, 25 Apr 2022 01:59:44 +0000 (20:59 -0500)
Instantiate it as a pointer instead given that it is possible in this case.

Use F_type_output_d instead of "stdout".

13 files changed:
level_0/f_conversion/tests/unit/c/test-conversion-number_signed_print.c
level_0/f_conversion/tests/unit/c/test-conversion-number_unsigned_print.c
level_0/f_file/tests/unit/c/test-file-stream_close.c
level_0/f_file/tests/unit/c/test-file-stream_open.c
level_0/f_file/tests/unit/c/test-file-stream_read.c
level_0/f_file/tests/unit/c/test-file-stream_read_block.c
level_0/f_file/tests/unit/c/test-file-stream_read_until.c
level_0/f_file/tests/unit/c/test-file-stream_reopen.c
level_0/f_file/tests/unit/c/test-file-stream_write.c
level_0/f_file/tests/unit/c/test-file-stream_write_block.c
level_0/f_file/tests/unit/c/test-file-stream_write_range.c
level_0/f_file/tests/unit/c/test-file-stream_write_until.c
level_3/fake/c/private-clean.c

index c2c79e6a612198fa74e0396911d0c97ee376a112..a7530e5c36c721d1636020989e1edb862684986f 100644 (file)
@@ -13,7 +13,7 @@ void test__f_conversion_number_signed_print__fails(void **state) {
     will_return(__wrap_fwrite_unlocked, true);
     will_return(__wrap_fwrite_unlocked, 0);
 
-    const f_status_t status = f_conversion_number_signed_print(1, data, stdout);
+    const f_status_t status = f_conversion_number_signed_print(1, data, F_type_output_d);
 
     assert_int_equal(F_status_set_fine(status), F_output);
   }
@@ -27,7 +27,7 @@ void test__f_conversion_number_signed_print__fails_for_prepend(void **state) {
     will_return(__wrap_fwrite_unlocked, true);
     will_return(__wrap_fwrite_unlocked, 0);
 
-    const f_status_t status = f_conversion_number_signed_print(1, data, stdout);
+    const f_status_t status = f_conversion_number_signed_print(1, data, F_type_output_d);
 
     assert_int_equal(F_status_set_fine(status), F_output);
   }
@@ -41,7 +41,7 @@ void test__f_conversion_number_signed_print__fails_for_zero(void **state) {
     will_return(__wrap_fwrite_unlocked, true);
     will_return(__wrap_fwrite_unlocked, 0);
 
-    const f_status_t status = f_conversion_number_signed_print(0, data, stdout);
+    const f_status_t status = f_conversion_number_signed_print(0, data, F_type_output_d);
 
     assert_int_equal(F_status_set_fine(status), F_output);
   }
@@ -59,10 +59,10 @@ void test__f_conversion_number_signed_print__fails_for_zero(void **state) {
     }
 
     {
-      FILE file;
+      FILE *file = 0;
       const f_conversion_data_t data = macro_f_conversion_data_t_initialize(1, 0, 0);
 
-      const f_status_t status = f_conversion_number_signed_print(0, data, &file);
+      const f_status_t status = f_conversion_number_signed_print(0, data, file);
 
       assert_int_equal(F_status_set_fine(status), F_parameter);
     }
@@ -74,7 +74,7 @@ void test__f_conversion_number_signed_print__works(void **state) {
   {
     const f_conversion_data_t data = macro_f_conversion_data_t_initialize(10, 0, 0);
 
-    const f_status_t status = f_conversion_number_signed_print(1, data, stdout);
+    const f_status_t status = f_conversion_number_signed_print(1, data, F_type_output_d);
 
     will_return(__wrap_fwrite_unlocked, false);
 
index 2beaf7b255818aca39a48407946231c2e2e233fe..e66222389fd342a013d87e85bb47ae228cb645bb 100644 (file)
@@ -13,7 +13,7 @@ void test__f_conversion_number_unsigned_print__fails(void **state) {
     will_return(__wrap_fwrite_unlocked, true);
     will_return(__wrap_fwrite_unlocked, 0);
 
-    const f_status_t status = f_conversion_number_unsigned_print(1, data, stdout);
+    const f_status_t status = f_conversion_number_unsigned_print(1, data, F_type_output_d);
 
     assert_int_equal(F_status_set_fine(status), F_output);
   }
@@ -27,7 +27,7 @@ void test__f_conversion_number_unsigned_print__fails_for_prepend(void **state) {
     will_return(__wrap_fwrite_unlocked, true);
     will_return(__wrap_fwrite_unlocked, 0);
 
-    const f_status_t status = f_conversion_number_unsigned_print(1, data, stdout);
+    const f_status_t status = f_conversion_number_unsigned_print(1, data, F_type_output_d);
 
     assert_int_equal(F_status_set_fine(status), F_output);
   }
@@ -41,7 +41,7 @@ void test__f_conversion_number_unsigned_print__fails_for_zero(void **state) {
     will_return(__wrap_fwrite_unlocked, true);
     will_return(__wrap_fwrite_unlocked, 0);
 
-    const f_status_t status = f_conversion_number_unsigned_print(0, data, stdout);
+    const f_status_t status = f_conversion_number_unsigned_print(0, data, F_type_output_d);
 
     assert_int_equal(F_status_set_fine(status), F_output);
   }
@@ -59,10 +59,10 @@ void test__f_conversion_number_unsigned_print__fails_for_zero(void **state) {
     }
 
     {
-      FILE file;
+      FILE *file = 0;
       const f_conversion_data_t data = macro_f_conversion_data_t_initialize(1, 0, 0);
 
-      const f_status_t status = f_conversion_number_unsigned_print(0, data, &file);
+      const f_status_t status = f_conversion_number_unsigned_print(0, data, file);
 
       assert_int_equal(F_status_set_fine(status), F_parameter);
     }
@@ -74,7 +74,7 @@ void test__f_conversion_number_unsigned_print__works(void **state) {
   {
     const f_conversion_data_t data = macro_f_conversion_data_t_initialize(10, 0, 0);
 
-    const f_status_t status = f_conversion_number_unsigned_print(1, data, stdout);
+    const f_status_t status = f_conversion_number_unsigned_print(1, data, F_type_output_d);
 
     will_return(__wrap_fwrite_unlocked, false);
 
index a860c350baa4fb685e98a0fd00a22d3f58a221bc..e4558236f0e7bdac5ab7e3afb01538d9fdfafd25 100644 (file)
@@ -153,7 +153,7 @@ void test__f_file_stream_close__fails_for_stream(void **state) {
 
       f_file_t file = f_file_t_initialize;
       file.id = 0;
-      file.stream = stdout;
+      file.stream = F_type_input_d;
 
       if (flush) {
         if (flush == 1) {
@@ -199,7 +199,7 @@ void test__f_file_stream_close__works(void **state) {
     f_file_t file = f_file_t_initialize;
 
     file.id = 0;
-    file.stream = stdout;
+    file.stream = F_type_input_d;
 
     will_return(__wrap_fclose, false);
     will_return(__wrap_fclose, 0);
@@ -231,7 +231,7 @@ void test__f_file_stream_close__works(void **state) {
     f_file_t file = f_file_t_initialize;
 
     file.id = 0;
-    file.stream = stdout;
+    file.stream = F_type_input_d;
 
     will_return(__wrap_fflush, false);
     will_return(__wrap_fflush, 0);
index 1c72251345ec1081f3e775da7d366f643bb95db8..d1ddfcaecc6ca76b65999aec34d4b15ac1a7c810 100644 (file)
@@ -110,34 +110,33 @@ void test__f_file_stream_open__works(void **state) {
 
   const f_string_static_t path = macro_f_string_static_t_initialize("test", 0, 4);
   const int id = 1;
-  FILE *file_pointer = stdout;
 
   {
     f_file_t file = f_file_t_initialize;
 
     will_return(__wrap_fopen, false);
-    will_return(__wrap_fopen, file_pointer);
+    will_return(__wrap_fopen, F_type_output_d);
 
     will_return(__wrap_fileno, id);
 
     const f_status_t status = f_file_stream_open(path, path, &file);
 
     assert_int_equal(status, F_none);
-    assert_int_equal(file.stream, file_pointer);
+    assert_int_equal(file.stream, F_type_output_d);
   }
 
   {
     f_file_t file = f_file_t_initialize;
 
     will_return(__wrap_fopen, false);
-    will_return(__wrap_fopen, file_pointer);
+    will_return(__wrap_fopen, F_type_output_d);
 
     will_return(__wrap_fileno, id);
 
     const f_status_t status = f_file_stream_open(path, f_string_empty_s, &file);
 
     assert_int_equal(status, F_none);
-    assert_int_equal(file.stream, file_pointer);
+    assert_int_equal(file.stream, F_type_output_d);
   }
 }
 
index 556f9b22d3672be5170f8fe3ce0406bed558b7ff..5016d8b4e0e47d34284d02ca8cc0c31ae47b5a53 100644 (file)
@@ -39,7 +39,7 @@ void test__f_file_stream_read__fails(void **state) {
 
     f_file_t file = f_file_t_initialize;
     file.size_read = 1;
-    file.stream = stdout;
+    file.stream = F_type_input_d;
 
     will_return(__wrap_feof_unlocked, false);
     will_return(__wrap_feof_unlocked, 0);
@@ -113,7 +113,7 @@ void test__f_file_stream_read__works(void **state) {
   {
     f_file_t file = f_file_t_initialize;
     file.size_read = 1;
-    file.stream = stdout;
+    file.stream = F_type_input_d;
 
     will_return(__wrap_feof_unlocked, false);
     will_return(__wrap_feof_unlocked, 0);
index 5a6a05e7c9d7c5250fa369d91f07f053c1caa197..c5da1c0b72e26255e7aeafef66e0a463e5533ff2 100644 (file)
@@ -39,7 +39,7 @@ void test__f_file_stream_read_block__fails(void **state) {
 
     f_file_t file = f_file_t_initialize;
     file.size_read = 1;
-    file.stream = stdout;
+    file.stream = F_type_input_d;
 
     will_return(__wrap_feof_unlocked, false);
     will_return(__wrap_feof_unlocked, 0);
@@ -112,7 +112,7 @@ void test__f_file_stream_read_block__works(void **state) {
   {
     f_file_t file = f_file_t_initialize;
     file.size_read = 1;
-    file.stream = stdout;
+    file.stream = F_type_input_d;
 
     will_return(__wrap_feof_unlocked, false);
     will_return(__wrap_feof_unlocked, 0);
index c316d6d0fbdcbeb4e725d6046aa538f11fb66d76..9a3384fc3c0a6db0be529ac2dc24f35be12f2ddf 100644 (file)
@@ -39,7 +39,7 @@ void test__f_file_stream_read_until__fails(void **state) {
 
     f_file_t file = f_file_t_initialize;
     file.size_read = 1;
-    file.stream = stdout;
+    file.stream = F_type_input_d;
 
     will_return(__wrap_feof_unlocked, false);
     will_return(__wrap_feof_unlocked, 0);
@@ -115,7 +115,7 @@ void test__f_file_stream_read_until__works(void **state) {
   {
     f_file_t file = f_file_t_initialize;
     file.size_read = 1;
-    file.stream = stdout;
+    file.stream = F_type_input_d;
 
     will_return(__wrap_feof_unlocked, false);
     will_return(__wrap_feof_unlocked, 0);
index 5cffff635bd15e2c3f5d4fc816242d32be4f898b..352da5535c2b2bdb07aafb5ed4739b9f39cf00ad 100644 (file)
@@ -106,35 +106,34 @@ void test__f_file_stream_reopen__works(void **state) {
 
   const f_string_static_t path = macro_f_string_static_t_initialize("test", 0, 4);
   const int id = 1;
-  FILE *file_pointer = stdout;
 
   {
     f_file_t file = f_file_t_initialize;
-    file.stream = file_pointer;
+    file.stream = F_type_input_d;
 
     will_return(__wrap_freopen, false);
-    will_return(__wrap_freopen, file_pointer);
+    will_return(__wrap_freopen, F_type_input_d);
 
     will_return(__wrap_fileno, id);
 
     const f_status_t status = f_file_stream_reopen(path, path, &file);
 
     assert_int_equal(status, F_none);
-    assert_int_equal(file.stream, file_pointer);
+    assert_int_equal(file.stream, F_type_input_d);
   }
 
   {
     f_file_t file = f_file_t_initialize;
 
     will_return(__wrap_freopen, false);
-    will_return(__wrap_freopen, file_pointer);
+    will_return(__wrap_freopen, F_type_input_d);
 
     will_return(__wrap_fileno, id);
 
     const f_status_t status = f_file_stream_reopen(path, f_string_empty_s, &file);
 
     assert_int_equal(status, F_none);
-    assert_int_equal(file.stream, file_pointer);
+    assert_int_equal(file.stream, F_type_input_d);
   }
 }
 
index 355b6aae28a2cc3bc08b88a31d6d1ff66da2c29a..4b62b812a7651492346419a7a078b0028f2d60ae 100644 (file)
@@ -37,7 +37,7 @@ void test__f_file_stream_write__fails(void **state) {
 
     f_file_t file = f_file_t_initialize;
     file.size_read = 1;
-    file.stream = stdout;
+    file.stream = F_type_input_d;
 
     will_return(__wrap_fwrite_unlocked, true);
     will_return(__wrap_fwrite_unlocked, errnos[i]);
@@ -79,8 +79,7 @@ void test__f_file_stream_write__returns_file_closed(void **state) {
 void test__f_file_stream_write__returns_data_not(void **state) {
 
   f_file_t file = f_file_t_initialize;
-  FILE file_stucture;
-  file.stream = &file_stucture;
+  file.stream = F_type_input_d;
 
   {
     const f_status_t status = f_file_stream_write(file, f_string_empty_s, 0);
@@ -105,7 +104,7 @@ void test__f_file_stream_write__works(void **state) {
   {
     f_file_t file = f_file_t_initialize;
     file.size_write = path.used;
-    file.stream = stdout;
+    file.stream = F_type_input_d;
 
     will_return(__wrap_fwrite_unlocked, false);
     will_return(__wrap_fwrite_unlocked, file.size_write);
index 7b392201a2098de142184999c799db025f615dee..6ad1ac787e5ada3f5052d6a014c6bc6cf1f9832b 100644 (file)
@@ -37,7 +37,7 @@ void test__f_file_stream_write_block__fails(void **state) {
 
     f_file_t file = f_file_t_initialize;
     file.size_read = 1;
-    file.stream = stdout;
+    file.stream = F_type_input_d;
 
     will_return(__wrap_fwrite_unlocked, true);
     will_return(__wrap_fwrite_unlocked, errnos[i]);
@@ -79,8 +79,7 @@ void test__f_file_stream_write_block__returns_file_closed(void **state) {
 void test__f_file_stream_write_block__returns_data_not(void **state) {
 
   f_file_t file = f_file_t_initialize;
-  FILE file_stucture;
-  file.stream = &file_stucture;
+  file.stream = F_type_input_d;
 
   {
     const f_status_t status = f_file_stream_write_block(file, f_string_empty_s, 0);
@@ -105,7 +104,7 @@ void test__f_file_stream_write_block__works(void **state) {
   {
     f_file_t file = f_file_t_initialize;
     file.size_write = 1;
-    file.stream = stdout;
+    file.stream = F_type_input_d;
 
     will_return(__wrap_fwrite_unlocked, false);
     will_return(__wrap_fwrite_unlocked, file.size_write);
@@ -121,7 +120,7 @@ void test__f_file_stream_write_block__works(void **state) {
   {
     f_file_t file = f_file_t_initialize;
     file.size_write = path.used;
-    file.stream = stdout;
+    file.stream = F_type_input_d;
 
     will_return(__wrap_fwrite_unlocked, false);
     will_return(__wrap_fwrite_unlocked, file.size_write);
index 2a6da07c4643419455346678f8754bfb167fa62f..6d8e5b9d7ef02703bc2b30e302975031b06428f1 100644 (file)
@@ -38,7 +38,7 @@ void test__f_file_stream_write_range__fails(void **state) {
 
     f_file_t file = f_file_t_initialize;
     file.size_read = 1;
-    file.stream = stdout;
+    file.stream = F_type_input_d;
 
     will_return(__wrap_fwrite_unlocked, true);
     will_return(__wrap_fwrite_unlocked, errnos[i]);
@@ -83,8 +83,7 @@ void test__f_file_stream_write_range__returns_file_closed(void **state) {
 void test__f_file_stream_write_range__returns_data_not(void **state) {
 
   f_file_t file = f_file_t_initialize;
-  FILE file_stucture;
-  file.stream = &file_stucture;
+  file.stream = F_type_input_d;
 
   {
     const f_string_range_t range = f_string_range_t_initialize;
@@ -154,7 +153,7 @@ void test__f_file_stream_write_range__works(void **state) {
   {
     f_file_t file = f_file_t_initialize;
     file.size_write = 1;
-    file.stream = stdout;
+    file.stream = F_type_input_d;
 
     will_return(__wrap_fwrite_unlocked, false);
     will_return(__wrap_fwrite_unlocked, file.size_write);
@@ -170,7 +169,7 @@ void test__f_file_stream_write_range__works(void **state) {
   {
     f_file_t file = f_file_t_initialize;
     file.size_write = path.used;
-    file.stream = stdout;
+    file.stream = F_type_input_d;
 
     will_return(__wrap_fwrite_unlocked, false);
     will_return(__wrap_fwrite_unlocked, file.size_write);
index 6112a840025845287805e804b8af0aa53fdce266..149d42c5778dcc3a1358625e763736e4410c2440 100644 (file)
@@ -37,7 +37,7 @@ void test__f_file_stream_write_until__fails(void **state) {
 
     f_file_t file = f_file_t_initialize;
     file.size_read = 1;
-    file.stream = stdout;
+    file.stream = F_type_input_d;
 
     will_return(__wrap_fwrite_unlocked, true);
     will_return(__wrap_fwrite_unlocked, errnos[i]);
@@ -82,8 +82,7 @@ void test__f_file_stream_write_until__returns_data_not(void **state) {
   const f_string_static_t path = macro_f_string_static_t_initialize("test", 0, 4);
 
   f_file_t file = f_file_t_initialize;
-  FILE file_stucture;
-  file.stream = &file_stucture;
+  file.stream = F_type_input_d;
 
   {
     const f_status_t status = f_file_stream_write_until(file, f_string_empty_s, 0, 0);
@@ -138,7 +137,7 @@ void test__f_file_stream_write_until__works(void **state) {
   {
     f_file_t file = f_file_t_initialize;
     file.size_write = 1;
-    file.stream = stdout;
+    file.stream = F_type_input_d;
 
     will_return(__wrap_fwrite_unlocked, false);
     will_return(__wrap_fwrite_unlocked, file.size_write);
@@ -172,7 +171,7 @@ void test__f_file_stream_write_until__works(void **state) {
   {
     f_file_t file = f_file_t_initialize;
     file.size_write = path.used;
-    file.stream = stdout;
+    file.stream = F_type_input_d;
 
     will_return(__wrap_fwrite_unlocked, false);
     will_return(__wrap_fwrite_unlocked, file.size_write);
index af99fd691f5d7bf3d03f92273214a1754e6045ae..2681b01c3a41338b4a79a213bace14481c112d48 100644 (file)
@@ -60,7 +60,7 @@ extern "C" {
     if (!result) {
 
       // @todo in order to get this working, the recursive function that calls this needs to be rewritten with more flexibility or provide a higher-level equivalent function.
-      fll_print_format("Removed '%S'.%r", stdout, path, f_string_eol_s);
+      fll_print_format("Removed '%S'.%r", F_type_input_d, path, f_string_eol_s);
     }
 
     return result;