Squid Web Cache master
Loading...
Searching...
No Matches
mem_node_test.cc
Go to the documentation of this file.
1/*
2 * Copyright (C) 1996-2025 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
16int
17main(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 */
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;
50 return EXIT_SUCCESS;
51}
52
#define assert(EX)
Definition assert.h:17
StoreIOBuffer nodeBuffer
Definition mem_node.h:35
Range< int64_t > dataRange() const
Definition mem_node.cc:83
bool canAccept(int64_t const &location) const
Definition mem_node.cc:105
bool contains(int64_t const &location) const
Definition mem_node.cc:95
static size_t InUseCount()
Definition mem_node.cc:58
int64_t end() const
Definition mem_node.cc:77
int64_t start() const
Definition mem_node.cc:70
#define SM_PAGE_SIZE
Definition defines.h:63
int main()