Got the test backwards in r258279. Fixed that and de-tabbed
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@258281 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -335,137 +335,137 @@ struct ThrowingIterator {
|
||||
typedef const T * pointer;
|
||||
typedef const T & reference;
|
||||
|
||||
enum ThrowingAction { TAIncrement, TADecrement, TADereference, TAAssignment, TAComparison };
|
||||
enum ThrowingAction { TAIncrement, TADecrement, TADereference, TAAssignment, TAComparison };
|
||||
|
||||
// Constructors
|
||||
ThrowingIterator ()
|
||||
: begin_(nullptr), end_(nullptr), current_(nullptr), action_(TADereference), index_(0) {}
|
||||
ThrowingIterator (const T *first, const T *last, size_t index = 0, ThrowingAction action = TADereference)
|
||||
: begin_(first), end_(last), current_(first), action_(action), index_(index) {}
|
||||
ThrowingIterator (const ThrowingIterator &rhs)
|
||||
: begin_(rhs.begin_), end_(rhs.end_), current_(rhs.current_), action_(rhs.action_), index_(rhs.index_) {}
|
||||
ThrowingIterator & operator= (const ThrowingIterator &rhs)
|
||||
{
|
||||
if (action_ == TAAssignment)
|
||||
{
|
||||
if (index_ == 0)
|
||||
// Constructors
|
||||
ThrowingIterator ()
|
||||
: begin_(nullptr), end_(nullptr), current_(nullptr), action_(TADereference), index_(0) {}
|
||||
ThrowingIterator (const T *first, const T *last, size_t index = 0, ThrowingAction action = TADereference)
|
||||
: begin_(first), end_(last), current_(first), action_(action), index_(index) {}
|
||||
ThrowingIterator (const ThrowingIterator &rhs)
|
||||
: begin_(rhs.begin_), end_(rhs.end_), current_(rhs.current_), action_(rhs.action_), index_(rhs.index_) {}
|
||||
ThrowingIterator & operator= (const ThrowingIterator &rhs)
|
||||
{
|
||||
if (action_ == TAAssignment)
|
||||
{
|
||||
if (index_ == 0)
|
||||
#ifndef TEST_HAS_NO_EXCEPTIONS
|
||||
assert(false);
|
||||
throw std::runtime_error ("throw from iterator assignment");
|
||||
#else
|
||||
throw std::runtime_error ("throw from iterator assignment");
|
||||
assert(false);
|
||||
#endif
|
||||
|
||||
else
|
||||
--index_;
|
||||
}
|
||||
begin_ = rhs.begin_;
|
||||
end_ = rhs.end_;
|
||||
current_ = rhs.current_;
|
||||
action_ = rhs.action_;
|
||||
index_ = rhs.index_;
|
||||
return *this;
|
||||
}
|
||||
else
|
||||
--index_;
|
||||
}
|
||||
begin_ = rhs.begin_;
|
||||
end_ = rhs.end_;
|
||||
current_ = rhs.current_;
|
||||
action_ = rhs.action_;
|
||||
index_ = rhs.index_;
|
||||
return *this;
|
||||
}
|
||||
|
||||
// iterator operations
|
||||
reference operator*() const
|
||||
{
|
||||
if (action_ == TADereference)
|
||||
{
|
||||
if (index_ == 0)
|
||||
// iterator operations
|
||||
reference operator*() const
|
||||
{
|
||||
if (action_ == TADereference)
|
||||
{
|
||||
if (index_ == 0)
|
||||
#ifndef TEST_HAS_NO_EXCEPTIONS
|
||||
assert(false);
|
||||
throw std::runtime_error ("throw from iterator dereference");
|
||||
#else
|
||||
throw std::runtime_error ("throw from iterator dereference");
|
||||
assert(false);
|
||||
#endif
|
||||
else
|
||||
--index_;
|
||||
}
|
||||
return *current_;
|
||||
}
|
||||
else
|
||||
--index_;
|
||||
}
|
||||
return *current_;
|
||||
}
|
||||
|
||||
ThrowingIterator & operator++()
|
||||
{
|
||||
if (action_ == TAIncrement)
|
||||
{
|
||||
if (index_ == 0)
|
||||
ThrowingIterator & operator++()
|
||||
{
|
||||
if (action_ == TAIncrement)
|
||||
{
|
||||
if (index_ == 0)
|
||||
#ifndef TEST_HAS_NO_EXCEPTIONS
|
||||
assert(false);
|
||||
throw std::runtime_error ("throw from iterator increment");
|
||||
#else
|
||||
throw std::runtime_error ("throw from iterator increment");
|
||||
assert(false);
|
||||
#endif
|
||||
else
|
||||
--index_;
|
||||
}
|
||||
++current_;
|
||||
return *this;
|
||||
}
|
||||
|
||||
ThrowingIterator operator++(int)
|
||||
{
|
||||
ThrowingIterator temp = *this;
|
||||
++(*this);
|
||||
return temp;
|
||||
}
|
||||
else
|
||||
--index_;
|
||||
}
|
||||
++current_;
|
||||
return *this;
|
||||
}
|
||||
|
||||
ThrowingIterator operator++(int)
|
||||
{
|
||||
ThrowingIterator temp = *this;
|
||||
++(*this);
|
||||
return temp;
|
||||
}
|
||||
|
||||
ThrowingIterator & operator--()
|
||||
{
|
||||
if (action_ == TADecrement)
|
||||
{
|
||||
if (index_ == 0)
|
||||
ThrowingIterator & operator--()
|
||||
{
|
||||
if (action_ == TADecrement)
|
||||
{
|
||||
if (index_ == 0)
|
||||
#ifndef TEST_HAS_NO_EXCEPTIONS
|
||||
assert(false);
|
||||
throw std::runtime_error ("throw from iterator decrement");
|
||||
#else
|
||||
throw std::runtime_error ("throw from iterator decrement");
|
||||
assert(false);
|
||||
#endif
|
||||
else
|
||||
--index_;
|
||||
}
|
||||
--current_;
|
||||
return *this;
|
||||
}
|
||||
else
|
||||
--index_;
|
||||
}
|
||||
--current_;
|
||||
return *this;
|
||||
}
|
||||
|
||||
ThrowingIterator operator--(int) {
|
||||
ThrowingIterator temp = *this;
|
||||
--(*this);
|
||||
return temp;
|
||||
}
|
||||
ThrowingIterator operator--(int) {
|
||||
ThrowingIterator temp = *this;
|
||||
--(*this);
|
||||
return temp;
|
||||
}
|
||||
|
||||
bool operator== (const ThrowingIterator &rhs) const
|
||||
{
|
||||
if (action_ == TAComparison)
|
||||
{
|
||||
if (index_ == 0)
|
||||
bool operator== (const ThrowingIterator &rhs) const
|
||||
{
|
||||
if (action_ == TAComparison)
|
||||
{
|
||||
if (index_ == 0)
|
||||
#ifndef TEST_HAS_NO_EXCEPTIONS
|
||||
assert(false);
|
||||
throw std::runtime_error ("throw from iterator comparison");
|
||||
#else
|
||||
throw std::runtime_error ("throw from iterator comparison");
|
||||
assert(false);
|
||||
#endif
|
||||
else
|
||||
--index_;
|
||||
}
|
||||
bool atEndL = current_ == end_;
|
||||
bool atEndR = rhs.current_ == rhs.end_;
|
||||
if (atEndL != atEndR) return false; // one is at the end (or empty), the other is not.
|
||||
if (atEndL) return true; // both are at the end (or empty)
|
||||
return current_ == rhs.current_;
|
||||
}
|
||||
else
|
||||
--index_;
|
||||
}
|
||||
bool atEndL = current_ == end_;
|
||||
bool atEndR = rhs.current_ == rhs.end_;
|
||||
if (atEndL != atEndR) return false; // one is at the end (or empty), the other is not.
|
||||
if (atEndL) return true; // both are at the end (or empty)
|
||||
return current_ == rhs.current_;
|
||||
}
|
||||
|
||||
private:
|
||||
const T* begin_;
|
||||
const T* end_;
|
||||
const T* current_;
|
||||
ThrowingAction action_;
|
||||
mutable size_t index_;
|
||||
const T* begin_;
|
||||
const T* end_;
|
||||
const T* current_;
|
||||
ThrowingAction action_;
|
||||
mutable size_t index_;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
bool operator== (const ThrowingIterator<T>& a, const ThrowingIterator<T>& b)
|
||||
{ return a.operator==(b); }
|
||||
{ return a.operator==(b); }
|
||||
|
||||
template <typename T>
|
||||
bool operator!= (const ThrowingIterator<T>& a, const ThrowingIterator<T>& b)
|
||||
{ return !a.operator==(b); }
|
||||
|
||||
{ return !a.operator==(b); }
|
||||
|
||||
template <typename T>
|
||||
struct NonThrowingIterator {
|
||||
typedef std::bidirectional_iterator_tag iterator_category;
|
||||
@@ -474,75 +474,75 @@ struct NonThrowingIterator {
|
||||
typedef const T * pointer;
|
||||
typedef const T & reference;
|
||||
|
||||
// Constructors
|
||||
NonThrowingIterator ()
|
||||
: begin_(nullptr), end_(nullptr), current_(nullptr) {}
|
||||
NonThrowingIterator (const T *first, const T* last)
|
||||
: begin_(first), end_(last), current_(first) {}
|
||||
NonThrowingIterator (const NonThrowingIterator &rhs)
|
||||
: begin_(rhs.begin_), end_(rhs.end_), current_(rhs.current_) {}
|
||||
NonThrowingIterator & operator= (const NonThrowingIterator &rhs) TEST_NOEXCEPT
|
||||
{
|
||||
begin_ = rhs.begin_;
|
||||
end_ = rhs.end_;
|
||||
current_ = rhs.current_;
|
||||
return *this;
|
||||
}
|
||||
// Constructors
|
||||
NonThrowingIterator ()
|
||||
: begin_(nullptr), end_(nullptr), current_(nullptr) {}
|
||||
NonThrowingIterator (const T *first, const T* last)
|
||||
: begin_(first), end_(last), current_(first) {}
|
||||
NonThrowingIterator (const NonThrowingIterator &rhs)
|
||||
: begin_(rhs.begin_), end_(rhs.end_), current_(rhs.current_) {}
|
||||
NonThrowingIterator & operator= (const NonThrowingIterator &rhs) TEST_NOEXCEPT
|
||||
{
|
||||
begin_ = rhs.begin_;
|
||||
end_ = rhs.end_;
|
||||
current_ = rhs.current_;
|
||||
return *this;
|
||||
}
|
||||
|
||||
// iterator operations
|
||||
reference operator*() const TEST_NOEXCEPT
|
||||
{
|
||||
return *current_;
|
||||
}
|
||||
// iterator operations
|
||||
reference operator*() const TEST_NOEXCEPT
|
||||
{
|
||||
return *current_;
|
||||
}
|
||||
|
||||
NonThrowingIterator & operator++() TEST_NOEXCEPT
|
||||
{
|
||||
++current_;
|
||||
return *this;
|
||||
}
|
||||
|
||||
NonThrowingIterator operator++(int) TEST_NOEXCEPT
|
||||
{
|
||||
NonThrowingIterator temp = *this;
|
||||
++(*this);
|
||||
return temp;
|
||||
}
|
||||
NonThrowingIterator & operator++() TEST_NOEXCEPT
|
||||
{
|
||||
++current_;
|
||||
return *this;
|
||||
}
|
||||
|
||||
NonThrowingIterator operator++(int) TEST_NOEXCEPT
|
||||
{
|
||||
NonThrowingIterator temp = *this;
|
||||
++(*this);
|
||||
return temp;
|
||||
}
|
||||
|
||||
NonThrowingIterator & operator--() TEST_NOEXCEPT
|
||||
{
|
||||
--current_;
|
||||
return *this;
|
||||
}
|
||||
NonThrowingIterator & operator--() TEST_NOEXCEPT
|
||||
{
|
||||
--current_;
|
||||
return *this;
|
||||
}
|
||||
|
||||
NonThrowingIterator operator--(int) TEST_NOEXCEPT
|
||||
{
|
||||
NonThrowingIterator temp = *this;
|
||||
--(*this);
|
||||
return temp;
|
||||
}
|
||||
NonThrowingIterator operator--(int) TEST_NOEXCEPT
|
||||
{
|
||||
NonThrowingIterator temp = *this;
|
||||
--(*this);
|
||||
return temp;
|
||||
}
|
||||
|
||||
bool operator== (const NonThrowingIterator &rhs) const TEST_NOEXCEPT
|
||||
{
|
||||
bool atEndL = current_ == end_;
|
||||
bool atEndR = rhs.current_ == rhs.end_;
|
||||
if (atEndL != atEndR) return false; // one is at the end (or empty), the other is not.
|
||||
if (atEndL) return true; // both are at the end (or empty)
|
||||
return current_ == rhs.current_;
|
||||
}
|
||||
bool operator== (const NonThrowingIterator &rhs) const TEST_NOEXCEPT
|
||||
{
|
||||
bool atEndL = current_ == end_;
|
||||
bool atEndR = rhs.current_ == rhs.end_;
|
||||
if (atEndL != atEndR) return false; // one is at the end (or empty), the other is not.
|
||||
if (atEndL) return true; // both are at the end (or empty)
|
||||
return current_ == rhs.current_;
|
||||
}
|
||||
|
||||
private:
|
||||
const T* begin_;
|
||||
const T* end_;
|
||||
const T* current_;
|
||||
const T* begin_;
|
||||
const T* end_;
|
||||
const T* current_;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
bool operator== (const NonThrowingIterator<T>& a, const NonThrowingIterator<T>& b) TEST_NOEXCEPT
|
||||
{ return a.operator==(b); }
|
||||
{ return a.operator==(b); }
|
||||
|
||||
template <typename T>
|
||||
bool operator!= (const NonThrowingIterator<T>& a, const NonThrowingIterator<T>& b) TEST_NOEXCEPT
|
||||
{ return !a.operator==(b); }
|
||||
{ return !a.operator==(b); }
|
||||
|
||||
#undef DELETE_FUNCTION
|
||||
|
||||
|
||||
Reference in New Issue
Block a user