summaryrefslogtreecommitdiff
path: root/tests/test_lifecycle.c
blob: a57e6b58a303a00c9d818038d6a0c16485771474 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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;
}