mirror of
https://github.com/aria2/aria2.git
synced 2025-01-24 02:31:29 +00:00
8d09b069e2
Added Time global::wallclock to cache "current time" to reduce the call gettimeofday(). Global variables are now in namespace global. * src/AbstractCommand.cc * src/ActivePeerConnectionCommand.cc * src/AdaptiveURISelector.cc * src/BtLeecherStateChoke.cc * src/BtLeecherStateChoke.h * src/BtSeederStateChoke.cc * src/BtSeederStateChoke.h * src/BtStopDownloadCommand.cc * src/ConsoleStatCalc.cc * src/DHTBucket.cc * src/DHTGetPeersCommand.cc * src/DHTMessageTrackerEntry.cc * src/DHTNode.cc * src/DHTPeerAnnounceEntry.cc * src/DHTPeerAnnounceStorage.cc * src/DHTSetup.cc * src/DefaultBtAnnounce.cc * src/DefaultBtInteractive.cc * src/DefaultBtMessageDispatcher.cc * src/DefaultPeerStorage.cc * src/DefaultPieceStorage.cc * src/DownloadCommand.cc * src/DownloadEngine.cc * src/FileEntry.cc * src/HttpServerBodyCommand.cc * src/HttpServerCommand.cc * src/HttpServerResponseCommand.cc * src/LpdMessageDispatcher.cc * src/MultiUrlRequestInfo.cc * src/Peer.cc * src/Peer.h * src/PeerAbstractCommand.cc * src/PeerStat.h * src/RequestSlot.cc * src/RequestSlot.h * src/SegmentMan.cc * src/ServerStatMan.cc * src/SleepCommand.cc * src/SpeedCalc.cc * src/SpeedCalc.h * src/TimeA2.cc * src/TimeA2.h * src/TimeBasedCommand.cc * src/TimeSeedCriteria.h * src/UTMetadataRequestTracker.h * src/UTPexExtensionMessage.cc * src/wallclock.h
34 lines
656 B
C++
34 lines
656 B
C++
#include "TimeSeedCriteria.h"
|
|
|
|
#include <cppunit/extensions/HelperMacros.h>
|
|
|
|
#include "util.h"
|
|
#include "wallclock.h"
|
|
|
|
namespace aria2 {
|
|
|
|
class TimeSeedCriteriaTest:public CppUnit::TestFixture {
|
|
|
|
CPPUNIT_TEST_SUITE(TimeSeedCriteriaTest);
|
|
CPPUNIT_TEST(testEvaluate);
|
|
CPPUNIT_TEST_SUITE_END();
|
|
|
|
public:
|
|
void testEvaluate();
|
|
};
|
|
|
|
|
|
CPPUNIT_TEST_SUITE_REGISTRATION(TimeSeedCriteriaTest);
|
|
|
|
void TimeSeedCriteriaTest::testEvaluate() {
|
|
TimeSeedCriteria cri(1);
|
|
global::wallclock.reset();
|
|
global::wallclock.advance(2);
|
|
CPPUNIT_ASSERT(cri.evaluate());
|
|
cri.reset();
|
|
cri.setDuration(10);
|
|
CPPUNIT_ASSERT(!cri.evaluate());
|
|
}
|
|
|
|
} // namespace aria2
|