summaryrefslogtreecommitdiff
path: root/toxav/rtp_test.cpp
blob: 76e369f02c25bd701a0ad215ab0b9718e234c213 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include "rtp.h"

#include "../toxcore/crypto_core.h"

#include <gtest/gtest.h>

TEST(Rtp, Deserialisation) {
    RTPHeader header;
    random_bytes((uint8_t *)&header, sizeof header);

    uint8_t rdata[sizeof(RTPHeader)];
    EXPECT_EQ(rtp_header_pack(rdata, &header), RTP_HEADER_SIZE);

    RTPHeader unpacked;
    EXPECT_EQ(rtp_header_unpack(rdata, &unpacked), RTP_HEADER_SIZE);

    EXPECT_EQ(std::string((char const *)&header, sizeof header),
              std::string((char const *)&unpacked, sizeof unpacked));
}