]>
git.ipfire.org Git - thirdparty/squid.git/blob - test-suite/MemPoolTest.cc
ac0ebc767e90032c91b53c6a5ad034928764ec56
2 * Copyright (C) 1996-2016 The Squid Software Foundation and contributors
4 * Squid software is distributed under GPLv2+ license and includes
5 * contributions from numerous individuals and organizations.
6 * Please see the COPYING and CONTRIBUTORS files for details.
17 /* TODO: put this in a libTest */
19 xassert(const char *msg
, const char *file
, int line
)
21 std::cout
<< "Assertion failed: (" << msg
<< ") at " << file
<< ":" << line
<< std::endl
;
30 class SomethingToAlloc
35 static MemAllocator
*Pool
;
37 MemAllocator
*MemPoolTest::Pool
= NULL
;
42 assert (Pool
== NULL
);
43 Pool
= memPoolCreate("Test Pool", sizeof(SomethingToAlloc
));
45 SomethingToAlloc
*something
= static_cast<SomethingToAlloc
*>(Pool
->alloc());
47 assert (something
->aValue
== 0);
48 something
->aValue
= 5;
49 Pool
->freeOne(something
);
50 SomethingToAlloc
*otherthing
= static_cast<SomethingToAlloc
*>(Pool
->alloc());
51 assert (otherthing
== something
);
52 assert (otherthing
->aValue
== 0);
53 Pool
->freeOne(otherthing
);
57 #endif /* USE_MEMPOOLS */
60 main (int argc
, char **argv
)