test_senhist.c revision 06b2a236
106b2a236SDmitri Tikhonov/* Copyright (c) 2017 - 2021 LiteSpeed Technologies Inc.  See LICENSE. */
250aadb33SDmitri Tikhonov#include <assert.h>
350aadb33SDmitri Tikhonov#include <stdio.h>
450aadb33SDmitri Tikhonov#include <stdlib.h>
550aadb33SDmitri Tikhonov#include <string.h>
616a9b66aSDmitri Tikhonov#include <inttypes.h>
750aadb33SDmitri Tikhonov
850aadb33SDmitri Tikhonov#include "lsquic_int_types.h"
950aadb33SDmitri Tikhonov#include "lsquic_senhist.h"
105392f7a3SLiteSpeed Tech#include "lsquic_types.h"
1116a9b66aSDmitri Tikhonov#include "lsquic_logger.h"
1250aadb33SDmitri Tikhonov
1350aadb33SDmitri Tikhonov
1450aadb33SDmitri Tikhonovint
1550aadb33SDmitri Tikhonovmain (void)
1650aadb33SDmitri Tikhonov{
178ae5ecb4SDmitri Tikhonov    struct lsquic_senhist hist = { 0, 0
18b93f59beSBob Perper#if !LSQUIC_SENHIST_FATAL
19b93f59beSBob Perper        , 0
20b93f59beSBob Perper#endif
21b93f59beSBob Perper    };
2250aadb33SDmitri Tikhonov    lsquic_packno_t packno;
2350aadb33SDmitri Tikhonov
245392f7a3SLiteSpeed Tech    lsquic_senhist_init(&hist, 0);
2550aadb33SDmitri Tikhonov
2616a9b66aSDmitri Tikhonov    assert(0 == lsquic_senhist_largest(&hist));
2750aadb33SDmitri Tikhonov
2850aadb33SDmitri Tikhonov    for (packno = 1; packno < 100; ++packno)
2950aadb33SDmitri Tikhonov        lsquic_senhist_add(&hist, packno);
3050aadb33SDmitri Tikhonov
3116a9b66aSDmitri Tikhonov    assert(99 == lsquic_senhist_largest(&hist));
3250aadb33SDmitri Tikhonov
3350aadb33SDmitri Tikhonov    lsquic_senhist_cleanup(&hist);
3450aadb33SDmitri Tikhonov
3550aadb33SDmitri Tikhonov    return 0;
3650aadb33SDmitri Tikhonov}
37