text
stringlengths
0
2.2M
}
} break;
case 3: {
// --------------------------------------------------------------------
// BASIC ACCESSORS
// Ensure each basic accessor properly interprets object state.
//
// Concerns:
//: 1 Each accessor returns the value of the corresponding attribute
//: of the object.
//:
//: 2 Each accessor method is declared 'const'.
//
// Plan:
//: 1 Create an object using the value constructor. Verify that each
//: basic accessor, invoked on a reference providing non-modifiable
//: access to the object, returns the expected value. (C-2)
//:
//: 2 Create another object using the value constructor having a
//: different value for each attribute compared to a default
//: constructed object. Verify that each basic accessor, invoked on
//: a reference providing non-modifiable access to the object,
//: returns the expected value. (C-1)
//
// Testing:
// bsls::Types::Uint64 peakRateLimit() const;
// bsls::Types::Uint64 sustainedRateLimit() const;
// bsls::TimeInterval peakRateWindow() const;
// bsls::TimeInterval sustainedRateWindow() const;
// bsls::TimeInterval lastUpdateTime() const;
// bsls::TimeInterval statisticsCollectionStartTime() const;
//-----------------------------------------------------------------
if (verbose) cout << endl
<< "BASIC ACCESSORS" << endl
<< "===============" << endl;
Obj mX(1, Ti(10), 10, Ti(1), Ti(0)); const Obj& X = mX;
ASSERT(10 == X.peakRateLimit());
ASSERT(Ti(1) == X.peakRateWindow());
ASSERT(1 == X.sustainedRateLimit());
ASSERT(Ti(10) == X.sustainedRateWindow());
ASSERT(Ti(0) == X.lastUpdateTime());
ASSERT(Ti(0) == X.statisticsCollectionStartTime());
ASSERT(0 == X.unitsReserved());
Uint64 SR = 100;
Ti SW(50);
Uint64 PR = 1000;
Ti PW(10);
Ti CT(6);
Uint64 RU = 22;
Obj mY(SR, SW, PR, PW, CT); const Obj& Y = mY;
mY.reserve(RU);
ASSERT(PR == Y.peakRateLimit());
ASSERT(PW == Y.peakRateWindow());
ASSERT(SR == Y.sustainedRateLimit());
ASSERT(SW == Y.sustainedRateWindow());
ASSERT(CT == Y.lastUpdateTime());
ASSERT(CT == Y.statisticsCollectionStartTime());
ASSERT(RU == Y.unitsReserved());
} break;
case 2: {
// --------------------------------------------------------------------
// VALUE CTOR
// Ensure that we can put an object into any initial state relevant
// for thorough testing.
//
// Concerns:
//: 1 The value constructor can create an object having any value that
//: does not violate the constructor's documented preconditions.
//:
//: 2 The capacity of a underlying leaky bucket is set to the
//: rounded-down product of 'sustainedRateWindow' and
//: 'sustainedRateLimit'. As a result, the 'sustainedRateLimit'
//: retrieved from an object's accessor may be one less than the
//: original specified value.
//:
//: 3 If less than one unit is transmitted during the specified
//: 'sustainedRateWindow' at 'sustainedRateLimit' then
//: 'sustainRateWindow' will be set to the time period during which 1
//: unit is transmitted.
//:
//: 4 The capacity of a underlying leaky bucket is set to the
//: rounded-down product of 'peakRateWindow' and 'peakRateLimit'. As
//: a result, the 'peakRateLimit' retrieved from an object's accessor
//: may be one less than the original specified value.
//:
//: 5 If less than one unit is transmitted during the specified
//: 'peakRateWindow' at 'peakRateLimit' then 'sustainRateWindow' will
//: be set to the time period during which 1 unit is transmitted.
//:
//: 6 QoI: Assert preconditions violations are detected when enabled.
//
// Plan:
//: 2 Use a table driven test, for a set of varied possible attributes,