text
stringlengths
0
2.2M
}
} break;
case 8: {
// --------------------------------------------------------------------
// CLASS METHOD 'updateState'
//
// Concerns:
//: 1 The method updates 'lastUpdateTime'.
//:
//: 2 The method udpdates 'lastUpdateTime' if the specified
//: 'currentTime' precedes 'lastUpdateTime'.
//:
//: 3 The method does not affect 'statisticsCollectionStartTime' if
//: time does not go backwards.
//:
//: 4 The method updates 'statisticsCollectionStartTime', if
//: 'lastUpdateTime' precedes 'statisticsCollectionStartTime'.
//
// Testing:
// void updateState(const bsls::TimeInterval& currentTime);
// --------------------------------------------------------------------
if (verbose) cout << endl
<< "CLASS METHOD 'updateState'" << endl
<< "==========================" << endl;
Obj x(10, Ti(10), 100, Ti(1), Ti(10));
x.submit(30);
x.submit(100);
// C-1
x.updateState(Ti(15));
ASSERT(Ti(15) == x.lastUpdateTime());
ASSERT(Ti(10) == x.statisticsCollectionStartTime()); // C-3
// C-2
x.updateState(Ti(5));
ASSERT(Ti(5) == x.lastUpdateTime());
ASSERT(Ti(5) == x.statisticsCollectionStartTime()); // C-4
} break;
case 7: {
// --------------------------------------------------------------------
// CLASS METHOD 'wouldExceedBandwidth', 'calculateTimeToSubmit'.
//
// Concerns:
//: 1 'wouldExceedBandwidth' returns true when peak rate limit is
//: exceeded.
//:
//: 2 'wouldExceedBandwidth' returns true, when sustained rate limit is
//: exceeded.
//:
//: 3 'wouldExceedBandwidth' returns false, if load does not exceed
//: both limits.
//:
//: 4 'calculateTimeToSubmit' returns a non-zero interval when
//: 'wouldExceedBandwidth' returns true.
//:
//: 5 'calculateTimeToSubmit' returns a zero interval when
//: 'wouldExceedBandwidth' returns false.
//:
//: 6 After waiting for the time interval, returned by
//: 'calculateTimeToSubmit' 'wouldExceedBandwidth' returns false.
//
// Testing:
// bsls::TimeInterval wouldExceedBandwidth(currentTime);
// bsls::TimeInterval calculateTimeToSubmit(currentTime);
// --------------------------------------------------------------------
if (verbose)
cout << endl
<< "CLASS METHOD 'wouldExceedBandwidth', 'calculateTimeToSubmit'"
<< endl
<< "============================================================"
<< endl;
struct {
int d_line;
Uint64 d_sustRate;
Ti d_sustWindow;
Uint64 d_peakRate;
Ti d_peakWindow;
Ti d_creationTime;
Uint64 d_nSubmits;
Uint64 d_units;
Ti d_submitInterval;
bool d_exceedBw;
} DATA[] = {
// LINE S_RATE S_WND P_RATE P_WND TCREATE N_SBMT UNITS INTERVAL EXCD_BW
// ---- ------- ------- ------ -------- -------- ------ ----- -------- -------
{L_, 100, Ti(10), 1000, Ti( 1), Ti(0), 500, 100, Ti( 0.1), true},
// C-2
{L_, 100, Ti(10), 1000, Ti( 1), Ti(0), 50, 100, Ti( 0.1), true},
// C-1
{L_, 100, Ti(10), 1000, Ti(0.1), Ti(0), 10, 100, Ti(0.01), true},
// C-3
{L_, 100, Ti(10), 1000, Ti(0.5), Ti(0), 10, 100, Ti( 1), false}
};