From 67799443dcfc131cf5509dbf40f17392e197f846 Mon Sep 17 00:00:00 2001 From: Stephane Gouache Date: Fri, 13 Sep 2024 18:24:58 +0200 Subject: [PATCH] Fix test control flow --- test/drivertest.cpp | 58 +++++++++++++++++++++++---------------------- 1 file changed, 30 insertions(+), 28 deletions(-) diff --git a/test/drivertest.cpp b/test/drivertest.cpp index 84f0658..1b23165 100644 --- a/test/drivertest.cpp +++ b/test/drivertest.cpp @@ -197,15 +197,16 @@ int test(const char *file_name_input, const char *file_name_output, if (copy_status == kSuccess) { printf("Copy %s to %s\n", file_name_input, file_name_output); copy_status = copyFile(file_name_input, file_name_output, nBufferSize); - } - if (copy_status == kSuccess) { - copy_status = compareSize(file_name_output, filesize); - if (copy_status != kSuccess) - printf("File sizes are different!\n"); - else - copy_status = compareFiles(file_name_local, file_name_output); - if (copy_status != kSuccess) - printf("File contents are different!\n"); + + if (copy_status == kSuccess) { + copy_status = compareSize(file_name_output, filesize); + if (copy_status != kSuccess) + printf("File sizes are different!\n"); + else + copy_status = compareFiles(file_name_local, file_name_output); + if (copy_status != kSuccess) + printf("File contents are different!\n"); + } removeFile(file_name_output); } @@ -214,15 +215,16 @@ int test(const char *file_name_input, const char *file_name_output, printf("Copy with fseek %s to %s ...\n", file_name_input, file_name_output); copy_status = copyFileWithFseek(file_name_input, file_name_output, nBufferSize); - } - if (copy_status == kSuccess) { - copy_status = compareSize(file_name_output, filesize); - if (copy_status != kSuccess) - printf("File sizes are different!\n"); - else - copy_status = compareFiles(file_name_local, file_name_output); - if (copy_status != kSuccess) - printf("File contents are different!\n"); + + if (copy_status == kSuccess) { + copy_status = compareSize(file_name_output, filesize); + if (copy_status != kSuccess) + printf("File sizes are different!\n"); + else + copy_status = compareFiles(file_name_local, file_name_output); + if (copy_status != kSuccess) + printf("File contents are different!\n"); + } removeFile(file_name_output); } @@ -232,16 +234,16 @@ int test(const char *file_name_input, const char *file_name_output, file_name_output); copy_status = copyFileWithAppend(file_name_input, file_name_output, nBufferSize); - } - if (copy_status == kSuccess) { - copy_status = compareSize(file_name_output, filesize); - copy_status = compareSize(file_name_output, filesize); - if (copy_status != kSuccess) - printf("File sizes are different!\n"); - else - copy_status = compareFiles(file_name_local, file_name_output); - if (copy_status != kSuccess) - printf("File contents are different!\n"); + + if (copy_status == kSuccess) { + copy_status = compareSize(file_name_output, filesize); + if (copy_status != kSuccess) + printf("File sizes are different!\n"); + else + copy_status = compareFiles(file_name_local, file_name_output); + if (copy_status != kSuccess) + printf("File contents are different!\n"); + } removeFile(file_name_output); }