1 /*
2  * Copyright (C) 1996-2021 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 #ifndef SQUID_TESTS_CAPTURINGSTORE_ENTRY_H
10 #define SQUID_TESTS_CAPTURINGSTORE_ENTRY_H
11 
12 #include "Store.h"
13 
14 /* class that captures various call data for test analysis */
15 
16 class CapturingStoreEntry : public StoreEntry
17 {
18     MEMPROXY_CLASS(CapturingStoreEntry);
19 
20 public:
CapturingStoreEntry()21     CapturingStoreEntry() : _buffer_calls(0), _flush_calls(0) {}
22 
23     String _appended_text;
24     int _buffer_calls;
25     int _flush_calls;
26 
buffer()27     virtual void buffer() {
28         _buffer_calls += 1;
29     }
30 
flush()31     virtual void flush() {
32         _flush_calls += 1;
33     }
34 
append(char const * buf,int len)35     virtual void append(char const * buf, int len) {
36         if (!buf || len < 0) // old 'String' can't handle these cases
37             return;
38         _appended_text.append(buf, len);
39     }
40 };
41 
42 #endif
43 
44