2 * Copyright 2022 The OpenSSL Project Authors. All Rights Reserved.
4 * Licensed under the Apache License 2.0 (the "License"). You may not use
5 * this file except in compliance with the License. You can obtain a copy
6 * in the file LICENSE in the source distribution or at
7 * https://www.openssl.org/source/license.html
10 #include "internal/packet.h"
11 #include "internal/quic_txpim.h"
14 static int test_txpim(void)
19 QUIC_TXPIM_PKT *pkts[10] = {NULL};
20 QUIC_TXPIM_CHUNK chunks[3];
21 const QUIC_TXPIM_CHUNK *rchunks;
23 if (!TEST_ptr(txpim = ossl_quic_txpim_new()))
26 for (i = 0; i < OSSL_NELEM(pkts); ++i) {
27 if (!TEST_ptr(pkts[i] = ossl_quic_txpim_pkt_alloc(txpim)))
30 if (!TEST_size_t_eq(ossl_quic_txpim_pkt_get_num_chunks(pkts[i]), 0))
33 for (j = 0; j < OSSL_NELEM(chunks); ++j) {
34 chunks[j].stream_id = 100 - j;
35 chunks[j].start = 1000 * i + j * 10;
36 chunks[j].end = chunks[j].start + 5;
38 if (!TEST_true(ossl_quic_txpim_pkt_append_chunk(pkts[i], chunks + j)))
42 if (!TEST_size_t_eq(ossl_quic_txpim_pkt_get_num_chunks(pkts[i]),
46 rchunks = ossl_quic_txpim_pkt_get_chunks(pkts[i]);
47 if (!TEST_uint64_t_eq(rchunks[0].stream_id, 98)
48 || !TEST_uint64_t_eq(rchunks[1].stream_id, 99)
49 || !TEST_uint64_t_eq(rchunks[2].stream_id, 100))
55 for (i = 0; i < OSSL_NELEM(pkts); ++i)
56 if (txpim != NULL && pkts[i] != NULL)
57 ossl_quic_txpim_pkt_release(txpim, pkts[i]);
59 ossl_quic_txpim_free(txpim);