- Implemented missing operator<=, operator>=.
- Added corresponding unit tests.
This commit is contained in:
Paul Beckingham 2011-07-04 13:34:20 -04:00
parent 33bb6b6d85
commit fc793e7b1d
3 changed files with 31 additions and 1 deletions

View file

@ -226,6 +226,15 @@ bool Duration::operator< (const Duration& other)
return left < right;
}
////////////////////////////////////////////////////////////////////////////////
bool Duration::operator<= (const Duration& other)
{
long left = (long) ( mNegative ? -mSecs : mSecs);
long right = (long) (other.mNegative ? -other.mSecs : other.mSecs);
return left <= right;
}
////////////////////////////////////////////////////////////////////////////////
bool Duration::operator> (const Duration& other)
{
@ -235,6 +244,15 @@ bool Duration::operator> (const Duration& other)
return left > right;
}
////////////////////////////////////////////////////////////////////////////////
bool Duration::operator>= (const Duration& other)
{
long left = (long) ( mNegative ? -mSecs : mSecs);
long right = (long) (other.mNegative ? -other.mSecs : other.mSecs);
return left >= right;
}
////////////////////////////////////////////////////////////////////////////////
Duration::~Duration ()
{

View file

@ -39,7 +39,9 @@ public:
Duration (time_t); // Constructor
Duration (const std::string&); // Parse
bool operator< (const Duration&);
bool operator<= (const Duration&);
bool operator> (const Duration&);
bool operator>= (const Duration&);
Duration& operator= (const Duration&);
Duration& operator- (const Duration&);
~Duration (); // Destructor