MCPcopy Create free account
hub / github.com/Haivision/srt / TEST

Function TEST

test/test_unitqueue.cpp:17–31  ·  view source on GitHub ↗

Create CUnitQueue with queue size of 4 units. The size of 4 is chosen on purpose, because CUnitQueue::getNextAvailUnit(..) has the following condition `if (m_iCount * 10 > m_iSize * 9)`. With m_iSize = 4 it will be false up until m_iCount becomes 4. And there was an issue in getNextAvailUnit(..) in taking the very last element of the queue (it was skipped).

Source from the content-addressed store, hash-verified

15/// And there was an issue in getNextAvailUnit(..) in taking
16/// the very last element of the queue (it was skipped).
17TEST(CUnitQueue, Increase)
18{
19 srt::TestInit srtinit;
20 const int buffer_size_pkts = 4;
21 CUnitQueue unit_queue(buffer_size_pkts, 1500);
22
23 vector<CUnit*> taken_units;
24 for (int i = 0; i < 5 * buffer_size_pkts; ++i)
25 {
26 CUnit* unit = unit_queue.getNextAvailUnit();
27 ASSERT_NE(unit, nullptr);
28 unit_queue.makeUnitTaken(unit);
29 taken_units.push_back(unit);
30 }
31}
32
33/// Create CUnitQueue with queue size of 4 units.
34/// Then after requesting the 5th unit, free the previous

Callers

nothing calls this directly

Calls 9

getNextAvailUnitMethod · 0.80
makeUnitTakenMethod · 0.80
push_backMethod · 0.80
makeUnitFreeMethod · 0.80
sizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
clearMethod · 0.45
capacityMethod · 0.45

Tested by

no test coverage detected