summaryrefslogtreecommitdiff
path: root/tests/test_lifecycle.c
diff options
context:
space:
mode:
authorBerke Güzel <wenekar1@gmail.com>2026-10-14 13:13:52 +0300
committerBerke Güzel <wenekar1@gmail.com>2026-10-14 13:13:52 +0300
commit1ab3e5a123109704789c2768e11a4f9af515821d (patch)
tree31ee03e58093a58100c6eb58681d5d29648a5ddd /tests/test_lifecycle.c
parentd86fa6215d40caa7852dbbd6a8cf4aa8e89dd879 (diff)
Redefine public and rendering APIs with explicit contracts
Diffstat (limited to 'tests/test_lifecycle.c')
-rw-r--r--tests/test_lifecycle.c45
1 files changed, 29 insertions, 16 deletions
diff --git a/tests/test_lifecycle.c b/tests/test_lifecycle.c
index a334fed..08213b0 100644
--- a/tests/test_lifecycle.c
+++ b/tests/test_lifecycle.c
@@ -1,24 +1,37 @@
#include <yasl/yasl.h>
#include <yasl/cpu.h>
#include <yasl/gl.h>
+#include <yasl/metal.h>
#include <yasl/desktop.h>
#include <assert.h>
int main(void)
{
- yasl_shutdown(); yasl_wake();
- yasl_event e={.type=YASL_EVENT_QUIT};
- assert(yasl_wait_event(&e,0)==-1 && e.type==YASL_EVENT_NONE);
- assert(yasl_get_error(NULL)==YASL_ERROR_NOT_INITIALIZED);
- assert(!yasl_set_backend((enum yasl_backend)999));
- assert(yasl_get_error(NULL)==YASL_ERROR_INVALID);
- assert(!yasl_surface_create("bad",0,64,0));
- assert(!yasl_surface_create("bad",64,64,16));
- assert(yasl_set_app_id("org.yasl.api"));
- assert(yasl_set_backend(YASL_BACKEND_AUTO));
- yasl_surface_destroy(NULL);
- assert(yasl_time_ns()>0);
- const char *description=NULL;yasl_get_error(&description);assert(description);
- int w=9,h=9;yasl_surface_get_size(NULL,&w,&h);assert(w==0&&h==0);
- assert(yasl_executable_path(NULL,0)>0);
- yasl_shutdown();return 0;
+ assert(yasl_shutdown() == 0);
+ yasl_wake();
+ yasl_event event = {.type = YASL_EVENT_QUIT};
+ assert(yasl_wait_event(&event, 0) == -ENODEV && event.type == YASL_EVENT_NONE);
+ assert(yasl_wait_event(NULL, 0) == -EINVAL);
+ assert(yasl_init(&(struct yasl_options){.backend = (enum yasl_backend)999}) == -EINVAL);
+ assert(!yasl_surface_create(NULL) && errno == EINVAL);
+ struct yasl_surface_options options = {.width = 0, .height = 64};
+ assert(!yasl_surface_create(&options) && errno == EINVAL);
+ options.width = 64;
+ options.flags = 16;
+ assert(!yasl_surface_create(&options) && errno == EINVAL);
+ options.flags = 0;
+ options.type = (enum yasl_surface_type)99;
+ assert(!yasl_surface_create(&options) && errno == EINVAL);
+ struct yasl_cpu_buffer buffer = {.width = 9};
+ assert(yasl_cpu_acquire(NULL, &buffer) == -ENODEV && !buffer.pixels && !buffer.width);
+ assert(yasl_cpu_acquire(NULL, NULL) == -EINVAL);
+ CAMetalLayer *layer = NULL;
+ assert(yasl_metal_get_layer(NULL, &layer) == -ENODEV && !layer);
+ assert(yasl_surface_destroy(NULL) == 0);
+ assert(yasl_time_ns() > 0);
+ int w = 9, h = 9;
+ yasl_surface_get_size(NULL, &w, &h);
+ assert(w == 0 && h == 0);
+ assert(yasl_get_executable_path(NULL, 0) > 0);
+ assert(yasl_shutdown() == 0);
+ return 0;
}