text stringlengths 0 2.2M |
|---|
#include <bsl_c_math.h>
|
#include <bsl_iostream.h>
|
using namespace BloombergLP;
|
using namespace bsl;
|
//=============================================================================
|
// TEST PLAN
|
//-----------------------------------------------------------------------------
|
// Overview
|
// --------
|
// The component under test implements a mechanism.
|
//
|
// Class Methods:
|
//: o 'supportsRateLimitsExactly'
|
//
|
// Primary Manipulators:
|
//: o 'setRateLimits'
|
//
|
// Basic Accessors:
|
//: o 'peakRateLimit'
|
//: o 'sustainedRateLimit'
|
//: o 'peakRateWindow'
|
//: o 'sustainedRateWindow'
|
//: o 'lastUpdateTime'
|
//: o 'unitsReserved'
|
//
|
// This class also provides a value constructor capable of creating an object
|
// having any parameters.
|
//
|
// Global Concerns:
|
//: o ACCESSOR methods are declared 'const'.
|
//: o CREATOR & MANIPULATOR pointer/reference parameters are declared 'const'.
|
//: o Precondition violations are detected in appropriate build modes.
|
//
|
// Global Assumptions:
|
//: o ACCESSOR methods are 'const' thread-safe.
|
//-----------------------------------------------------------------------------
|
//
|
// CREATORS
|
// [ 2] RateLimiter(sR, sRW, pR, pRW, currentTime);
|
//
|
// MANIPULATORS
|
// [ 6] bool supportsRateLimitsExactly(sR, sRW, pR, pRW);
|
// [ 6] void setRateLimits(sR, sRW, pR, pRW, currentTime);
|
// [ 4] void submit(bsls::Types::Uint64 numOfUnits);
|
// [ 5] void reserve(bsls::Types::Uint64 numOfUnits);
|
// [ 8] void updateState(const bsls::TimeInterval& currentTime);
|
// [ 4] bool wouldExceedBandwidth(currentTime);
|
// [ 5] void submitReserved(bsls::Types::Unit64 numOfUnits);
|
// [12] void cancelReserved(bsls::Types::Unit64 numOfUnits);
|
// [10] void resetStatistics();
|
// [11] void reset(const bsls::TimeInterval& currentTime);
|
// [ 7] bsls::TimeInterval calculateTimeToSubmit(currentTime);
|
//
|
// ACCESSORS
|
// [ 3] bsls::Types::Uint64 peakRateLimit() const;
|
// [ 3] bsls::Types::Uint64 sustainedRateLimit() const;
|
// [ 3] bsls::TimeInterval peakRateWindow() const;
|
// [ 3] bsls::TimeInterval sustainedRateWindow() const;
|
// [ 5] bsls::Types::Uint64 unitsReserved() const;
|
// [ 3] bsls::TimeInterval lastUpdateTime() const;
|
// [ 9] void getStatistics(*submittedUnits, *unusedUnits) const;
|
// [ 3] bsls::TimeInterval statisticsCollectionStartTime() const;
|
//
|
//-----------------------------------------------------------------------------
|
// [ 1] BREATHING TEST
|
// [13] USAGE EXAMPLE
|
// [ 3] All accessor methods are declared 'const'.
|
// [ *] All creator/manipulator ptr./ref. parameters are 'const'.
|
//=============================================================================
|
//=============================================================================
|
// STANDARD BDE ASSERT TEST MACRO
|
//-----------------------------------------------------------------------------
|
static int testStatus = 0;
|
static void aSsErT(int c, const char *s, int i)
|
{
|
if (c) {
|
cout << "Error " << __FILE__ << "(" << i << "): " << s
|
<< " (failed)" << endl;
|
if (testStatus >= 0 && testStatus <= 100) ++testStatus;
|
}
|
}
|
# define ASSERT(X) { aSsErT(!(X), #X, __LINE__); }
|
//-----------------------------------------------------------------------------
|
#define LOOP_ASSERT(I,X) { \
|
if (!(X)) { cout << #I << ": " << I << "\n"; aSsErT(1, #X, __LINE__); }}
|
#define LOOP2_ASSERT(I,J,X) { \
|
if (!(X)) { cout << #I << ": " << I << "\t" << #J << ": " \
|
<< J << "\n"; aSsErT(1, #X, __LINE__); } }
|
#define LOOP3_ASSERT(I,J,K,X) { \
|
if (!(X)) { cout << #I << ": " << I << "\t" << #J << ": " << J << "\t" \
|
<< #K << ": " << K << "\n"; aSsErT(1, #X, __LINE__); } }
|
#define LOOP4_ASSERT(I,J,K,L,X) { \
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.