test_senhist.c revision f07b3eae
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>
7f07b3eaeSTyler Young#ifdef _MSC_VER
8f07b3eaeSTyler Young#include "vc_compat.h"
9f07b3eaeSTyler Young#endif
1050aadb33SDmitri Tikhonov#include "lsquic_int_types.h"
1150aadb33SDmitri Tikhonov#include "lsquic_senhist.h"
125392f7a3SLiteSpeed Tech#include "lsquic_types.h"
1316a9b66aSDmitri Tikhonov#include "lsquic_logger.h"
1450aadb33SDmitri Tikhonov
1550aadb33SDmitri Tikhonov
1650aadb33SDmitri Tikhonovint
1750aadb33SDmitri Tikhonovmain (void)
1850aadb33SDmitri Tikhonov{
198ae5ecb4SDmitri Tikhonov    struct lsquic_senhist hist = { 0, 0
20b93f59beSBob Perper#if !LSQUIC_SENHIST_FATAL
21b93f59beSBob Perper        , 0
22b93f59beSBob Perper#endif
23b93f59beSBob Perper    };
2450aadb33SDmitri Tikhonov    lsquic_packno_t packno;
2550aadb33SDmitri Tikhonov
265392f7a3SLiteSpeed Tech    lsquic_senhist_init(&hist, 0);
2750aadb33SDmitri Tikhonov
2816a9b66aSDmitri Tikhonov    assert(0 == lsquic_senhist_largest(&hist));
2950aadb33SDmitri Tikhonov
3050aadb33SDmitri Tikhonov    for (packno = 1; packno < 100; ++packno)
3150aadb33SDmitri Tikhonov        lsquic_senhist_add(&hist, packno);
3250aadb33SDmitri Tikhonov
3316a9b66aSDmitri Tikhonov    assert(99 == lsquic_senhist_largest(&hist));
3450aadb33SDmitri Tikhonov
3550aadb33SDmitri Tikhonov    lsquic_senhist_cleanup(&hist);
3650aadb33SDmitri Tikhonov
3750aadb33SDmitri Tikhonov    return 0;
3850aadb33SDmitri Tikhonov}
39