]>
git.ipfire.org Git - thirdparty/squid.git/blob - test-suite/mem_node_test.cc
2 * Copyright (C) 1996-2014 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.
9 /* DEBUG: section 19 Store Memory Primitives */
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
;
27 main(int argc
, char **argv
)
29 mem_node
*aNode
= new mem_node(0);
31 /* This will fail if MemPools are disabled. A knock on effect is that
32 * the store will never trim memory
34 assert (mem_node::InUseCount() == 1);
35 assert (SM_PAGE_SIZE
> 50);
36 aNode
->nodeBuffer
.length
= 45;
37 assert (aNode
->start() == 0);
38 assert (aNode
->end() == 45);
39 assert (aNode
->dataRange().size() == 45);
40 aNode
->nodeBuffer
.offset
= 50;
41 assert (aNode
->start() == 50);
42 assert (aNode
->end() == 95);
43 assert (aNode
->dataRange().size() == 45);
44 assert (!aNode
->contains(49));
45 assert (aNode
->contains(50));
46 assert (aNode
->contains(75));
47 assert (!aNode
->contains(95));
48 assert (aNode
->contains(94));
49 assert (!aNode
->canAccept(50));
50 assert (aNode
->canAccept(95));
51 assert (!aNode
->canAccept(94));
52 aNode
->nodeBuffer
.length
= SM_PAGE_SIZE
- 1;
53 assert (aNode
->canAccept (50 + SM_PAGE_SIZE
- 1));
54 assert (!aNode
->canAccept (50 + SM_PAGE_SIZE
));
55 assert (mem_node (0) < mem_node (2));
56 assert (!(mem_node (0) < mem_node (0)));
57 assert (!(mem_node (2) < mem_node (0)));
59 assert (mem_node::InUseCount() == 0);