From 927ae621c9a3d46dbc401b8e9ea7bbed1bf2e97b Mon Sep 17 00:00:00 2001 From: Berke Güzel Date: Sun, 11 Oct 2026 21:53:42 +0300 Subject: initial: Yet Another Surface Library (YASL) 0.1.0 A minimal, modern desktop window surface library in C. Supports Wayland on Linux and Cocoa/Metal on macOS with presentation timing, fractional scaling, IME, and CSD. --- tests/test_lifecycle.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 tests/test_lifecycle.c (limited to 'tests/test_lifecycle.c') diff --git a/tests/test_lifecycle.c b/tests/test_lifecycle.c new file mode 100644 index 0000000..a57e6b5 --- /dev/null +++ b/tests/test_lifecycle.c @@ -0,0 +1,33 @@ +#include "yasl/yasl.h" +#include +#include + +static void test_scaling(void) +{ + assert(yasl_scale_to_device(10.0, 120) == 10); + assert(yasl_scale_to_device(10.0, 240) == 20); + assert(yasl_scale_to_logical(20, 240) == 10); +} + +static void test_timing_clock(void) +{ + struct yasl_frame_clock clock = { .refresh_ns = 16666666.0 }; + yasl_clock_presented(&clock, 1000000000, true); + assert(clock.last_present_ns == 1000000000); + uint64_t next = yasl_clock_next_present_ns(&clock); + assert(next > 1000000000); + + yasl_clock_note_resize(&clock, 500000); + struct yasl_resize_stats stats; + yasl_clock_resize_stats(&clock, &stats); + assert(stats.count == 1); + assert(stats.max_us == 500.0); +} + +int main(void) +{ + test_scaling(); + test_timing_clock(); + printf("All YASL basic tests passed.\n"); + return 0; +} -- cgit v1.2.3