test_engine_ctor.c revision 06b2a236
1/* Copyright (c) 2017 - 2021 LiteSpeed Technologies Inc.  See LICENSE. */
2#include <assert.h>
3#include <stdlib.h>
4#include <string.h>
5
6#include "lsquic.h"
7
8
9int
10main (void)
11{
12    struct lsquic_engine_settings settings;
13    lsquic_engine_t *engine;
14    unsigned versions;
15    const unsigned flags = LSENG_SERVER;
16
17    lsquic_engine_init_settings(&settings, flags);
18
19    struct lsquic_engine_api api;
20    memset(&api, 0, sizeof(api));
21    api.ea_settings = &settings;
22    api.ea_packets_out = (void *) (uintptr_t) 1;
23    api.ea_stream_if = (void *) (uintptr_t) 2;
24
25    engine = lsquic_engine_new(flags, &api);
26    assert(engine);
27    versions = lsquic_engine_quic_versions(engine);
28    assert(versions == settings.es_versions);
29    lsquic_engine_destroy(engine);
30
31    settings.es_versions |= (1 << N_LSQVER /* Invalid value by definition */);
32    engine = lsquic_engine_new(flags, &api);
33    assert(!engine);
34
35    return 0;
36}
37