]> git.ipfire.org Git - thirdparty/squid.git/blob - test-suite/mem_node_test.cc
Remove Ident protocol support (#1827)
[thirdparty/squid.git] / test-suite / mem_node_test.cc
1 /*
2 * Copyright (C) 1996-2023 The Squid Software Foundation and contributors
3 *
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.
7 */
8
9 /* DEBUG: section 19 Store Memory Primitives */
10
11 #include "squid.h"
12 #include "mem_node.h"
13
14 #include <iostream>
15
16 int
17 main(int, char *[])
18 {
19 mem_node *aNode = new mem_node(0);
20 assert (aNode);
21 /* This will fail if MemPools are disabled. A knock on effect is that
22 * the store will never trim memory
23 */
24 assert (mem_node::InUseCount() == 1);
25 assert (SM_PAGE_SIZE > 50);
26 aNode->nodeBuffer.length = 45;
27 assert (aNode->start() == 0);
28 assert (aNode->end() == 45);
29 assert (aNode->dataRange().size() == 45);
30 aNode->nodeBuffer.offset = 50;
31 assert (aNode->start() == 50);
32 assert (aNode->end() == 95);
33 assert (aNode->dataRange().size() == 45);
34 assert (!aNode->contains(49));
35 assert (aNode->contains(50));
36 assert (aNode->contains(75));
37 assert (!aNode->contains(95));
38 assert (aNode->contains(94));
39 assert (!aNode->canAccept(50));
40 assert (aNode->canAccept(95));
41 assert (!aNode->canAccept(94));
42 aNode->nodeBuffer.length = SM_PAGE_SIZE - 1;
43 assert (aNode->canAccept (50 + SM_PAGE_SIZE - 1));
44 assert (!aNode->canAccept (50 + SM_PAGE_SIZE));
45 assert (mem_node (0) < mem_node (2));
46 assert (!(mem_node (0) < mem_node (0)));
47 assert (!(mem_node (2) < mem_node (0)));
48 delete aNode;
49 assert (mem_node::InUseCount() == 0);
50 return EXIT_SUCCESS;
51 }
52