text
stringlengths
0
2.2M
delta.nanoseconds() >= 0 &&
delta.nanoseconds() <= 1 );
delta = DATA[0].d_peakWindow - y.peakRateWindow();
ASSERT(0 == delta.seconds() &&
delta.nanoseconds() >= 0 &&
delta.nanoseconds() <= 1 );
ASSERT(DATA[1].d_sustRate == z.sustainedRateLimit());
ASSERT(DATA[1].d_peakRate == z.peakRateLimit());
ASSERT(DATA[1].d_creationTime == z.lastUpdateTime());
ASSERT(DATA[1].d_creationTime ==
z.statisticsCollectionStartTime());
delta = DATA[1].d_sustWindow - z.sustainedRateWindow();
ASSERT(0 == delta.seconds() &&
delta.nanoseconds() >= 0 &&
delta.nanoseconds() <= 1 );
delta = DATA[1].d_peakWindow - z.peakRateWindow();
ASSERT(0 == delta.seconds() &&
delta.nanoseconds() >= 0 &&
delta.nanoseconds() <= 1 );
}
}
// Negative Testing
{
bsls::AssertTestHandlerGuard hG;
// Zero rate or zero window.
ASSERT_SAFE_FAIL(Obj x1(0, Ti(15), 10, Ti(10), Ti(0)));
ASSERT_SAFE_FAIL(Obj x1(1, Ti( 0), 10, Ti(10), Ti(0)));
ASSERT_SAFE_FAIL(Obj x1(1, Ti(15), 0, Ti(10), Ti(0)));
ASSERT_SAFE_FAIL(Obj x1(1, Ti(15), 10, Ti( 0), Ti(0)));
// Negative window.
ASSERT_SAFE_FAIL(Obj x1(1, Ti(-15), 10, Ti(10), Ti(0)));
ASSERT_SAFE_FAIL(Obj x1(1, Ti(15), 10, Ti(-10), Ti(0)));
}
} break;
case 1: {
// ----------------------------------------------------------------
// BREATHING TEST:
// Developers' Sandbox.
//
// Plan:
// Perform and ad-hoc test of the primary modifiers and accessors.
//
// Testing:
// This "test" *exercises* basic functionality, but *tests*
// nothing.
// ----------------------------------------------------------------
if (verbose) cout << endl
<< "BREATHING TEST" << endl
<< "==============" << endl;
Obj x(1, Ti(10), 1, Ti(10), Ti(0));
ASSERT(1 == x.sustainedRateLimit());
ASSERT(Ti(10) == x.sustainedRateWindow());
ASSERT(1 == x.peakRateLimit());
ASSERT(Ti(10) == x.peakRateWindow());
ASSERT(Ti(0) == x.lastUpdateTime());
ASSERT(Ti(0) == x.statisticsCollectionStartTime()); // C-10
ASSERT(0 == x.unitsReserved());
Ti currentTime(1);
x.setRateLimits(1000, Ti(1), 10000, Ti(0.1));
x.reset(currentTime);
ASSERT(1000 == x.sustainedRateLimit());
ASSERT(Ti(1) == x.sustainedRateWindow());
x.submit(500);
x.reserve(250);
ASSERT(250 == x.unitsReserved());
ASSERT(false == x.wouldExceedBandwidth(currentTime));
ASSERT(Ti(0) == x.calculateTimeToSubmit(currentTime));
x.submitReserved(250);
x.submit(750);
ASSERT(0 == x.unitsReserved());
Ti delta = Ti(0.501) - x.calculateTimeToSubmit(currentTime);
ASSERT(0 == delta.seconds() &&
delta.nanoseconds() >= 0 &&
delta.nanoseconds() <= 1 );
currentTime.addMilliseconds(500);
ASSERT(0 == delta.seconds() &&
delta.nanoseconds() >= 0 &&
delta.nanoseconds() <= 1 );
currentTime.addMilliseconds(100);
x.updateState(currentTime);