Skip to content

Commit

Permalink
[tests] Fixed unit tests for CSndRateEstimator.
Browse files Browse the repository at this point in the history
  • Loading branch information
maxsharabayko committed Aug 21, 2024
1 parent eecc176 commit c10d55a
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions test/test_snd_rate_estimator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "gtest/gtest.h"
#include "buffer_tools.h"
#include "sync.h"
#include "packet.h"

using namespace srt;
using namespace std;
Expand Down Expand Up @@ -53,6 +54,7 @@ TEST_F(CSndRateEstFixture, Empty)

TEST_F(CSndRateEstFixture, CBRSending)
{
const size_t hdrBytes = srt::CPacket::HDR_SIZE;
// Generate CBR sending for 2.1 seconds to wrap the buffer around.
for (int i = 0; i < 2100; ++i)
{
Expand All @@ -61,7 +63,7 @@ TEST_F(CSndRateEstFixture, CBRSending)

const auto rate = m_rateEst.getRate();
if (i >= 100)
EXPECT_EQ(rate, 1316000) << "i=" << i;
EXPECT_EQ(rate, 1316000 + 1000 * hdrBytes) << "i=" << i;
else
EXPECT_EQ(rate, 0) << "i=" << i;
}
Expand All @@ -72,6 +74,7 @@ TEST_F(CSndRateEstFixture, CBRSending)
// only for one sampling period.
TEST_F(CSndRateEstFixture, CBRSendingAfterPause)
{
const size_t hdrBytes = srt::CPacket::HDR_SIZE;
// Send 100 packets with 1000 bytes each
for (int i = 0; i < 3100; ++i)
{
Expand All @@ -82,7 +85,7 @@ TEST_F(CSndRateEstFixture, CBRSendingAfterPause)

const auto rate = m_rateEst.getRate();
if (i >= 100 && !(i >= 2000 && i < 2100))
EXPECT_EQ(rate, 1316000) << "i=" << i;
EXPECT_EQ(rate, 1316000 + 1000 * hdrBytes) << "i=" << i;
else
EXPECT_EQ(rate, 0) << "i=" << i;
}
Expand All @@ -92,6 +95,7 @@ TEST_F(CSndRateEstFixture, CBRSendingAfterPause)
// Those empty samples should be included in bitrate estimation.
TEST_F(CSndRateEstFixture, CBRSendingShortPause)
{
const size_t hdrBytes = srt::CPacket::HDR_SIZE;
// Send 100 packets with 1000 bytes each
for (int i = 0; i < 3100; ++i)
{
Expand All @@ -102,9 +106,9 @@ TEST_F(CSndRateEstFixture, CBRSendingShortPause)

const auto rate = m_rateEst.getRate();
if (i >= 1500 && i < 2000)
EXPECT_EQ(rate, 658000) << "i=" << i;
EXPECT_EQ(rate, 658000 + 500 * hdrBytes) << "i=" << i;
else if (i >= 100)
EXPECT_EQ(rate, 1316000) << "i=" << i;
EXPECT_EQ(rate, 1316000 + 1000 * hdrBytes) << "i=" << i;
else
EXPECT_EQ(rate, 0) << "i=" << i;
}
Expand Down

0 comments on commit c10d55a

Please sign in to comment.