mem_node_test.cc
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2017 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  */
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 
bool contains(int64_t const &location) const
Definition: mem_node.cc:92
#define assert(EX)
Definition: assert.h:17
int64_t end() const
Definition: mem_node.cc:74
int64_t offset
Definition: StoreIOBuffer.h:55
static size_t InUseCount()
Definition: mem_node.cc:55
#define SM_PAGE_SIZE
Definition: defines.h:102
StoreIOBuffer nodeBuffer
Definition: mem_node.h:35
int main(int, char *[])
Range< int64_t > dataRange() const
Definition: mem_node.cc:80
int64_t start() const
Definition: mem_node.cc:67
bool canAccept(int64_t const &location) const
Definition: mem_node.cc:102

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors