text
stringlengths 0
2.2M
|
---|
} break;
|
case 6: {
|
// --------------------------------------------------------------------
|
// TESTING EQUALITY OPERATOR
|
//
|
// Concerns:
|
//: 1 The reverse iterators must compare equal to themselves.
|
//:
|
//: 2 Constant reverse iterators can be compared with mutable reverse
|
//: iterators.
|
//:
|
//: 3 Constant and mutable reverse iterators referring to the same
|
//: element shall compare equal.
|
//:
|
//: 4 Reverse iterators (either constant or mutable) that do not refer
|
//: to the same element shall not compare equal.
|
//
|
// Plan:
|
//: 1 Create a fixed size array 'A', assign values to each of its
|
//: elements.
|
//:
|
//: 2 Get a constant reverse iterator 'itc1' generated by 'rbegin' of
|
//: 'A'. Use 'itc1' to verify self-equality and equality between
|
//: constant and mutable reverse iterators. (C-1..3)
|
//:
|
//: 3 Get another constant reverse iterator 'itc2' generated by 'rend'
|
//: of 'A'. Use 'itc1' and 'itc2' to verify inequality. (C-4)
|
//:
|
//: 4 Get a third mutable reverse iterator 'itc2', change its value
|
//: using primary manipulators. Verify various equality and
|
//: inequality against 'itc1' and 'itc2'. (C-4)
|
//
|
// Testing:
|
// bool operator==(const reverse_iterator&, const reverse_iterator&);
|
// bool operator!=(const reverse_iterator&, const reverse_iterator&);
|
// --------------------------------------------------------------------
|
if (verbose) printf("\nTESTING EQUALITY OPERATOR"
|
"\n=========================\n");
|
using namespace testcontainer;
|
typedef MyFixedSizeArray<int, 5> TestContainer;
|
typedef TestContainer::reverse_iterator reverse_iterator;
|
typedef TestContainer::const_reverse_iterator const_reverse_iterator;
|
TestContainer tc;
|
for (int i = 0; i < tc.size(); ++i) {
|
tc[i] = i * i + i * 13 + 1;
|
}
|
if (verbose) printf("\nValidate self-equality\n");
|
const reverse_iterator ritBegin = tc.rbegin();
|
ASSERT( ritBegin == ritBegin );
|
ASSERT( !(ritBegin != ritBegin));
|
ASSERT(tc.rbegin() == ritBegin );
|
if (verbose) printf("\nValidate inequality\n");
|
#if !defined(BSLS_ITERATOR_NO_MIXED_OPS_IN_CPP03)
|
const const_reverse_iterator ritEnd = tc.rend();
|
#else
|
const reverse_iterator ritEnd = tc.rend();
|
#endif
|
ASSERT( ritBegin != ritEnd );
|
ASSERT( !(ritBegin == ritEnd));
|
ASSERT( ritEnd == ritEnd );
|
ASSERT( !(ritEnd != ritEnd));
|
ASSERT( tc.rbegin() != ritEnd );
|
ASSERT(!(tc.rbegin() == ritEnd));
|
ASSERT( tc.rend() == ritEnd );
|
ASSERT( !(tc.rend() != ritEnd));
|
if (verbose) printf("\nValidate transition to expected value\n");
|
reverse_iterator ritCursor = tc.rbegin();
|
ASSERT(ritBegin == ritCursor);
|
ASSERT(ritEnd != ritCursor);
|
for (int i = 0;i < tc.size() - 1; ++i) {
|
++ritCursor;
|
ASSERT(ritBegin != ritCursor);
|
ASSERT(ritEnd != ritCursor);
|
}
|
++ritCursor;
|
ASSERT(ritBegin != ritCursor);
|
ASSERT(ritEnd == ritCursor);
|
} break;
|
case 5: {
|
// --------------------------------------------------------------------
|
// TESTING OUTPUT: Not Applicable
|
// --------------------------------------------------------------------
|
} break;
|
case 4: {
|
// --------------------------------------------------------------------
|
// TESTING BASIC ACCESSORS: Not Applicable
|
// --------------------------------------------------------------------
|
} break;
|
case 3: {
|
// --------------------------------------------------------------------
|
// TESTING (PRIMITIVE) GENERATORS
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.