add testcase for gdimagecreatefromgd2part

master
wilson chen 2020-02-26 23:52:52 +08:00 committed by GitHub
parent 04bb9a08b3
commit ef952d4ca5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 38 additions and 0 deletions

View File

@ -3,6 +3,7 @@
/bug00309
/bug00354
/bug00383
/createimagefromgd2part
/createimagefromgd2partptr
/gd2_empty_file
/gd2_im2im

View File

@ -6,6 +6,7 @@ LIST(APPEND TESTS_FILES
bug00309
bug00354
bug00383
createimagefromgd2part
createimagefromgd2partptr
gd2_empty_file
php_bug_72339

View File

@ -6,6 +6,7 @@ libgd_test_programs += \
gd2/bug00309 \
gd2/bug00354 \
gd2/bug00383 \
gd2/createimagefromgd2part \
gd2/createimagefromgd2partptr \
gd2/gd2_empty_file \
gd2/php_bug_72339 \

View File

@ -0,0 +1,35 @@
/**
*Base test for gdImageCreateFromGd2Part()
*/
#include "gd.h"
#include "gdtest.h"
#include <stdio.h>
#include <stdlib.h>
int main()
{
gdImagePtr im;
FILE *p;
int expected_color = 0xffffff;
int actual_color = 0;
p = gdTestFileOpen2("gd2", "conv_test.gd2");
if (!p) {
gdTestErrorMsg("failed, connot open gd2 file: conv_test.gd2");
return 1;
}
im = gdImageCreateFromGd2Part(p, 3, 3, 3, 3);
fclose(p);
if (!im) {
return 1;
}
actual_color = gdImageGetPixel(im, 2, 2);
gdImageDestroy(im);
gdTestAssert(expected_color == actual_color);
return gdNumFailures();
}