text
stringlengths
0
2.2M
}
{
int mY[] = {1, 2, 3, 4, 5};
const int *p;
bsl::reverse_iterator<const int *> rp;
ASSERT(1 == *begin(mY));
p = end(mY);
ASSERT(5 == *--p);
ASSERT(end(mY) - begin(mY) == ssize(mY));
ASSERT(5 == *rbegin(mY));
rp = rend(mY);
ASSERT(1 == *--rp);
ASSERT(rend(mY) - rbegin(mY) == ssize(mY));
ASSERT(1 == *cbegin(mY));
p = cend(mY);
ASSERT(5 == *--p);
ASSERT(cend(mY) - cbegin(mY) == ssize(mY));
ASSERT(5 == *crbegin(mY));
rp = crend(mY);
ASSERT(1 == *--rp);
ASSERT(crend(mY) - crbegin(mY) == ssize(mY));
ASSERT(5 == size(mY));
ASSERT(5 == ssize(mY));
}
} break;
case 14: {
// --------------------------------------------------------------------
// TESTING ACCESS FUNCTIONS
// Most of the functions (except accepting arrays ones) just transfer
// requests to the corresponding methods of the container class. So
// we are going to check not only the return values, but also that
// expected methods have been called.
//
// Concerns:
//: 1 The access functions call appropriate methods of the passed
//: object.
//:
//: 2 The access functions correctly transfer return values obtained
//: from the methods of the passed object.
//
// Plan:
//: 1 Using object of the class 'AccessTestContainer' call an access
//: function and check that appropriate methods of the special class
//: have been called. (C-1)
//:
//: 2 Compare return value of an access function with the value
//: obtained from direct call of the appropriate container method.
//:
//: 3 Using arrays and initializer lists check that access functions
//: return expected results. (C-2)
//
// Testing
// T::iterator begin(T& container);
// T::const_iterator begin(const T& container);
// T *begin(T (&array)[N]);
// T::iterator end(T& container);
// T::const_iterator end(const T& container);
// T *end(T (&array)[N]);
// T::const_iterator cbegin(const T& container);
// T::reverse_iterator rbegin(T& container);
// T::const_reverse_iterator rbegin(const T& container);
// reverse_iterator<T *> rbegin(T (&array)[N]);
// reverse_iterator<const T *> rbegin(std::initializer_list<T> il);
// T::const_reverse_iterator crbegin(const T& container);
// T::const_iterator cend(const T& container);
// T::reverse_iterator rend(T& container);
// T::const_reverse_iterator rend(const T& container);
// reverse_iterator<T *> rend(T (&array)[N]);
// reverse_iterator<const T *> rend(std::initializer_list<T> il);
// T::const_reverse_iterator crend(const T& container);
// --------------------------------------------------------------------
if (verbose) printf("\nTESTING ACCESS FUNCTIONS"
"\n========================\n");
if (verbose) printf("\tTest container class.\n");
{
typedef testcontainer::AccessTestContainer Container;
typedef Container::iterator iterator;
typedef Container::const_iterator const_iterator;
typedef Container::const_iterator const_iterator;
typedef Container::reverse_iterator reverse_iterator;
typedef Container::const_reverse_iterator const_reverse_iterator;
Container mXB;
const Container XB;
const Container XCB;
Container mXRB;
const Container XRB;
const Container XCRB;
Container mXE;
const Container XE;
const Container XCE;
Container mXRE;