text
stringlengths 0
2.2M
|
---|
"\nCheck reverse iterators refer to right values\n");
|
ritBegin = tc.rbegin();
|
for (int i = tc.size() ;i > 0; --i) {
|
LOOP_ASSERT(*ritBegin, i == *(ritBegin++));
|
}
|
if (verbose) printf("\nRepeat the tests for const_iterators\n");
|
length = 0;
|
const_iterator itcBegin = tc2.begin();
|
const_iterator itcEnd = tc2.end();
|
while(itcBegin != itcEnd) {
|
++length;
|
++itcBegin;
|
}
|
LOOP_ASSERT(length, arrayLength == length);
|
length = 0;
|
const_reverse_iterator ritcBegin = tc2.rbegin();
|
const_reverse_iterator ritcEnd = tc2.rend();
|
while(ritcBegin != ritcEnd) {
|
++length;
|
++ritcBegin;
|
}
|
LOOP_ASSERT(length, arrayLength == length);
|
itcBegin = tc2.begin();
|
for (int i = 0;i < tc2.size(); ++i) {
|
LOOP_ASSERT(*itcBegin, i + 1 == *itcBegin);
|
++itcBegin;
|
}
|
ritcBegin = tc2.rbegin();
|
for (int i = tc2.size() ;i > 0; --i) {
|
LOOP_ASSERT(*ritcBegin, i == *ritcBegin);
|
++ritcBegin;
|
}
|
} break;
|
case 2: {
|
// --------------------------------------------------------------------
|
// TESTING PRIMARY MANIPULATORS
|
//
|
// Concerns:
|
//: 1 A reverse iterator created with value constructor has the
|
//: specified value.
|
//:
|
//: 2 The pre-increment operator changes the iterator to refer to the
|
//: element one before the previously referred element.
|
//:
|
//: 3 The above concerns are also valid on a constant reverse iterator.
|
//
|
// Plan:
|
//: 1 Create a reverse iterator 'A' and a constant reverse iterator
|
//: 'cA' using default constructor.
|
//:
|
//: 2 Create another reverse iterator 'B' and another constant reverse
|
//: iterator 'cB' using value constructor, verify they both have the
|
//: specified value passed in constructor, and they have different
|
//: values from 'A' and 'cA' (using yet unproven 'operator!=').
|
//: (C-1,3)
|
//:
|
//: 3 Pre-increment 'B', verify its value has changed by comparing 'B'
|
//: with 'cB'. Also verify the increment was performed correctly by
|
//: checking the value 'cB' refers to. (C-2)
|
//:
|
//: 4 Create another constant reverse iterator 'cC' using value
|
//: constructor, pre-increment it. Verify 'cC' has changed by
|
//: comparing 'cC' with 'cB'. Also verify the pre-increment was
|
//: performed correctly by checking the value it refers to. (C-2,3)
|
//
|
// Testing:
|
// bsl::reverse_iterator();
|
// bsl::reverse_iterator(ITER);
|
// bsl::reverse_iterator& operator++();
|
// --------------------------------------------------------------------
|
if (verbose) printf("\nTESTING PRIMARY MANIPULATORS"
|
"\n============================\n");
|
if (verbose) printf(
|
"\nTesting default constructor and 'operator++'.\n");
|
// Declare test data and types.
|
int testData[4] = { 0, 1, 2, 3 };
|
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;
|
const reverse_iterator itcDefault;
|
reverse_iterator itDefault;
|
// Confirm that an iterator over our reference array does not have the
|
// same value as a default constructed iterator. (Actually, this
|
// comparison is undefined in general.)
|
const reverse_iterator itcOrigin(testData + numElements);
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.