summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/test_lifecycle.c33
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;
+}