text
stringlengths 0
2.2M
|
---|
//:
|
//: 2 'operator>', 'operator<=', and 'operator>=' are correctly tied to
|
//: 'operator<'. i.e., For two objects, 'a' and 'b':
|
//:
|
//: 1 '(a > b) == (b < a)'
|
//:
|
//: 2 '(a <= b) == !(b < a)'
|
//:
|
//: 3 '(a >= b) == !(a < b)'
|
//:
|
//: 3 'operator-' and 'distance' return same results if parameters are
|
//: passed correctly.
|
//:
|
//: 4 'operator+' and 'bsl::reverse_iterator::operator+' return same
|
//: results if parameters are passed correctly.
|
//
|
// Plan:
|
//: 1 Create reverse iterators 'it1' and 'it2'. Verify 'operator<'
|
//: returns the correct lexicographic comparison results. (C-1)
|
//:
|
//: 2 Verify 'operator>', 'operator<=', and 'operator>=' return correct
|
//: results using 'it1' and 'it2'. Verify their results are
|
//: tied to results of 'operator<'. (C-2)
|
//:
|
//: 3 Compare results of 'operator-' and 'distance' using 'it1' and
|
//: 'it2', verify they return same results. (C-3)
|
//:
|
//: 4 Compare results of 'operator+' and 'reverse_iterator::operator+'
|
//: using 'it1' and a distance, verify they return same results.
|
//: (C-4)
|
// --------------------------------------------------------------------
|
if (verbose) printf("\nTESTING FREE FUNCTIONS"
|
"\n======================\n");
|
// Declare test data and types.
|
int testData[] = { 42, 13, 56, 72, 39, };
|
int numElements = sizeof(testData) / sizeof(int);
|
typedef int *iterator;
|
typedef int const *const_iterator;
|
typedef bsl::reverse_iterator<iterator> reverse_iterator;
|
typedef bsl::reverse_iterator<const_iterator> const_reverse_iterator;
|
reverse_iterator it1(testData + numElements);
|
if (verbose) printf("\nTest 'operator-', 'operator>', "
|
"'operator<=', and 'operator>='\n");
|
for (int i = 0; i < numElements; ++i) {
|
reverse_iterator it2(testData + i);
|
LOOP3_ASSERT(i, *it1, *it2, it2 > it1);
|
LOOP3_ASSERT(i, *it1, *it2, !(it1 > it2));
|
LOOP3_ASSERT(i, *it1, *it2, it1 < it2);
|
LOOP3_ASSERT(i, *it1, *it2, !(it2 < it1));
|
LOOP3_ASSERT(i, *it1, *it2, it1 <= it2);
|
LOOP3_ASSERT(i, *it1, *it2, !(it2 <= it1));
|
LOOP3_ASSERT(i, *it1, *it2, it2 >= it1);
|
LOOP3_ASSERT(i, *it1, *it2, !(it1 >= it2));
|
}
|
#if !defined(BSLS_ITERATOR_NO_MIXED_OPS_IN_CPP03)
|
for (int i = 0; i < numElements; ++i) {
|
const_reverse_iterator it2(testData + i);
|
LOOP3_ASSERT(i, *it1, *it2, it2 > it1);
|
LOOP3_ASSERT(i, *it1, *it2, !(it1 > it2));
|
LOOP3_ASSERT(i, *it1, *it2, it1 < it2);
|
LOOP3_ASSERT(i, *it1, *it2, !(it2 < it1));
|
LOOP3_ASSERT(i, *it1, *it2, it1 <= it2);
|
LOOP3_ASSERT(i, *it1, *it2, !(it2 <= it1));
|
LOOP3_ASSERT(i, *it1, *it2, it2 >= it1);
|
LOOP3_ASSERT(i, *it1, *it2, !(it1 >= it2));
|
}
|
#endif
|
} break;
|
case 12: {
|
// --------------------------------------------------------------------
|
// TESTING OTHER ACCESSORS
|
//
|
// Concerns:
|
//: 1 All other accessors of 'bsl::reverse_iterator' work correctly.
|
//
|
// Plan:
|
//: 1 Create reverse iterators 'it'. Call different accessors of 'it'.
|
//: Verify each accessor returns expected values. (C-1)
|
//
|
// Testing:
|
// operator+(typename difference_type n) const;
|
// operator-(typename difference_type n) const;
|
// --------------------------------------------------------------------
|
if (verbose) printf("\nTESTING OTHER ACCESSORS"
|
"\n=======================\n");
|
// Declare test data and types.
|
int testData[] = { 42, 13, 56, 72, 39, };
|
int numElements = sizeof(testData) / sizeof(int);
|
typedef int *iterator;
|
typedef bsl::reverse_iterator<iterator> reverse_iterator;
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.