Files
LCUI/lib/pandagl/tests/test_image_reader.c
Liu faa7058837 test: reorganize test suite with xmake test integration
Restructure the test infrastructure with these changes:

* Extend libctest with ctest_suite_t, ctest_parse_args, ctest_run_suites and CTEST_MAIN macro to standardize test entry points; support --grep / --grep= / --list / --interactive flags; add ctest-tests for self-tests.

* Regroup tests by lib boundary: sink unit tests into lib/<name>/tests/ with <lib>_<topic> entry function names, move fixtures into lib/<name>/tests/fixtures/, rename top-level tests/cases/ to tests/integration/ for cross-lib integration tests.

* Add tests/scenes/ for reusable widget tree builders shared by integration cases and visual preview binaries; add tests/previews/ with 4 diagnostic binaries (flex_layout, block_layout, widget_opacity, scrollbar).

* Rewrite all describe/equal description strings using 'should ...' style or noun topic names; drop redundant lcui_quit/lcui_main calls from integration cases.

* Integrate xmake test via add_tests(\default\) and a shared tests.runnable rule defined in the root xmake.lua; the rule wraps the test binary with drmemory (Windows) or valgrind (Linux) when option memcheck=y.

* Drop the lcui-tests aggregation: lcui-tests now contains only integration cases and scenes, not the union of lib tests. Use xmake test to run everything across libs.

* Fix .clang-format: InsertNewlineAtEndOfFile -> InsertNewlineAtEOF (correct key for clang-format 16+).

* Update AGENTS.md with the new test layout, naming rules, description style and run commands.

* Update CI to use xmake test and xmake f --memcheck=y instead of per-lib runs.
2026-05-24 17:56:23 +08:00

36 lines
1.1 KiB
C

/*
* lib/pandagl/tests/test_image_reader.c
*
* Copyright (c) 2023, Liu Chao <i@lc-soft.io> All rights reserved.
*
* SPDX-License-Identifier: MIT
*
* This file is part of LCUI, distributed under the MIT License found in the
* LICENSE.TXT file in the root directory of this source tree.
*/
#include <stdio.h>
#include <pandagl.h>
#include <yutil.h>
#include <ctest.h>
void test_pandagl_image_reader(void)
{
pd_canvas_t img;
int i;
char file[256], *formats[] = { "png", "bmp", "jpg" };
for (i = 0; i < 3; ++i) {
pd_canvas_init(&img);
snprintf(file, 255, "test_image_reader.%s", formats[i]);
logger_debug("image file: %s\n", file);
ctest_equal_int("should read image from file successfully",
pd_read_image_from_file(file, &img), 0);
ctest_equal_int("should have correct image width", img.width,
91);
ctest_equal_int("should have correct image height", img.height,
69);
pd_canvas_destroy(&img);
}
}