File indexing completed on 2025-02-16 04:37:45
0001 /* 0002 SPDX-FileCopyrightText: 2011 Joris Guisson <joris.guisson@gmail.com> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 #include <QObject> 0007 #include <QtTest> 0008 #include <util/bufferpool.h> 0009 #include <util/log.h> 0010 0011 class BufferPoolTest : public QObject 0012 { 0013 Q_OBJECT 0014 public: 0015 private Q_SLOTS: 0016 void initTestCase() 0017 { 0018 bt::InitLog("bufferpooltest.log"); 0019 } 0020 0021 void cleanupTestCase() 0022 { 0023 } 0024 0025 void testPool() 0026 { 0027 bt::BufferPool::Ptr pool(new bt::BufferPool()); 0028 pool->setWeakPointer(pool.toWeakRef()); 0029 0030 bt::Buffer::Ptr a = pool->get(1000); 0031 QVERIFY(a); 0032 QVERIFY(a->size() == 1000); 0033 QVERIFY(a->capacity() == 1000); 0034 a.clear(); 0035 0036 a = pool->get(500); 0037 QVERIFY(a); 0038 QVERIFY(a->size() == 500); 0039 QVERIFY(a->capacity() == 1000); 0040 0041 bt::Buffer::Ptr b = pool->get(2000); 0042 QVERIFY(b); 0043 QVERIFY(b->size() == 2000); 0044 QVERIFY(b->capacity() == 2000); 0045 } 0046 }; 0047 0048 QTEST_MAIN(BufferPoolTest) 0049 0050 #include "bufferpooltest.moc"