On Mon, 2019-04-22 at 18:50 +1000, Conor McCarthy wrote: ...
+#include "wine/test.h" +#include "windef.h" +#include "winbase.h" +#include "winerror.h" + +#include "patchapi.h" + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include "test_files.h"
I see no reason to put that in a separate file.
+int create_file(const BYTE *buf, size_t size, const char *name) +{ + size_t w; + FILE *f = fopen(name, "wb"); + if (f == NULL) + return -1; + w = fwrite(buf, 1, size, f); + fclose(f); + return w != size; +}
Please write this using Win32 functions only (CreateFile etc). It would also be better not to assume that the current directory is writable.
+#define CREATE_FILE(buf, name) create_file(buf, sizeof(buf), name) ... +static const char old_file_temp[] = "old_file.temp"; +static const char patch_file_temp[] = "patch_file.temp"; +static const char patch_file_temp_2[] = "patch_file_2.temp"; +static const char output_file_temp[] = "output.temp"; + +static void test_ApplyPatchToFile(void) +{ + ULONG current; + DWORD err; + + if (CREATE_FILE(patch_null_input_uncompressed, patch_file_temp_2) + || CREATE_FILE(old_two_files_ranges_0, old_file_temp) + || CREATE_FILE(patch_two_files_ranges, patch_file_temp)) + { + skip("Failed to create temporary input files\n"); + return; + }
Please avoid macros like CREATE_FILE. You could introduce a structure here that holds the buffer, size and filename, define an array of those and then iterate over the array. Look at how other tests do it.