Repository: activemq-cpp Updated Branches: refs/heads/master 78a141774 -> 6ddd619ba
https://issues.apache.org/jira/browse/AMQCPP-585 Fix and test. Project: http://git-wip-us.apache.org/repos/asf/activemq-cpp/repo Commit: http://git-wip-us.apache.org/repos/asf/activemq-cpp/commit/6ddd619b Tree: http://git-wip-us.apache.org/repos/asf/activemq-cpp/tree/6ddd619b Diff: http://git-wip-us.apache.org/repos/asf/activemq-cpp/diff/6ddd619b Branch: refs/heads/master Commit: 6ddd619bae81215822c7aec3b2469ed6ec894473 Parents: 78a1417 Author: Timothy Bish <[email protected]> Authored: Wed Sep 23 16:00:11 2015 -0400 Committer: Timothy Bish <[email protected]> Committed: Wed Sep 23 16:00:11 2015 -0400 ---------------------------------------------------------------------- activemq-cpp/src/main/decaf/util/Date.cpp | 36 ++++++++++---------- activemq-cpp/src/main/decaf/util/Date.h | 6 ++-- activemq-cpp/src/test/decaf/util/DateTest.cpp | 39 +++++++++++----------- 3 files changed, 41 insertions(+), 40 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/activemq-cpp/blob/6ddd619b/activemq-cpp/src/main/decaf/util/Date.cpp ---------------------------------------------------------------------- diff --git a/activemq-cpp/src/main/decaf/util/Date.cpp b/activemq-cpp/src/main/decaf/util/Date.cpp index f46ec25..616bba1 100644 --- a/activemq-cpp/src/main/decaf/util/Date.cpp +++ b/activemq-cpp/src/main/decaf/util/Date.cpp @@ -29,15 +29,15 @@ using namespace decaf::lang; using namespace decaf::lang::exceptions; //////////////////////////////////////////////////////////////////////////////// -Date::Date() : time( System::currentTimeMillis() ) { +Date::Date() : time(System::currentTimeMillis()) { } //////////////////////////////////////////////////////////////////////////////// -Date::Date( long long milliseconds ) : time(milliseconds) { +Date::Date(long long milliseconds) : time(milliseconds) { } //////////////////////////////////////////////////////////////////////////////// -Date::Date( const Date& source ) : time(0) { +Date::Date(const Date& source) : time(0) { (*this) = source; } @@ -51,37 +51,37 @@ long long Date::getTime() const{ } //////////////////////////////////////////////////////////////////////////////// -void Date::setTime( long long milliseconds ){ +void Date::setTime(long long milliseconds){ this->time = milliseconds; } //////////////////////////////////////////////////////////////////////////////// -bool Date::after( const Date& when ) const { +bool Date::after(const Date& when) const { return time > when.time; } //////////////////////////////////////////////////////////////////////////////// -bool Date::before( const Date& when ) const { +bool Date::before(const Date& when) const { return time < when.time; } //////////////////////////////////////////////////////////////////////////////// -Date& Date::operator= ( const Date& source ) { +Date& Date::operator= (const Date& source) { this->time = source.time; return *this; } //////////////////////////////////////////////////////////////////////////////// -bool Date::equals( const Date& when ) const { +bool Date::equals(const Date& when) const { return time == when.time; } //////////////////////////////////////////////////////////////////////////////// -int Date::compareTo( const Date& value ) const { +int Date::compareTo(const Date& value) const { - if( this->time < value.time ) { + if (this->time < value.time) { return -1; - } else if( this->time > value.time ) { + } else if (this->time > value.time) { return 1; } @@ -89,32 +89,32 @@ int Date::compareTo( const Date& value ) const { } //////////////////////////////////////////////////////////////////////////////// -bool Date::operator==( const Date& value ) const { - return ( this->time == value.time ); +bool Date::operator==(const Date& value) const { + return (this->time == value.time); } //////////////////////////////////////////////////////////////////////////////// -bool Date::operator<( const Date& value ) const { - return ( this->time < value.time ); +bool Date::operator<(const Date& value) const { + return (this->time < value.time); } //////////////////////////////////////////////////////////////////////////////// std::string Date::toString() const { apr_time_exp_t exploded; - char buffer[80] = {0}; + char buffer[80] = { 0 }; apr_size_t resultSize = 0; // dow mon dd hh:mm:ss zzz yyyy static char format[] = "%a %b %d %T %Z %Y"; // Explode time to local time. - if( apr_time_exp_lt( &exploded, this->time ) != APR_SUCCESS ) { + if (apr_time_exp_lt(&exploded, this->time * 1000) != APR_SUCCESS) { return ""; } // Now format the exploded time into our desired format. - if( apr_strftime( &buffer[0], &resultSize, sizeof(buffer) / sizeof(char), format, &exploded ) != APR_SUCCESS ) { + if (apr_strftime(&buffer[0], &resultSize, sizeof(buffer) / sizeof(char), format, &exploded) != APR_SUCCESS) { return ""; } http://git-wip-us.apache.org/repos/asf/activemq-cpp/blob/6ddd619b/activemq-cpp/src/main/decaf/util/Date.h ---------------------------------------------------------------------- diff --git a/activemq-cpp/src/main/decaf/util/Date.h b/activemq-cpp/src/main/decaf/util/Date.h index edb57b7..84fe133 100644 --- a/activemq-cpp/src/main/decaf/util/Date.h +++ b/activemq-cpp/src/main/decaf/util/Date.h @@ -22,8 +22,8 @@ #include <decaf/lang/Comparable.h> #include <string> -namespace decaf{ -namespace util{ +namespace decaf { +namespace util { /** * Wrapper class around a time value in milliseconds. This @@ -35,7 +35,7 @@ namespace util{ private: /** - * The underlying time value in milliseconds� + * The underlying time value in milliseconds */ long long time; http://git-wip-us.apache.org/repos/asf/activemq-cpp/blob/6ddd619b/activemq-cpp/src/test/decaf/util/DateTest.cpp ---------------------------------------------------------------------- diff --git a/activemq-cpp/src/test/decaf/util/DateTest.cpp b/activemq-cpp/src/test/decaf/util/DateTest.cpp index 0789037..9220845 100644 --- a/activemq-cpp/src/test/decaf/util/DateTest.cpp +++ b/activemq-cpp/src/test/decaf/util/DateTest.cpp @@ -29,37 +29,38 @@ using namespace decaf::lang; void DateTest::test() { Date date1; - CPPUNIT_ASSERT( date1.getTime() != 0 ); + CPPUNIT_ASSERT(date1.getTime() != 0); decaf::lang::Thread::sleep(55); Date date2; - CPPUNIT_ASSERT( date1.before(date2) == true ); - CPPUNIT_ASSERT( date1.after(date2) == false ); + CPPUNIT_ASSERT(date1.before(date2) == true); + CPPUNIT_ASSERT(date1.after(date2) == false); Date date3 = date1; // Test Comparable interface - CPPUNIT_ASSERT( date1.equals( date3 ) == true ); - CPPUNIT_ASSERT( date3.equals( date1 ) == true ); - CPPUNIT_ASSERT( date1.equals( date2 ) == false ); - CPPUNIT_ASSERT( date1.compareTo( date2 ) < 0 ); - CPPUNIT_ASSERT( date2.compareTo( date1 ) > 0 ); - CPPUNIT_ASSERT( date1.compareTo( date3 ) == 0 ); - CPPUNIT_ASSERT( date3.compareTo( date1 ) == 0 ); - CPPUNIT_ASSERT( date1 < date2 ); - CPPUNIT_ASSERT( !( date2 < date1 ) ); - CPPUNIT_ASSERT( !( date1 < date3 ) ); - CPPUNIT_ASSERT( date3 == date1 ); - CPPUNIT_ASSERT( date1 == date3 ); - CPPUNIT_ASSERT( !( date1 == date2 ) ); + CPPUNIT_ASSERT(date1.equals(date3) == true); + CPPUNIT_ASSERT(date3.equals(date1) == true); + CPPUNIT_ASSERT(date1.equals(date2) == false); + CPPUNIT_ASSERT(date1.compareTo(date2) < 0); + CPPUNIT_ASSERT(date2.compareTo(date1) > 0); + CPPUNIT_ASSERT(date1.compareTo(date3) == 0); + CPPUNIT_ASSERT(date3.compareTo(date1) == 0); + CPPUNIT_ASSERT(date1 < date2); + CPPUNIT_ASSERT(!(date2 < date1)); + CPPUNIT_ASSERT(!(date1 < date3)); + CPPUNIT_ASSERT(date3 == date1); + CPPUNIT_ASSERT(date1 == date3); + CPPUNIT_ASSERT(!(date1 == date2)); } //////////////////////////////////////////////////////////////////////////////// void DateTest::testToString() { - Date now; - CPPUNIT_ASSERT( now.toString() != "" ); - CPPUNIT_ASSERT( now.toString().size() >= 20 ); + Date now(1443038174960LL); + CPPUNIT_ASSERT(now.toString() != ""); + CPPUNIT_ASSERT(now.toString().size() >= 20); + CPPUNIT_ASSERT_EQUAL(std::string("Wed Sep 23 15:56:14 EDT 2015"), now.toString()); }
