From 1bca65ae9a677476dbaeab6a74c0f1e4a749319a Mon Sep 17 00:00:00 2001 From: TazyFoundSoup Date: Mon, 30 Mar 2026 16:25:06 +1100 Subject: fix(png/test): Use new context design in open_png test --- tests/format/image/png/png_open.c | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) (limited to 'tests/format') diff --git a/tests/format/image/png/png_open.c b/tests/format/image/png/png_open.c index 0249978..030c7cf 100644 --- a/tests/format/image/png/png_open.c +++ b/tests/format/image/png/png_open.c @@ -1,32 +1,42 @@ +#include +#include #include -#include +#include #include -ff_result fftest_rgb2x2() { - FILE* file = fopen("assets/rgb2x2.png", "rb"); - if (!file) return FF_RESULT_ERROR_INVALID_FILE; - - ff_stream stream = ff_create_file_stream(file); - if (stream.user == NULL) { - fclose(file); +ff_result fftest_rgb2x2(ff_ctx* ctx) { + FILE* file = fopen("tests/format/image/png/assets/rgb2x2.png", "rb"); + if (!file) { + printf("file failed to open\n"); return FF_RESULT_ERROR_INVALID_FILE; } - ff_png_ctx* ctx = NULL; - ff_result res = ff_open_png(&stream, &ctx, FF_ENABLE); + ff_stream stream = ff_create_file_stream(file); + + ff_png_ctx* png_ctx = NULL; + ff_result res = ff_open_png(ctx, &stream, &png_ctx, FF_ENABLE); + + fclose(file); return res; } - int main() { - ff_result res = fftest_rgb2x2(); + ff_allocator alloc = { malloc, free, calloc }; + ff_ctx* ctx = ff_init(&alloc); + + ff_stream out = ff_create_file_stream(stdout); + ff_set_debug_stream(&out, ctx); - if (res == FF_RESULT_WARN_NO_IMPL) { // This is only because I'm still busy. yall just jealous im 13 and better than like 80% of the people who have ever lived at this point in time. + ff_result res = fftest_rgb2x2(ctx); + + if (res == FF_RESULT_WARN_NO_IMPL) { printf("Works!\n"); } else { printf("Doesn't work :(\n"); } + ff_cleanup(ctx); + return 0; } -- cgit v1.2.3