diff options
author | Mike Frysinger <vapier@gentoo.org> | 2016-06-03 20:31:02 -0400 |
---|---|---|
committer | Mike Frysinger <vapier@gentoo.org> | 2016-06-03 20:31:02 -0400 |
commit | d6c50766ee39d96f8b9899acd6e0d358623b9812 (patch) | |
tree | 5022d0804af777033455c954111122ec36720673 /tests/gdimagerotate/bug00067.c | |
parent | 7b195d90c37354874d719f3a488abe16f94512c8 (diff) | |
download | libgd-d6c50766ee39d96f8b9899acd6e0d358623b9812.tar.gz |
tests: add helpers for accessing test data
A lot of tests want to read images/fonts that exist in tests/ for reading.
Rather than construct these paths by hand in every single test file, add a
few helper functions to quickly access them.
The helper functions are slightly slower (due to the repeated calls to the
strcat func), but they aren't terribly slow, especially relative to image
loading that these tests perform. They also make writing/maintaining the
tests a lot easier which is more important here.
Diffstat (limited to 'tests/gdimagerotate/bug00067.c')
-rw-r--r-- | tests/gdimagerotate/bug00067.c | 21 |
1 files changed, 6 insertions, 15 deletions
diff --git a/tests/gdimagerotate/bug00067.c b/tests/gdimagerotate/bug00067.c index 4a65959..243fd9a 100644 --- a/tests/gdimagerotate/bug00067.c +++ b/tests/gdimagerotate/bug00067.c @@ -7,29 +7,19 @@ int main() { gdImagePtr im, exp; - char path[2048]; + char *path, filename[2048]; const char *file_im = "gdimagerotate/remirh128.jpg"; - const char *file_exp = "gdimagerotate/bug00067"; FILE *fp; int color; int error = 0; int angle; - sprintf(path, "%s/%s", GDTEST_TOP_DIR, file_im); - - fp = fopen(path, "rb"); - - if (!fp) { - gdTestErrorMsg("opening Jpeg %s for reading failed.\n", path); - return 1; - } - + fp = gdTestFileOpen(file_im); im = gdImageCreateFromJpeg(fp); - fclose(fp); if (!im) { - gdTestErrorMsg("loading %s failed.\n", path); + gdTestErrorMsg("loading %s failed.\n", file_im); return 1; } @@ -51,12 +41,13 @@ int main() return 1; } - sprintf(path, "%s/%s_%03d_exp.png", GDTEST_TOP_DIR, file_exp, angle); - + sprintf(filename, "bug00067_%03d_exp.png", angle); + path = gdTestFilePath2("gdimagerotate", filename); if (!gdAssertImageEqualsToFile(path, exp)) { gdTestErrorMsg("comparing rotated image to %s failed.\n", path); error += 1; } + free(path); gdImageDestroy(exp); } |