From aa1343ee99c352fa07af33f7d5880d3974b7230d Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Mon, 24 Apr 2023 23:26:43 -0500 Subject: [PATCH] Progress: Continue fixing the unit tests. Properly handle mock return types. Make sure to return F_file_descriptor_not instead of F_stream_not in cases where the file descriptor is checked instead of the file stream. --- .../f_conversion/tests/unit/c/mock-conversion.c | 2 +- level_0/f_file/c/file.c | 12 ++++---- level_0/f_file/c/file.h | 14 ++++----- level_0/f_file/c/file/stream.c | 36 +++++++++++++++------- level_0/f_file/tests/unit/c/mock-file.c | 2 +- .../f_file/tests/unit/c/test-file-stream_write.c | 16 ++-------- .../f_file/tests/unit/c/test-file-stream_write.h | 7 ----- .../tests/unit/c/test-file-stream_write_block.c | 12 -------- .../tests/unit/c/test-file-stream_write_block.h | 7 ----- .../tests/unit/c/test-file-stream_write_range.c | 14 --------- .../tests/unit/c/test-file-stream_write_range.h | 7 ----- .../tests/unit/c/test-file-stream_write_until.c | 12 -------- .../tests/unit/c/test-file-stream_write_until.h | 7 ----- level_0/f_file/tests/unit/c/test-file-write.c | 12 -------- level_0/f_file/tests/unit/c/test-file-write.h | 7 ----- .../f_file/tests/unit/c/test-file-write_block.c | 12 -------- .../f_file/tests/unit/c/test-file-write_block.h | 7 ----- .../f_file/tests/unit/c/test-file-write_range.c | 14 --------- .../f_file/tests/unit/c/test-file-write_range.h | 7 ----- .../f_file/tests/unit/c/test-file-write_until.c | 12 -------- .../f_file/tests/unit/c/test-file-write_until.h | 7 ----- level_0/f_file/tests/unit/c/test-file.c | 16 +++++----- level_0/f_print/tests/unit/c/mock-print.c | 4 +-- 23 files changed, 53 insertions(+), 193 deletions(-) diff --git a/level_0/f_conversion/tests/unit/c/mock-conversion.c b/level_0/f_conversion/tests/unit/c/mock-conversion.c index 91603c2..585c105 100644 --- a/level_0/f_conversion/tests/unit/c/mock-conversion.c +++ b/level_0/f_conversion/tests/unit/c/mock-conversion.c @@ -14,7 +14,7 @@ size_t __wrap_fwrite_unlocked(const void * const ptr, size_t size, size_t nmemb, const bool failure = mock_type(bool); if (failure) { - return mock_type(int); + return mock_type(size_t); } const bool check_ptr = mock_type(bool); diff --git a/level_0/f_file/c/file.c b/level_0/f_file/c/file.c index fb1e685..812beb0 100644 --- a/level_0/f_file/c/file.c +++ b/level_0/f_file/c/file.c @@ -1999,7 +1999,7 @@ extern "C" { #ifndef _di_f_file_touch_at_ f_status_t f_file_touch_at(const f_file_t directory, const f_string_static_t path, const mode_t mode, const int flag) { - if (directory.id == -1) return F_stream_not; + if (directory.id == -1) return F_file_descriptor_not; if (!path.used) return F_data_not; struct stat stat_file; @@ -2065,7 +2065,7 @@ extern "C" { if (!type) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (directory.id == -1) return F_stream_not; + if (directory.id == -1) return F_file_descriptor_not; if (!path.used) return F_data_not; struct stat stat_file; @@ -2114,7 +2114,7 @@ extern "C" { if (file.id == -1 || !buffer.used || !file.size_write) { if (written) *written = 0; - return file.id == -1 ? F_stream_not : F_data_not; + return file.id == -1 ? F_file_descriptor_not : F_data_not; } if (written) { @@ -2142,7 +2142,7 @@ extern "C" { if (file.id == -1 || !buffer.used || !file.size_write) { if (written) *written = 0; - return file.id == -1 ? F_stream_not : F_data_not; + return file.id == -1 ? F_file_descriptor_not : F_data_not; } const f_array_length_t write_max = file.size_write > buffer.used ? buffer.used : file.size_write; @@ -2178,7 +2178,7 @@ extern "C" { if (file.id == -1 || !buffer.used || !total || !file.size_write) { if (written) *written = 0; - return file.id == -1 ? F_stream_not : F_data_not; + return file.id == -1 ? F_file_descriptor_not : F_data_not; } const f_array_length_t write_max = total > buffer.used ? buffer.used : total; @@ -2216,7 +2216,7 @@ extern "C" { *written = 0; } - return file.id == -1 ? F_stream_not : F_data_not; + return file.id == -1 ? F_file_descriptor_not : F_data_not; } const f_array_length_t write_max = (range.stop - range.start) + 1 > buffer.used ? buffer.used : (range.stop - range.start) + 1; diff --git a/level_0/f_file/c/file.h b/level_0/f_file/c/file.h index 0eec160..befba24 100644 --- a/level_0/f_file/c/file.h +++ b/level_0/f_file/c/file.h @@ -2126,10 +2126,10 @@ extern "C" { * * @return * F_none on success. + * F_file_descriptor_not if file.id is -1. + * * F_access_denied (with error bit) on access denied. * F_buffer (with error bit) if the buffer is invalid. - * F_stream_not if file.stream is NULL. - * * F_busy (with error bit) if file system is too busy to perform write. * F_directory_descriptor (with error bit) when at_id is not a valid file descriptor (at_id must point to a directory). * F_directory_not (with error bit) if a supposed directory in path is not actually a directory. @@ -2200,8 +2200,8 @@ extern "C" { * * @return * F_none if path was found and and the type was loaded in the type parameter. + * F_file_descriptor_not if file.id is -1. * F_file_found_not if the path was not found. - * F_stream_not if file.stream is NULL. * * F_access_denied (with error bit) if access to the file was denied. * F_directory_descriptor (with error bit) when at_id is not a valid file descriptor (at_id must point to a directory). @@ -2269,7 +2269,7 @@ extern "C" { * F_none on success. * F_none_eos on success and wrote up to buffer.used. * F_data_not if buffer.used is 0 or range.start > range.stop. - * F_stream_not if file.id is -1. + * F_file_descriptor_not if file.id is -1. * * F_block (with error bit) if file descriptor is set to non-block and the write would result in a blocking operation. * F_buffer (with error bit) if the buffer is invalid. @@ -2304,7 +2304,7 @@ extern "C" { * F_none_stop on success and wrote up to stop point. * F_none_eos on success and wrote up to buffer.used (buffer.used is reached before stop point). * F_data_not if buffer.used is 0 or range.start > range.stop. - * F_stream_not if file.id is -1. + * F_file_descriptor_not if file.id is -1. * * F_block (with error bit) if file descriptor is set to non-block and the write would result in a blocking operation. * F_buffer (with error bit) if the buffer is invalid. @@ -2339,7 +2339,7 @@ extern "C" { * F_none_stop on success and wrote up to stop point. * F_none_eos on success and wrote up to buffer.used (buffer.used is reached before stop point). * F_data_not if buffer.used is 0 or range.start > range.stop. - * F_stream_not if file.id is -1. + * F_file_descriptor_not if file.id is -1. * * F_block (with error bit) if file descriptor is set to non-block and the write would result in a blocking operation. * F_buffer (with error bit) if the buffer is invalid. @@ -2374,7 +2374,7 @@ extern "C" { * F_none_stop on success and wrote up to stop point. * F_none_eos on success and wrote up to buffer.used (buffer.used is reached before stop point). * F_data_not if buffer.used is 0 or range.start > range.stop. - * F_stream_not if file.id is -1. + * F_file_descriptor_not if file.id is -1. * * F_block (with error bit) if file descriptor is set to non-block and the write would result in a blocking operation. * F_buffer (with error bit) if the buffer is invalid. diff --git a/level_0/f_file/c/file/stream.c b/level_0/f_file/c/file/stream.c index 3b42b1f..cecbb21 100644 --- a/level_0/f_file/c/file/stream.c +++ b/level_0/f_file/c/file/stream.c @@ -425,19 +425,23 @@ extern "C" { return file.stream ? F_data_not : F_stream_not; } + f_status_t status = F_none; + if (written) { - const f_status_t status = private_f_file_stream_write_until(file, buffer, buffer.used, written); + status = private_f_file_stream_write_until(file, buffer, buffer.used, written); if (status == F_none && *written == buffer.used) return F_none_eos; } else { f_array_length_t written_local = 0; - const f_status_t status = private_f_file_stream_write_until(file, buffer, buffer.used, &written_local); + status = private_f_file_stream_write_until(file, buffer, buffer.used, &written_local); if (status == F_none && written_local == buffer.used) return F_none_eos; } + if (F_status_is_error(status)) return status; + return F_none; } #endif // _di_f_file_stream_write_ @@ -455,8 +459,10 @@ extern "C" { const f_array_length_t write_max = file.size_write > buffer.used ? buffer.used : file.size_write; + f_status_t status = F_none; + if (written) { - const f_status_t status = private_f_file_stream_write_until(file, buffer, write_max, written); + status = private_f_file_stream_write_until(file, buffer, write_max, written); if (status == F_none) { if (*written == buffer.used) return F_none_eos; @@ -466,7 +472,7 @@ extern "C" { else { f_array_length_t written_local = 0; - const f_status_t status = private_f_file_stream_write_until(file, buffer, write_max, &written_local); + status = private_f_file_stream_write_until(file, buffer, write_max, &written_local); if (status == F_none) { if (written_local == buffer.used) return F_none_eos; @@ -474,6 +480,8 @@ extern "C" { } } + if (F_status_is_error(status)) return status; + return F_none; } #endif // _di_f_file_stream_write_block_ @@ -491,8 +499,10 @@ extern "C" { const f_array_length_t write_max = total > buffer.used ? buffer.used : total; + f_status_t status = F_none; + if (written) { - const f_status_t status = private_f_file_stream_write_until(file, buffer, write_max, written); + status = private_f_file_stream_write_until(file, buffer, write_max, written); if (status == F_none) { if (*written == buffer.used) return F_none_eos; @@ -502,7 +512,7 @@ extern "C" { else { f_array_length_t written_local = 0; - const f_status_t status = private_f_file_stream_write_until(file, buffer, buffer.used, &written_local); + status = private_f_file_stream_write_until(file, buffer, buffer.used, &written_local); if (status == F_none) { if (written_local == buffer.used) return F_none_eos; @@ -510,6 +520,8 @@ extern "C" { } } + if (F_status_is_error(status)) return status; + return F_none; } #endif // _di_f_file_stream_write_until_ @@ -526,11 +538,12 @@ extern "C" { } const f_array_length_t write_max = (range.stop - range.start) + 1 > buffer.used ? buffer.used : (range.stop - range.start) + 1; + const f_string_static_t buffer_adjusted = macro_f_string_static_t_initialize_1(buffer.string + range.start, 0, buffer.used - range.start); - if (written) { - const f_string_static_t buffer_adjusted = macro_f_string_static_t_initialize_1(buffer.string + range.start, 0, buffer.used - range.start); + f_status_t status = F_none; - const f_status_t status = private_f_file_stream_write_until(file, buffer_adjusted, write_max, written); + if (written) { + status = private_f_file_stream_write_until(file, buffer_adjusted, write_max, written); if (status == F_none) { if (range.start + *written == buffer.used) return F_none_eos; @@ -538,10 +551,9 @@ extern "C" { } } else { - const f_string_static_t buffer_adjusted = macro_f_string_static_t_initialize_1(buffer.string + range.start, 0, buffer.used - range.start); f_array_length_t written_local = 0; - const f_status_t status = private_f_file_stream_write_until(file, buffer_adjusted, write_max, &written_local); + status = private_f_file_stream_write_until(file, buffer_adjusted, write_max, &written_local); if (status == F_none) { if (range.start + written_local == buffer.used) return F_none_eos; @@ -549,6 +561,8 @@ extern "C" { } } + if (F_status_is_error(status)) return status; + return F_none; } #endif // _di_f_file_stream_write_range_ diff --git a/level_0/f_file/tests/unit/c/mock-file.c b/level_0/f_file/tests/unit/c/mock-file.c index 5f4ba24..d929dcb 100644 --- a/level_0/f_file/tests/unit/c/mock-file.c +++ b/level_0/f_file/tests/unit/c/mock-file.c @@ -290,7 +290,7 @@ size_t __wrap_fwrite_unlocked(const void *ptr, size_t size, size_t nmemb, FILE * const bool failure = mock_type(bool); if (failure) { - return mock_type(int); + return mock_type(size_t); } return mock_type(size_t); diff --git a/level_0/f_file/tests/unit/c/test-file-stream_write.c b/level_0/f_file/tests/unit/c/test-file-stream_write.c index 57053aa..df11499 100644 --- a/level_0/f_file/tests/unit/c/test-file-stream_write.c +++ b/level_0/f_file/tests/unit/c/test-file-stream_write.c @@ -14,7 +14,9 @@ void test__f_file_stream_write__fails(void **state) { file.size_read = 1; file.size_write = 1; - will_return(__wrap_write, 0); + will_return(__wrap_fwrite_unlocked, true); + will_return(__wrap_fwrite_unlocked, 0); + will_return(__wrap_ferror_unlocked, true); const f_status_t status = f_file_stream_write(file, test, 0); @@ -22,18 +24,6 @@ void test__f_file_stream_write__fails(void **state) { } } -void test__f_file_stream_write__parameter_checking(void **state) { - - f_file_t file = macro_f_file_t_initialize_2(F_type_output_d, F_type_descriptor_output_d, F_file_flag_write_only_d); - file.size_write = 0; - - { - const f_status_t status = f_file_stream_write(file, f_string_empty_s, 0); - - assert_int_equal(status, F_status_set_error(F_parameter)); - } -} - void test__f_file_stream_write__returns_stream_not(void **state) { const f_file_t file = f_file_t_initialize; diff --git a/level_0/f_file/tests/unit/c/test-file-stream_write.h b/level_0/f_file/tests/unit/c/test-file-stream_write.h index 0452a44..28deb61 100644 --- a/level_0/f_file/tests/unit/c/test-file-stream_write.h +++ b/level_0/f_file/tests/unit/c/test-file-stream_write.h @@ -18,13 +18,6 @@ extern void test__f_file_stream_write__fails(void **state); /** - * Test that parameter checking works as expected. - * - * @see f_file_stream_write() - */ -extern void test__f_file_stream_write__parameter_checking(void **state); - -/** * Test that function works but the stream is not valid. * * @see f_file_stream_write() diff --git a/level_0/f_file/tests/unit/c/test-file-stream_write_block.c b/level_0/f_file/tests/unit/c/test-file-stream_write_block.c index 88f7fbd..9d1a110 100644 --- a/level_0/f_file/tests/unit/c/test-file-stream_write_block.c +++ b/level_0/f_file/tests/unit/c/test-file-stream_write_block.c @@ -25,18 +25,6 @@ void test__f_file_stream_write_block__fails(void **state) { } } -void test__f_file_stream_write_block__parameter_checking(void **state) { - - f_file_t file = macro_f_file_t_initialize_2(F_type_output_d, F_type_descriptor_output_d, F_file_flag_write_only_d); - file.size_write = 0; - - { - const f_status_t status = f_file_stream_write_block(file, f_string_empty_s, 0); - - assert_int_equal(status, F_status_set_error(F_parameter)); - } -} - void test__f_file_stream_write_block__returns_stream_not(void **state) { const f_file_t file = f_file_t_initialize; diff --git a/level_0/f_file/tests/unit/c/test-file-stream_write_block.h b/level_0/f_file/tests/unit/c/test-file-stream_write_block.h index f5f02ec..b973786 100644 --- a/level_0/f_file/tests/unit/c/test-file-stream_write_block.h +++ b/level_0/f_file/tests/unit/c/test-file-stream_write_block.h @@ -18,13 +18,6 @@ extern void test__f_file_stream_write_block__fails(void **state); /** - * Test that parameter checking works as expected. - * - * @see f_file_stream_write_block() - */ -extern void test__f_file_stream_write_block__parameter_checking(void **state); - -/** * Test that function works but the stream is not valid. * * @see f_file_stream_write_block() diff --git a/level_0/f_file/tests/unit/c/test-file-stream_write_range.c b/level_0/f_file/tests/unit/c/test-file-stream_write_range.c index 7a18572..8ce7104 100644 --- a/level_0/f_file/tests/unit/c/test-file-stream_write_range.c +++ b/level_0/f_file/tests/unit/c/test-file-stream_write_range.c @@ -24,20 +24,6 @@ void test__f_file_stream_write_range__fails(void **state) { } } -void test__f_file_stream_write_range__parameter_checking(void **state) { - - f_file_t file = macro_f_file_t_initialize_2(F_type_output_d, F_type_descriptor_output_d, F_file_flag_write_only_d); - file.size_write = 0; - - const f_string_range_t range = f_string_range_t_initialize; - - { - const f_status_t status = f_file_stream_write_range(file, f_string_empty_s, range, 0); - - assert_int_equal(status, F_status_set_error(F_parameter)); - } -} - void test__f_file_stream_write_range__returns_stream_not(void **state) { const f_file_t file = f_file_t_initialize; diff --git a/level_0/f_file/tests/unit/c/test-file-stream_write_range.h b/level_0/f_file/tests/unit/c/test-file-stream_write_range.h index 496a2cd..ff19d4b 100644 --- a/level_0/f_file/tests/unit/c/test-file-stream_write_range.h +++ b/level_0/f_file/tests/unit/c/test-file-stream_write_range.h @@ -18,13 +18,6 @@ extern void test__f_file_stream_write_range__fails(void **state); /** - * Test that parameter checking works as expected. - * - * @see f_file_stream_write_range() - */ -extern void test__f_file_stream_write_range__parameter_checking(void **state); - -/** * Test that function works but the stream is not valid. * * @see f_file_stream_write_range() diff --git a/level_0/f_file/tests/unit/c/test-file-stream_write_until.c b/level_0/f_file/tests/unit/c/test-file-stream_write_until.c index 92b1ef0..bdf0dfa 100644 --- a/level_0/f_file/tests/unit/c/test-file-stream_write_until.c +++ b/level_0/f_file/tests/unit/c/test-file-stream_write_until.c @@ -23,18 +23,6 @@ void test__f_file_stream_write_until__fails(void **state) { } } -void test__f_file_stream_write_until__parameter_checking(void **state) { - - f_file_t file = macro_f_file_t_initialize_2(F_type_output_d, F_type_descriptor_output_d, F_file_flag_write_only_d); - file.size_write = 0; - - { - const f_status_t status = f_file_stream_write_until(file, f_string_empty_s, 0, 0); - - assert_int_equal(status, F_status_set_error(F_parameter)); - } -} - void test__f_file_stream_write_until__returns_stream_not(void **state) { f_file_t file = f_file_t_initialize; diff --git a/level_0/f_file/tests/unit/c/test-file-stream_write_until.h b/level_0/f_file/tests/unit/c/test-file-stream_write_until.h index 13a91fc..df2585d 100644 --- a/level_0/f_file/tests/unit/c/test-file-stream_write_until.h +++ b/level_0/f_file/tests/unit/c/test-file-stream_write_until.h @@ -18,13 +18,6 @@ extern void test__f_file_stream_write_until__fails(void **state); /** - * Test that parameter checking works as expected. - * - * @see f_file_stream_write_until() - */ -extern void test__f_file_stream_write_until__parameter_checking(void **state); - -/** * Test that function works but the stream is not valid. * * @see f_file_stream_write_until() diff --git a/level_0/f_file/tests/unit/c/test-file-write.c b/level_0/f_file/tests/unit/c/test-file-write.c index d0bdb69..54fa441 100644 --- a/level_0/f_file/tests/unit/c/test-file-write.c +++ b/level_0/f_file/tests/unit/c/test-file-write.c @@ -65,18 +65,6 @@ void test__f_file_write__fails(void **state) { } // for } -void test__f_file_write__parameter_checking(void **state) { - - f_file_t file = macro_f_file_t_initialize_2(F_type_output_d, F_type_descriptor_output_d, F_file_flag_write_only_d); - file.size_write = 0; - - { - const f_status_t status = f_file_write(file, f_string_empty_s, 0); - - assert_int_equal(status, F_status_set_error(F_parameter)); - } -} - void test__f_file_write__returns_file_descriptor_not(void **state) { const f_file_t file = f_file_t_initialize; diff --git a/level_0/f_file/tests/unit/c/test-file-write.h b/level_0/f_file/tests/unit/c/test-file-write.h index f009664..f2ab8aa 100644 --- a/level_0/f_file/tests/unit/c/test-file-write.h +++ b/level_0/f_file/tests/unit/c/test-file-write.h @@ -18,13 +18,6 @@ extern void test__f_file_write__fails(void **state); /** - * Test that parameter checking works as expected. - * - * @see f_file_write() - */ -extern void test__f_file_write__parameter_checking(void **state); - -/** * Test that function works but the descriptor is not valid. * * @see f_file_write() diff --git a/level_0/f_file/tests/unit/c/test-file-write_block.c b/level_0/f_file/tests/unit/c/test-file-write_block.c index bfae6e2..cf6e6e7 100644 --- a/level_0/f_file/tests/unit/c/test-file-write_block.c +++ b/level_0/f_file/tests/unit/c/test-file-write_block.c @@ -48,18 +48,6 @@ void test__f_file_write_block__fails(void **state) { } // for } -void test__f_file_write_block__parameter_checking(void **state) { - - f_file_t file = macro_f_file_t_initialize_2(F_type_output_d, F_type_descriptor_output_d, F_file_flag_write_only_d); - file.size_write = 0; - - { - const f_status_t status = f_file_write_block(file, f_string_empty_s, 0); - - assert_int_equal(status, F_status_set_error(F_parameter)); - } -} - void test__f_file_write_block__returns_file_descriptor_not(void **state) { f_file_t file = f_file_t_initialize; diff --git a/level_0/f_file/tests/unit/c/test-file-write_block.h b/level_0/f_file/tests/unit/c/test-file-write_block.h index 157d752..f91c166 100644 --- a/level_0/f_file/tests/unit/c/test-file-write_block.h +++ b/level_0/f_file/tests/unit/c/test-file-write_block.h @@ -18,13 +18,6 @@ extern void test__f_file_write_block__fails(void **state); /** - * Test that parameter checking works as expected. - * - * @see f_file_write_block() - */ -extern void test__f_file_write_block__parameter_checking(void **state); - -/** * Test that function works but the descriptor is not valid. * * @see f_file_write_block() diff --git a/level_0/f_file/tests/unit/c/test-file-write_range.c b/level_0/f_file/tests/unit/c/test-file-write_range.c index 36942d9..6ac54c2 100644 --- a/level_0/f_file/tests/unit/c/test-file-write_range.c +++ b/level_0/f_file/tests/unit/c/test-file-write_range.c @@ -49,20 +49,6 @@ void test__f_file_write_range__fails(void **state) { } // for } -void test__f_file_write_range__parameter_checking(void **state) { - - f_file_t file = macro_f_file_t_initialize_2(F_type_output_d, F_type_descriptor_output_d, F_file_flag_write_only_d); - file.size_write = 0; - - const f_string_range_t range = f_string_range_t_initialize; - - { - const f_status_t status = f_file_write_range(file, f_string_empty_s, range, 0); - - assert_int_equal(status, F_status_set_error(F_parameter)); - } -} - void test__f_file_write_range__returns_file_descriptor_not(void **state) { f_file_t file = f_file_t_initialize; diff --git a/level_0/f_file/tests/unit/c/test-file-write_range.h b/level_0/f_file/tests/unit/c/test-file-write_range.h index ae91218..0316b07 100644 --- a/level_0/f_file/tests/unit/c/test-file-write_range.h +++ b/level_0/f_file/tests/unit/c/test-file-write_range.h @@ -18,13 +18,6 @@ extern void test__f_file_write_range__fails(void **state); /** - * Test that parameter checking works as expected. - * - * @see f_file_write_range() - */ -extern void test__f_file_write_range__parameter_checking(void **state); - -/** * Test that function works but the descriptor is not valid. * * @see f_file_write_range() diff --git a/level_0/f_file/tests/unit/c/test-file-write_until.c b/level_0/f_file/tests/unit/c/test-file-write_until.c index af48524..ca723ef 100644 --- a/level_0/f_file/tests/unit/c/test-file-write_until.c +++ b/level_0/f_file/tests/unit/c/test-file-write_until.c @@ -48,18 +48,6 @@ void test__f_file_write_until__fails(void **state) { } // for } -void test__f_file_write_until__parameter_checking(void **state) { - - f_file_t file = macro_f_file_t_initialize_2(F_type_output_d, F_type_descriptor_output_d, F_file_flag_write_only_d); - file.size_write = 0; - - { - const f_status_t status = f_file_write_until(file, f_string_empty_s, 0, 0); - - assert_int_equal(status, F_status_set_error(F_parameter)); - } -} - void test__f_file_write_until__returns_file_descriptor_not(void **state) { f_file_t file = f_file_t_initialize; diff --git a/level_0/f_file/tests/unit/c/test-file-write_until.h b/level_0/f_file/tests/unit/c/test-file-write_until.h index 0d8a9b2..55e6f86 100644 --- a/level_0/f_file/tests/unit/c/test-file-write_until.h +++ b/level_0/f_file/tests/unit/c/test-file-write_until.h @@ -18,13 +18,6 @@ extern void test__f_file_write_until__fails(void **state); /** - * Test that parameter checking works as expected. - * - * @see f_file_write_until() - */ -extern void test__f_file_write_until__parameter_checking(void **state); - -/** * Test that function works but the descriptor is not valid. * * @see f_file_write_until() diff --git a/level_0/f_file/tests/unit/c/test-file.c b/level_0/f_file/tests/unit/c/test-file.c index 411c09f..479513b 100644 --- a/level_0/f_file/tests/unit/c/test-file.c +++ b/level_0/f_file/tests/unit/c/test-file.c @@ -432,20 +432,20 @@ int main(void) { cmocka_unit_test(test__f_file_stream_read_block__parameter_checking), cmocka_unit_test(test__f_file_stream_read_until__parameter_checking), cmocka_unit_test(test__f_file_stream_reopen__parameter_checking), - cmocka_unit_test(test__f_file_stream_write__parameter_checking), - cmocka_unit_test(test__f_file_stream_write_block__parameter_checking), - cmocka_unit_test(test__f_file_stream_write_until__parameter_checking), - cmocka_unit_test(test__f_file_stream_write_range__parameter_checking), + // f_file_stream_write() doesn't use parameter checking. + // f_file_stream_write_block() doesn't use parameter checking. + // f_file_stream_write_until() doesn't use parameter checking. + // f_file_stream_write_range() doesn't use parameter checking. // f_file_touch() doesn't use parameter checking. // f_file_touch_at() doesn't use parameter checking. cmocka_unit_test(test__f_file_type__parameter_checking), cmocka_unit_test(test__f_file_type_at__parameter_checking), cmocka_unit_test(test__f_file_umask_get__parameter_checking), // f_file_umask_set() doesn't use parameter checking. - cmocka_unit_test(test__f_file_write__parameter_checking), - cmocka_unit_test(test__f_file_write_block__parameter_checking), - cmocka_unit_test(test__f_file_write_until__parameter_checking), - cmocka_unit_test(test__f_file_write_range__parameter_checking), + // f_file_write() doesn't use parameter checking. + // f_file_write_block() doesn't use parameter checking. + // f_file_write_until() doesn't use parameter checking. + // f_file_write_range() doesn't use parameter checking. #endif // _di_level_0_parameter_checking_ }; diff --git a/level_0/f_print/tests/unit/c/mock-print.c b/level_0/f_print/tests/unit/c/mock-print.c index 9f5c062..9ab0222 100644 --- a/level_0/f_print/tests/unit/c/mock-print.c +++ b/level_0/f_print/tests/unit/c/mock-print.c @@ -17,7 +17,7 @@ size_t __wrap_fwrite_unlocked(const void *ptr, size_t size, size_t nmemb, FILE * const bool failure = mock_type(bool); if (failure) { - return mock_type(int); + return mock_type(size_t); } return mock_type(size_t); @@ -28,7 +28,7 @@ ssize_t __wrap_write(int fd, const void *buf, size_t count) { const bool failure = mock_type(bool); if (failure) { - errno = mock_type(int); + errno = mock_type(ssize_t); return -1; } -- 1.8.3.1