diff options
| author | Berke Güzel <wenekar1@gmail.com> | 2026-10-11 21:53:42 +0300 |
|---|---|---|
| committer | Berke Güzel <wenekar1@gmail.com> | 2026-10-11 21:53:42 +0300 |
| commit | 927ae621c9a3d46dbc401b8e9ea7bbed1bf2e97b (patch) | |
| tree | aeb00c16770dcf5a36d28c1167cc39c6759059fb /tests | |
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.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/test_lifecycle.c | 33 |
1 files changed, 33 insertions, 0 deletions
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 <assert.h> +#include <stdio.h> + +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; +} |
