BDE 4.14.0 Production release
Loading...
Searching...
No Matches
bslma_testallocatormonitor.h
Go to the documentation of this file.
1/// @file bslma_testallocatormonitor.h
2///
3/// The content of this file has been pre-processed for Doxygen.
4///
5
6
7// bslma_testallocatormonitor.h -*-C++-*-
8#ifndef INCLUDED_BSLMA_TESTALLOCATORMONITOR
9#define INCLUDED_BSLMA_TESTALLOCATORMONITOR
10
11#include <bsls_ident.h>
12BSLS_IDENT("$Id: $")
13
14/// @defgroup bslma_testallocatormonitor bslma_testallocatormonitor
15/// @brief Provide a mechanism to summarize `bslma::TestAllocator` object use.
16/// @addtogroup bsl
17/// @{
18/// @addtogroup bslma
19/// @{
20/// @addtogroup bslma_testallocatormonitor
21/// @{
22///
23/// <h1> Outline </h1>
24/// * <a href="#bslma_testallocatormonitor-purpose"> Purpose</a>
25/// * <a href="#bslma_testallocatormonitor-classes"> Classes </a>
26/// * <a href="#bslma_testallocatormonitor-description"> Description </a>
27/// * <a href="#bslma_testallocatormonitor-statistics"> Statistics </a>
28/// * <a href="#bslma_testallocatormonitor-usage"> Usage </a>
29/// * <a href="#bslma_testallocatormonitor-example-1-standard-usage"> Example 1: Standard Usage </a>
30///
31/// # Purpose {#bslma_testallocatormonitor-purpose}
32/// Provide a mechanism to summarize `bslma::TestAllocator` object use.
33///
34/// # Classes {#bslma_testallocatormonitor-classes}
35///
36/// - bslma::TestAllocatorMonitor: `bslma::TestAllocator` summary mechanism
37///
38/// @see bslma_testallocator
39///
40/// # Description {#bslma_testallocatormonitor-description}
41/// This component provides a single mechanism class,
42/// `bslma::TestAllocatorMonitor`, which is used, in concert with
43/// `bslma::TestAllocator`, in the implementation of test drivers. The
44/// `bslma::TestAllocatorMonitor` class provides boolean accessors indicating
45/// whether associated test allocator state has changed (or not) since
46/// construction of the monitor. Using `bslma::TestAllocatorMonitor` objects
47/// often result in test cases that are more concise, easier to read, and less
48/// error prone than test cases that directly access the test allocator for
49/// state information.
50///
51/// ## Statistics {#bslma_testallocatormonitor-statistics}
52///
53///
54/// The test allocator statistics tracked by the test allocator monitor along
55/// with the boolean accessors used to observe a change in those statistics are
56/// shown in the table below. The change (or lack of change) reported by these
57/// accessors are relative to the value of the test allocator statistic at the
58/// construction of the monitor. Note that each of these statistics count
59/// blocks of memory (i.e., number of allocations from the allocator), and do
60/// not depend on the number of bytes in those allocated blocks.
61/// @code
62/// Statistic Is-Same Method Is-Up Method Is-Down Method
63/// -------------- -------------- ------------ --------------
64/// numBlocksInUse isInUseSame isInUseUp isInUseDown
65/// numBlocksMax isMaxSame isMaxUp none
66/// numBlocksTotal isTotalSame isTotalUp none
67/// @endcode
68/// The `numBlocksMax` and `numBlocksTotal` statistics have values that are
69/// monotonically non-decreasing; hence, they need no "Is-Down" methods. Note
70/// that if a monitor is created for an allocator with outstanding blocks ("in
71/// use"), then it is possible for the allocator's count of outstanding blocks
72/// to drop below the value seen by the monitor at construction.
73///
74/// ## Usage {#bslma_testallocatormonitor-usage}
75///
76///
77/// This section illustrates intended use of this component.
78///
79/// ### Example 1: Standard Usage {#bslma_testallocatormonitor-example-1-standard-usage}
80///
81///
82/// Classes taking `bslma::allocator` objects have many requirements (and thus,
83/// many testing concerns) that other classes do not. Here we illustrate how
84/// `bslma::TestAllocatorMonitor` objects (in conjunction with
85/// `bslma::TestAllocator` objects) can be used in a test driver to succinctly
86/// address many concerns of an object's use of allocators.
87///
88/// First, for a test subject, we introduce `MyClass`, an unconstrained
89/// attribute class having a single, null-terminated ascii string attribute,
90/// `description`. For the sake of brevity, `MyClass` defines only a default
91/// constructor, a primary manipulator (the `setDescription` method), and a
92/// basic accessor (the `description` method). These suffice for the purposes
93/// of these example. Note that a proper attribute class would also implement
94/// value and copy constructors, `operator==`, an accessor for the allocator,
95/// and other methods.
96/// @code
97/// class MyClass {
98/// // This unconstrained (value-semantic) attribute class has a single,
99/// // null-terminated ascii string attribute, 'description'.
100///
101/// // DATA
102/// size_t d_capacity; // available memory
103/// char *d_description_p; // string data
104/// bslma::Allocator *d_allocator_p; // held, not owned
105///
106/// public:
107/// // CREATORS
108/// explicit MyClass(bslma::Allocator *basicAllocator = 0);
109/// // Create a 'MyClass' object having the (default) attribute values:
110/// //..
111/// // description() == ""
112/// //..
113/// // Optionally specify a 'basicAllocator' used to supply memory. If
114/// // 'basicAllocator' is 0, the currently installed default allocator
115/// // is used.
116///
117/// ~MyClass();
118/// // Destroy this object.
119///
120/// // MANIPULATORS
121/// void setDescription(const char *value);
122/// // Set the null-terminated ascii string 'description' attribute of
123/// // this object to the specified 'value'. On completion, the
124/// // 'description' method returns the address of a copy of the ascii
125/// // string at 'value'.
126///
127/// // ACCESSORS
128/// const char *description() const;
129/// // Return the value of the null-terminated ascii string
130/// // 'description' attribute of this object.
131/// };
132///
133/// // ========================================================================
134/// // INLINE FUNCTION DEFINITIONS
135/// // ========================================================================
136///
137/// // -------------
138/// // class MyClass
139/// // -------------
140///
141/// // CREATORS
142/// inline
143/// MyClass::MyClass(bslma::Allocator *basicAllocator)
144/// : d_capacity(0)
145/// , d_description_p(0)
146/// , d_allocator_p(bslma::Default::allocator(basicAllocator))
147/// {
148/// }
149///
150/// inline
151/// MyClass::~MyClass()
152/// {
153/// BSLS_ASSERT_SAFE(0 <= d_capacity);
154///
155/// d_allocator_p->deallocate(d_description_p);
156/// }
157///
158/// // MANIPULATORS
159/// inline
160/// void MyClass::setDescription(const char *value)
161/// {
162/// BSLS_ASSERT_SAFE(value);
163///
164/// size_t size = std::strlen(value) + 1;
165/// if (size > d_capacity) {
166/// char *newMemory = (char *) d_allocator_p->allocate(size);
167/// d_allocator_p->deallocate(d_description_p);
168/// d_description_p = newMemory;
169/// d_capacity = size;
170///
171/// }
172/// std::memcpy(d_description_p, value, size);
173/// }
174/// @endcode
175/// Notice that the implementation of the manipulator allocates/deallocates
176/// memory *before* updating the object. This ordering leaves the object
177/// unchanged in case the allocator throws an exception (part of the strong
178/// exception guarantee). This is an implementation detail, not a part of the
179/// contract (in this example).
180/// @code
181/// // ACCESSORS
182/// inline
183/// const char *MyClass::description() const
184/// {
185/// return d_description_p ? d_description_p : "";
186/// }
187/// @endcode
188/// Then, we design a test-driver for `MyClass`. Our allocator-related concerns
189/// for `MyClass` include:
190/// @code
191/// Concerns:
192/// //: 1 Any memory allocation is from the object allocator.
193/// //:
194/// //: 2 Every object releases any allocated memory at destruction.
195/// //:
196/// //: 3 No accessor allocates any memory.
197/// //:
198/// //: 4 All memory allocation is exception-neutral.
199/// //:
200/// //: 5 QoI: The default constructor allocates no memory.
201/// //:
202/// //: 6 QoI: When possible, memory is cached for reuse.
203/// @endcode
204/// Notice that some of these concerns (e.g., C-5..6) are not part of the
205/// class's documented, contractual behavior. These are classified as Quality
206/// of Implementation (QoI) concerns.
207///
208/// Next, we define a test plan. For example, a plan to test these concerns is:
209/// @code
210/// Plan:
211/// //: 1 Setup global and default allocators:
212/// //:
213/// //: 1 Create two 'bslma::TestAllocator' objects and, for each of these,
214/// //: create an associated 'bslma::TestAllocatorMonitor' object.
215/// //:
216/// //: 2 Install the two allocators as the global and default allocators.
217/// //:
218/// //: 2 Confirm that default construction allocates no memory: (C-5)
219/// //:
220/// //: 1 Construct a 'bslma::TestAllocatorMonitor' object to be used passed
221/// //: to test objects on their construction, and an associated
222/// //:
223/// //: 2 In an inner block, default construct an object of 'MyClass' using
224/// //: the designated "object" test allocator.
225/// //:
226/// //: 3 Allow the object to go out of scope (destroyed). Confirm that no
227/// //: memory has been allocated from any of the allocators.
228/// //:
229/// //: 3 Exercise an object of 'MyClass' such that memory should be allocated,
230/// //: and then confirm that the object allocator (only) is used: (C-2..4,6)
231/// //:
232/// //: 1 In another inner block, default construct a new test object using
233/// //: the (as yet unused) object allocator.
234/// //:
235/// //: 2 Force the test object to allocate memory by setting its
236/// //: 'descriptor' attribute to a value whose size exceeds the size of
237/// //: the object itself. Confirm that the attribute was set and that
238/// //: memory was allocated.
239/// //:
240/// //: 3 Confirm that the primary manipulator (the 'setDescription' method)
241/// //: is exception-neutral (i.e., exceptions from the allocator are
242/// //: propagated and no memory is leaked). Use the
243/// //: 'BSLMA_TESTALLOCATOR_EXCEPTION_TEST_*' macros to manage the test,
244/// //: and use the test allocator monitor to confirm that memory is
245/// //: allocated on the no-exception code path. (C-4)
246/// //:
247/// //: 4 When the object is holding memory, create an additional test
248/// //: allocator monitor allocator for the object allocator. Use the
249/// //: basic accessor (i.e., the 'description' method) to confirm that the
250/// //: object has the expected value. Check this test allocator monitor
251/// //: to confirm that accessor allocated no memory. (C-3)
252/// //:
253/// //: 5 Change the attribute to a smaller value and confirm that the
254/// //: current memory was reused (i.e., no memory is allocated). (C-6)
255/// //:
256/// //: 6 Destroy the test object by allowing it to go out of scope, and
257/// //: confirm that all allocations are returned. (C-2)
258/// //:
259/// //: 4 Confirm that at no time were the global allocator or the default
260/// //: allocator were used. (C-1)
261/// @endcode
262/// The implementation of the plan is shown below:
263///
264/// Then, we implement the first portion of the plan. We create the trio of
265/// test allocators, their respective test allocator monitors, and install two
266/// of the allocators as the global and default allocators:
267/// @code
268/// {
269/// if (verbose) cout << "Setup global and default allocators" << endl;
270///
271/// bslma::TestAllocator ga("global", veryVeryVeryVerbose);
272/// bslma::TestAllocator da("default", veryVeryVeryVerbose);
273/// bslma::TestAllocatorMonitor gam(&ga);
274/// bslma::TestAllocatorMonitor dam(&da);
275///
276/// bslma::Default::setGlobalAllocator(&ga);
277/// assert(0 == bslma::Default::setDefaultAllocator(&da));
278/// @endcode
279/// Then, we default construct a test object using the object allocator, and
280/// then, immediately destroy it. The object allocator monitor, `oam`, shows
281/// that the allocator was not used.
282/// @code
283/// if (verbose) cout << "No allocation by Default Constructor " << endl;
284///
285/// bslma::TestAllocator oa("object", veryVeryVeryVerbose);
286/// bslma::TestAllocatorMonitor oam(&oa);
287///
288/// {
289/// MyClass obj(&oa);
290/// assert(oam.isTotalSame()); // object allocator unused
291/// }
292/// @endcode
293/// Next, we pass the (still unused) object allocator to another test object.
294/// This time, we coerce the object into allocating memory by setting an
295/// attribute. (Setting an attribute larger than the receiving object means
296/// that the object cannot store the data within its own footprint and must
297/// allocate memory.)
298/// @code
299/// if (verbose) cout << "Exercise object" << endl;
300///
301/// {
302/// MyClass obj(&oa);
303///
304/// const char DESCRIPTION1[]="abcdefghijklmnopqrstuvwyz"
305/// "abcdefghijklmnopqrstuvwyz";
306/// assert(sizeof(obj) < sizeof(DESCRIPTION1));
307///
308/// if (veryVerbose) cout << "\tPrimary Manipulator Allocates" << endl;
309///
310/// BSLMA_TESTALLOCATOR_EXCEPTION_TEST_BEGIN(oa) {
311/// if (veryVeryVerbose) { T_ T_ Q(ExceptionTestBody) }
312///
313/// obj.setDescription(DESCRIPTION1);
314/// assert(oam.isTotalUp()); // object allocator was used
315/// assert(oam.isInUseUp()); // some outstanding allocation(s)
316/// assert(oam.isMaxUp()); // a maximum was set
317/// } BSLMA_TESTALLOCATOR_EXCEPTION_TEST_END
318/// @endcode
319/// Notice, as expected, memory was allocated from object allocator.
320///
321/// Now that the allocator has been used, we create a second monitor to capture
322/// the that state. Confirm that the basic accessor (the `description` method)
323/// does not use the allocator.
324/// @code
325/// if (veryVerbose) cout << "\tBasic Accessor does not allocate" << endl;
326///
327/// bslma::TestAllocatorMonitor oam2(&oa); // Captures state of 'oa'
328/// // with outstanding
329/// // allocations.
330///
331/// assert(0 == strcmp(DESCRIPTION1, obj.description()));
332/// assert(oam2.isTotalSame()); // object allocator was not used
333/// @endcode
334/// Next, confirm that when a shorter value is assigned, the existing memory is
335/// reused.
336/// @code
337/// obj.setDescription("a");
338/// assert(0 == std::strcmp("a", obj.description()));
339///
340/// assert(oam2.isTotalSame()); // no allocations
341/// @endcode
342/// Notice that there are no allocations because the object had sufficient
343/// capacity in previously allocated memory to store the short string.
344///
345/// Next, as an additional test, we make the object allocate additional memory
346/// by setting a longer attribute: one that exceeds the capacity allocated for
347/// `DESCRIPTION1`. Use the second monitor to confirm that an allocation was
348/// performed.
349///
350/// There are tests where using a test allocator monitor does not suffice. Our
351/// test object is currently holding memory, if we assign a value that exceeds
352/// its current capacity there will be two operations on the object allocator:
353/// the allocation of larger memory, and the deallocation of its current memory:
354/// in that order, as part of the strong exception guarantee. Thus, the maximum
355/// number of allocations should go up by one, and no more.
356///
357/// Note that absence of memory leaks due to exceptions (the other part of the
358/// strong exception guarantee is confirmed during the destruction of the object
359/// test allocator at the end of this test, which featured exceptions.
360/// @code
361/// bsls::Types::Int64 maxBeforeSet = oa.numBlocksMax();
362/// const char DESCRIPTION2[] = "abcdefghijklmnopqrstuvwyz"
363/// "abcdefghijklmnopqrstuvwyz"
364/// "abcdefghijklmnopqrstuvwyz"
365/// "abcdefghijklmnopqrstuvwyz"
366/// "abcdefghijklmnopqrstuvwyz";
367/// assert(sizeof(DESCRIPTION1) < sizeof(DESCRIPTION2));
368///
369/// obj.setDescription(DESCRIPTION2);
370/// assert(0 == std::strcmp(DESCRIPTION2, obj.description()));
371///
372/// assert(oam2.isTotalUp()); // The object allocator used.
373///
374/// assert(oam2.isInUseSame()); // The outstanding block (allocation)
375/// // count unchanged (even though byte
376/// // outstanding byte count increased).
377///
378/// assert(oam2.isMaxUp()); // Max increased as expected, but was
379/// // did it change only by one? The
380/// // monitor cannot answer that
381/// // question.
382///
383/// bsls::Types::Int64 maxAfterSet = oa.numBlocksMax();
384///
385/// assert(1 == maxAfterSet - maxBeforeSet);
386/// @endcode
387/// Notice that our test allocator monitor cannot confirm that the allocator's
388/// maximum increased by exactly one. In this case, we must extract our
389/// statistics directly from the test allocator.
390///
391/// Note that increment in "max" occurs only the first time through the
392/// allocate/deallocate scenario in `setDescription`.
393/// @code
394/// bslma::TestAllocatorMonitor oam3(&oa);
395///
396/// const char DESCRIPTION3[] = "abcdefghijklmnopqrstuvwyz"
397/// "abcdefghijklmnopqrstuvwyz"
398/// "abcdefghijklmnopqrstuvwyz"
399/// "abcdefghijklmnopqrstuvwyz"
400/// "abcdefghijklmnopqrstuvwyz"
401/// "abcdefghijklmnopqrstuvwyz"
402/// "abcdefghijklmnopqrstuvwyz"
403/// "abcdefghijklmnopqrstuvwyz"
404/// "abcdefghijklmnopqrstuvwyz";
405/// assert(sizeof(DESCRIPTION2) < sizeof(DESCRIPTION3));
406///
407/// obj.setDescription(DESCRIPTION3);
408/// assert(0 == std::strcmp(DESCRIPTION3, obj.description()));
409///
410/// assert(oam3.isTotalUp()); // The object allocator used.
411///
412/// assert(oam3.isInUseSame()); // The outstanding block (allocation)
413/// // count unchanged (even though byte
414/// // outstanding byte count increased).
415///
416/// assert(oam3.isMaxSame()); // A repeat of the scenario for
417/// // 'DESCRIPTION2', so no change in the
418/// // allocator's maximum.
419/// @endcode
420/// Now, we close scope and check that all object memory was deallocated
421/// @code
422/// }
423///
424/// if (veryVerbose) cout << "\tAll memory returned object allocator"
425/// << endl;
426///
427/// assert(oam.isInUseSame());
428/// @endcode
429/// Finally, we check that none of these operations used the default or global
430/// allocators.
431/// @code
432/// if (verbose) cout << "Global and Default allocators never used" << endl;
433///
434/// assert(gam.isTotalSame());
435/// assert(dam.isTotalSame());
436/// @endcode
437/// @}
438/** @} */
439/** @} */
440
441/** @addtogroup bsl
442 * @{
443 */
444/** @addtogroup bslma
445 * @{
446 */
447/** @addtogroup bslma_testallocatormonitor
448 * @{
449 */
450
451#include <bslscm_version.h>
452
453#include <bslma_testallocator.h>
454
455#include <bsls_assert.h>
456
457
458
459namespace bslma {
460
461 // ==========================
462 // class TestAllocatorMonitor
463 // ==========================
464
465/// This mechanism provides a set of boolean accessor methods indicating
466/// whether a change has occurred in the state of the `TestAllocator` object
467/// (supplied at construction) since the construction of the monitor. See the
468/// @ref bslma_testallocatormonitor-statistics section for the statics tracked.
469///
470/// See @ref bslma_testallocatormonitor
472
473 // DATA
474 bsls::Types::Int64 d_initialInUse; // 'numBlocksInUse'
475 bsls::Types::Int64 d_initialMax; // 'numBlocksMax'
476 bsls::Types::Int64 d_initialTotal; // 'numBlocksTotal'
477 const TestAllocator *d_testAllocator_p; // held, not owned
478
479 // PRIVATE CLASS METHODS
480
481 /// Return the specified `allocator`, and, if compiled in "SAFE" mode,
482 /// assert that `allocator` is not 0. Note that this static function is
483 /// needed to perform validation on the allocator address supplied at
484 /// construction, prior to that address being dereferenced to initialize
485 /// the `const` data members of this type.
486 static const TestAllocator *validateArgument(
487 const TestAllocator *allocator);
488
489 private:
490 // NOT IMPLEMENTED
491 TestAllocatorMonitor(const TestAllocatorMonitor&); // = delete
492 TestAllocatorMonitor& operator=(const TestAllocatorMonitor&); // = delete
493
494 public:
495 // CREATORS
496
497 /// Create a `TestAllocatorMonitor` object to track changes in
498 /// statistics of the specified `testAllocator`.
499 explicit TestAllocatorMonitor(const TestAllocator *testAllocator);
500
501 /// Destroy this object.
503
504 // MANIPULATOR
505
506 /// Change the allocator monitored by this object to the specified
507 /// `testAllocator` and initialize the allocator properties monitored by
508 /// this object to the current state of `testAllocator`. If no
509 /// `testAllocator` is passed, do not modify the allocator held by this
510 /// object and re-initialize the allocator properties monitored by this
511 /// object to the current state of that allocator.
512 void reset(const bslma::TestAllocator *testAllocator = 0);
513
514 // ACCESSORS
515
516 /// Return `true` if the `numBlocksInUse` statistic of the tracked test
517 /// allocator has decreased since construction of this monitor, and
518 /// `false` otherwise.
519 bool isInUseDown() const;
520
521 /// Return `true` if the `numBlocksInUse` statistic of the tracked test
522 /// allocator has not changed since construction of this monitor, and
523 /// `false` otherwise.
524 bool isInUseSame() const;
525
526 /// Return `true` if the `numBlocksInUse` statistic of the tracked test
527 /// allocator has increased since construction of this monitor, and
528 /// `false` otherwise.
529 bool isInUseUp() const;
530
531 /// Return `true` if the `numBlocksMax` statistic of the tracked test
532 /// allocator has not changed since construction of this monitor, and
533 /// `false` otherwise.
534 bool isMaxSame() const;
535
536 /// Return `true` if the `numBlocksMax` statistic of the tracked test
537 /// allocator has increased since construction of this monitor, and
538 /// `false` otherwise.
539 bool isMaxUp() const;
540
541 /// Return `true` if the `numBlocksTotal` statistic of the tracked test
542 /// allocator has not changed since construction of this monitor, and
543 /// `false` otherwise.
544 bool isTotalSame() const;
545
546 /// Return `true` if the `numBlocksTotal` statistic of the tracked test
547 /// allocator has increased since construction of this monitor, and
548 /// `false` otherwise.
549 bool isTotalUp() const;
550
551 /// Return the change in the `numBlocksInUse` statistic of the tracked
552 /// test allocator since construction of this monitor.
554
555 /// Return the change in the `numBlocksMax` statistic of the tracked
556 /// test allocator since construction of this monitor.
558
559 /// Return the change in the `numBlocksTotal` statistic of the tracked
560 /// test allocator since construction of this monitor.
562};
563
564// ============================================================================
565// INLINE DEFINITIONS
566// ============================================================================
567
568 // --------------------------
569 // class TestAllocatorMonitor
570 // --------------------------
571
572// CLASS METHODS
573inline
574const TestAllocator *
575TestAllocatorMonitor::validateArgument(const TestAllocator *allocator)
576{
577 BSLS_ASSERT_SAFE(allocator);
578
579 return allocator;
580}
581
582// MANIPULATOR
583inline
585{
586 // This method is called inline by c'tor, hence it should precede it.
587
588 if (testAllocator) {
589 d_testAllocator_p = testAllocator;
590 }
591
592 d_initialInUse = d_testAllocator_p->numBlocksInUse();
593 d_initialMax = d_testAllocator_p->numBlocksMax();
594 d_initialTotal = d_testAllocator_p->numBlocksTotal();
595
596 BSLS_ASSERT_SAFE(0 <= d_initialMax);
597 BSLS_ASSERT_SAFE(0 <= d_initialTotal);
598}
599
600// CREATORS
601inline
602TestAllocatorMonitor::TestAllocatorMonitor(const TestAllocator *testAllocator)
603: d_testAllocator_p(testAllocator)
604{
605 BSLS_ASSERT_SAFE(d_testAllocator_p);
606
607 reset();
608}
609
610} // close package namespace
611
612namespace bslma {
613
614inline
616{
617 BSLS_ASSERT_SAFE(d_testAllocator_p);
618 BSLS_ASSERT_SAFE(0 <= d_initialMax);
619 BSLS_ASSERT_SAFE(0 <= d_initialTotal);
620}
621
622} // close package namespace
623
624namespace bslma {
625
626// ACCESSORS
627inline
629{
630 return d_testAllocator_p->numBlocksInUse() < d_initialInUse;
631}
632
633inline
635{
636 return d_testAllocator_p->numBlocksInUse() == d_initialInUse;
637}
638
639inline
641{
642 return d_testAllocator_p->numBlocksInUse() > d_initialInUse;
643}
644
645inline
647{
648 return d_initialMax == d_testAllocator_p->numBlocksMax();
649}
650
651inline
653{
654 return d_testAllocator_p->numBlocksMax() != d_initialMax;
655}
656
657inline
659{
660 return d_testAllocator_p->numBlocksTotal() == d_initialTotal;
661}
662
663inline
665{
666 return d_testAllocator_p->numBlocksTotal() != d_initialTotal;
667}
668
669inline
671{
672 return d_testAllocator_p->numBlocksInUse() - d_initialInUse;
673}
674
675inline
677{
678 return d_testAllocator_p->numBlocksMax() - d_initialMax;
679}
680
681inline
683{
684 return d_testAllocator_p->numBlocksTotal() - d_initialTotal;
685}
686
687} // close package namespace
688
689#ifndef BDE_OPENSOURCE_PUBLICATION // BACKWARD_COMPATIBILITY
690// ============================================================================
691// BACKWARD COMPATIBILITY
692// ============================================================================
693
694/// This alias is defined for backward compatibility.
696#endif // BDE_OPENSOURCE_PUBLICATION -- BACKWARD_COMPATIBILITY
697
698
699
700#endif
701
702// ----------------------------------------------------------------------------
703// Copyright 2013 Bloomberg Finance L.P.
704//
705// Licensed under the Apache License, Version 2.0 (the "License");
706// you may not use this file except in compliance with the License.
707// You may obtain a copy of the License at
708//
709// http://www.apache.org/licenses/LICENSE-2.0
710//
711// Unless required by applicable law or agreed to in writing, software
712// distributed under the License is distributed on an "AS IS" BASIS,
713// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
714// See the License for the specific language governing permissions and
715// limitations under the License.
716// ----------------------------- END-OF-FILE ----------------------------------
717
718/** @} */
719/** @} */
720/** @} */
Definition bslma_testallocatormonitor.h:471
bool isMaxSame() const
Definition bslma_testallocatormonitor.h:646
bool isMaxUp() const
Definition bslma_testallocatormonitor.h:652
bool isTotalUp() const
Definition bslma_testallocatormonitor.h:664
bool isTotalSame() const
Definition bslma_testallocatormonitor.h:658
bsls::Types::Int64 numBlocksMaxChange() const
Definition bslma_testallocatormonitor.h:676
bsls::Types::Int64 numBlocksInUseChange() const
Definition bslma_testallocatormonitor.h:670
bool isInUseDown() const
Definition bslma_testallocatormonitor.h:628
bool isInUseUp() const
Definition bslma_testallocatormonitor.h:640
~TestAllocatorMonitor()
Destroy this object.
Definition bslma_testallocatormonitor.h:615
bool isInUseSame() const
Definition bslma_testallocatormonitor.h:634
void reset(const bslma::TestAllocator *testAllocator=0)
Definition bslma_testallocatormonitor.h:584
bsls::Types::Int64 numBlocksTotalChange() const
Definition bslma_testallocatormonitor.h:682
Definition bslma_testallocator.h:384
bsls::Types::Int64 numBlocksInUse() const
Definition bslma_testallocator.h:1087
bsls::Types::Int64 numBlocksMax() const
Definition bslma_testallocator.h:1093
bsls::Types::Int64 numBlocksTotal() const
Definition bslma_testallocator.h:1099
bslma::TestAllocatorMonitor bslma_TestAllocatorMonitor
This alias is defined for backward compatibility.
Definition bslma_testallocatormonitor.h:695
#define BSLS_ASSERT_SAFE(X)
Definition bsls_assert.h:1762
#define BSLS_IDENT(str)
Definition bsls_ident.h:195
Definition balxml_encoderoptions.h:68
long long Int64
Definition bsls_types.h:132