summaryrefslogtreecommitdiff
path: root/tests/version_test.c
blob: 9893e2f01c4aef1fd2d1470f1a536dd0446c8b4b (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
#include "wsap_vtcore/wsap_vtcore.h"

#include <assert.h>
#include <stdio.h>
#include <string.h>

/* The project version from meson.build. The build defines it. */
#ifndef WSAP_VTCORE_TEST_PROJECT_VERSION
#error "define WSAP_VTCORE_TEST_PROJECT_VERSION as the project version, such as \"0.1.0\""
#endif

int main(void)
{
    char text[32];
    snprintf(text, sizeof(text), "%d.%d.%d",
        WSAP_VTCORE_VERSION_MAJOR, WSAP_VTCORE_VERSION_MINOR, WSAP_VTCORE_VERSION_PATCH);
    assert(!strcmp(text, WSAP_VTCORE_TEST_PROJECT_VERSION));

    int major, minor, patch;
    assert(sscanf(WSAP_VTCORE_TEST_PROJECT_VERSION, "%d.%d.%d", &major, &minor, &patch) == 3);
    assert(WSAP_VTCORE_VERSION_CODE == WSAP_VTCORE_VERSION(major, minor, patch));
    assert(wsap_vtcore_version() == WSAP_VTCORE_VERSION_CODE);

    assert(WSAP_VTCORE_VERSION(0, 2, 0) > WSAP_VTCORE_VERSION(0, 1, 255));
    assert(WSAP_VTCORE_VERSION(1, 0, 0) > WSAP_VTCORE_VERSION(0, 255, 255));
    return 0;
}