mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-23 16:48:06 +02:00
Add missing relational operators to VarIterator (#4714)
* Add missing relational operators to VarIterator * Add tests for relational operators of VarIterator
This commit is contained in:
@@ -69,6 +69,18 @@ public:
|
|||||||
bool operator != (const VarIterator& other) const;
|
bool operator != (const VarIterator& other) const;
|
||||||
/// Inequality operator.
|
/// Inequality operator.
|
||||||
|
|
||||||
|
bool operator < (const VarIterator& other) const;
|
||||||
|
/// Less than operator.
|
||||||
|
|
||||||
|
bool operator > (const VarIterator& other) const;
|
||||||
|
/// Greater than operator.
|
||||||
|
|
||||||
|
bool operator <= (const VarIterator& other) const;
|
||||||
|
/// Less than or equal to operator.
|
||||||
|
|
||||||
|
bool operator >= (const VarIterator& other) const;
|
||||||
|
/// Greater than or equal to operator.
|
||||||
|
|
||||||
Var& operator * () const;
|
Var& operator * () const;
|
||||||
/// Returns value at the current position.
|
/// Returns value at the current position.
|
||||||
|
|
||||||
@@ -138,6 +150,30 @@ inline bool VarIterator::operator != (const VarIterator& other) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline bool VarIterator::operator < (const VarIterator& other) const
|
||||||
|
{
|
||||||
|
return _position < other._position;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline bool VarIterator::operator > (const VarIterator& other) const
|
||||||
|
{
|
||||||
|
return _position > other._position;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline bool VarIterator::operator <= (const VarIterator& other) const
|
||||||
|
{
|
||||||
|
return _position <= other._position;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline bool VarIterator::operator >= (const VarIterator& other) const
|
||||||
|
{
|
||||||
|
return _position >= other._position;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
} } // namespace Poco::Dynamic
|
} } // namespace Poco::Dynamic
|
||||||
|
|
||||||
|
|
||||||
|
@@ -83,8 +83,7 @@ void VarIterator::increment() const
|
|||||||
{
|
{
|
||||||
if (POSITION_END == _position)
|
if (POSITION_END == _position)
|
||||||
throw RangeException("End of iterator reached.");
|
throw RangeException("End of iterator reached.");
|
||||||
|
else if (_position < _pVar->size() - 1)
|
||||||
if (_position < _pVar->size() - 1)
|
|
||||||
++_position;
|
++_position;
|
||||||
else
|
else
|
||||||
_position = POSITION_END;
|
_position = POSITION_END;
|
||||||
|
@@ -3161,6 +3161,8 @@ void VarTest::testIterator()
|
|||||||
|
|
||||||
da = Poco::Dynamic::Array();
|
da = Poco::Dynamic::Array();
|
||||||
assertTrue(da.begin() == da.end());
|
assertTrue(da.begin() == da.end());
|
||||||
|
assertTrue(da.begin() <= da.end());
|
||||||
|
assertTrue(da.begin() >= da.end());
|
||||||
|
|
||||||
da = 1;
|
da = 1;
|
||||||
assertTrue (!da.isEmpty());
|
assertTrue (!da.isEmpty());
|
||||||
@@ -3172,6 +3174,10 @@ void VarTest::testIterator()
|
|||||||
}
|
}
|
||||||
catch (RangeException&) {}
|
catch (RangeException&) {}
|
||||||
assertTrue (da.begin() != da.end());
|
assertTrue (da.begin() != da.end());
|
||||||
|
assertTrue (da.begin() <= da.end());
|
||||||
|
assertTrue (da.begin() < da.end());
|
||||||
|
assertTrue (da.end() >= da.begin());
|
||||||
|
assertTrue (da.end() > da.begin());
|
||||||
|
|
||||||
Var::Iterator it = da.begin();
|
Var::Iterator it = da.begin();
|
||||||
Var::Iterator end = da.end();
|
Var::Iterator end = da.end();
|
||||||
|
Reference in New Issue
Block a user