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