Skip to content
Myr

test program now verifies pngsuite tests against refererence versions

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Sean Barrett · committed by Sean Barrett · parent 8679ce0 · Browse files · 1 file+24 added−2 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+24 added−2 removed

  • tests:+24 added−2 removed

1 file+24 added−2 removed

modified:tests/image_test.c+24 added-2 removed
5 unmodified lines
67#define STB_DEFINE8#include "stb.h"910#define PART11112int main(int argc, char **argv)13{14 int w,h;15 if (argc > 1) {
16 unmodified lines
32 } else33 printf("FAILED 4\n");34 }35 } else {34 int i;36 int i, nope=0;37 #ifdef PART138 char **files = stb_readdir_files("pngsuite/part1");39 #else40 char **files = stb_readdir_files("images");41 #endif42 for (i=0; i < stb_arr_len(files); ++i) {43 int n;44 char **failed = NULL;45 unsigned char *data;
4 unmodified lines
50 data = stbi_load(files[i], &w, &h, 0, 3); if (data) free(data); else stb_arr_push(failed, "3");51 data = stbi_load(files[i], &w, &h, 0, 4); if (data) ; else stb_arr_push(failed, "4");52 if (data) {53 char fname[512];5455 #ifdef PART156 int w2,h2;57 unsigned char *data2;58 stb_splitpath(fname, files[i], STB_FILE_EXT);59 data2 = stbi_load(stb_sprintf("pngsuite/part1_check/%s", fname), &w2, &h2, 0, 4);60 if (!data2)61 printf("FAILED: couldn't load 'pngsuite/part1_check/%s\n", fname);62 else {63 if (w != w2 || h != w2 || 0 != memcmp(data, data2, w*h*4)) {64 printf("FAILED: %s loaded but didn't match part1_check 32-bit version\n", files[i]);65 }66 free(data2);67 }68 #else69 stb_splitpath(fname, files[i], STB_FILE);70 stbi_write_png(stb_sprintf("output/%s.png", fname), w, h, 4, data, w*4);71 #endif72 free(data);73 }74 if (failed) {75 int j;
2 unmodified lines
78 printf("%s ", failed[j]);79 printf(" -- %s\n", files[i]);80 }81 }60 printf("Tested %d files\n", i);82 printf("Tested %d files.\n", i);83 }84 return 0;85}