11namespace tracktion {
inline namespace graph
14#if GRAPH_UNIT_TESTS_AUDIOBUFFERPOOL
19 AudioBufferPoolTests()
20 :
juce::UnitTest (
"AudioBufferPool",
"tracktion_graph") {}
23 void runTest()
override
29 void runAllocationTests()
31 using namespace choc::buffer;
33 beginTest (
"Allocation");
35 const auto size = Size::create (2, 128);
40 expectEquals<int> ((
int) pool.getNumBuffers(), 0);
41 pool.release (ChannelArrayBuffer<float> (size));
42 expectEquals<int> ((
int) pool.getNumBuffers(), 1);
43 expectEquals<int> ((
int) pool.getAllocatedSize(), (
int) SeparateChannelLayout<float>::getBytesNeeded (size));
47 AudioBufferPool pool (1);
48 expectEquals<int> ((
int) pool.getNumBuffers(), 0);
49 pool.release (ChannelArrayBuffer<float> (size));
50 expectEquals<int> ((
int) pool.getNumBuffers(), 1);
51 expectEquals<int> ((
int) pool.getAllocatedSize(), (
int) SeparateChannelLayout<float>::getBytesNeeded (size));
55 AudioBufferPool pool (2);
56 pool.reserve (1, size);
58 pool.release (ChannelArrayBuffer<float> (size));
60 auto buffer = pool.allocate (size);
61 const auto bufferSize = buffer.getSize();
62 expectGreaterOrEqual ((
int) bufferSize.numFrames, (
int)
size.numFrames);
63 expectGreaterOrEqual ((
int) bufferSize.numChannels, (
int)
size.numChannels);
64 expectEquals<int> ((
int) pool.getAllocatedSize(), (
int) SeparateChannelLayout<float>::getBytesNeeded (size));
66 expectEquals<int> ((
int) pool.getNumBuffers(), 1);
67 pool.release (std::move (buffer));
68 expectEquals<int> ((
int) pool.getNumBuffers(), 2);
74static AudioBufferPoolTests audioBufferPoolTests;