diff options
author | Joseph Hunkeler <jhunkeler@users.noreply.github.com> | 2019-11-22 22:54:39 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-11-22 22:54:39 -0500 |
commit | 46ab9c276afee2fb03304aa53089c6c700c7af6e (patch) | |
tree | 59ea6b7a8217c17c0c1e915616f6615cc1813d9c /test/test_reloc_write.c | |
parent | 46a3e5a6837929d16670ed78e549882f34800ca4 (diff) | |
parent | 2ae80482cd88fb9786d3ff54777b8a462641f29f (diff) | |
download | reloc-46ab9c276afee2fb03304aa53089c6c700c7af6e.tar.gz |
Merge pull request #3 from jhunkeler/improve-testing
Improve testing
Diffstat (limited to 'test/test_reloc_write.c')
-rw-r--r-- | test/test_reloc_write.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/test/test_reloc_write.c b/test/test_reloc_write.c new file mode 100644 index 0000000..b2044c7 --- /dev/null +++ b/test/test_reloc_write.c @@ -0,0 +1,28 @@ +#include "reloc.h" +#include "myassert.h" +#if !defined(_MSC_VER) +#include <unistd.h> // unlink() +#endif + +const char *input_file = "test_data.bin"; +const char *output_file = "test_reloc_write.out"; + + +int test_reloc_write() { + RelocData *info = reloc_read(input_file); + myassert("failed to populate RelocData struct", info); + size_t size = reloc_write(info, output_file); + myassert("incorrect number of bytes written", size == info->size); + reloc_deinit_data(info); + if (unlink(output_file) != 0) { + perror("Could not delete output file"); + return errno; + } + + return 0; +} + + +int main() { + return test_reloc_write(); +} |