mirror of https://github.com/aria2/aria2
46 lines
1.0 KiB
C++
46 lines
1.0 KiB
C++
#include "Peer.h"
|
|
#include <cppunit/extensions/HelperMacros.h>
|
|
|
|
using namespace std;
|
|
|
|
class PeerTest:public CppUnit::TestFixture {
|
|
|
|
CPPUNIT_TEST_SUITE(PeerTest);
|
|
CPPUNIT_TEST(testPeerAllowedIndexSet);
|
|
CPPUNIT_TEST(testAmAllowedIndexSet);
|
|
CPPUNIT_TEST(testGetId);
|
|
CPPUNIT_TEST_SUITE_END();
|
|
private:
|
|
PeerHandle peer;
|
|
public:
|
|
PeerTest():peer(0) {}
|
|
|
|
void setUp() {
|
|
peer = new Peer("localhost", 6969, 16*1024, 256*1024*1024);
|
|
}
|
|
|
|
void testPeerAllowedIndexSet();
|
|
void testAmAllowedIndexSet();
|
|
void testGetId();
|
|
};
|
|
|
|
|
|
CPPUNIT_TEST_SUITE_REGISTRATION(PeerTest);
|
|
|
|
void PeerTest::testPeerAllowedIndexSet() {
|
|
CPPUNIT_ASSERT(!peer->isInPeerAllowedIndexSet(0));
|
|
peer->addPeerAllowedIndex(0);
|
|
CPPUNIT_ASSERT(peer->isInPeerAllowedIndexSet(0));
|
|
}
|
|
|
|
void PeerTest::testAmAllowedIndexSet() {
|
|
CPPUNIT_ASSERT(!peer->isInAmAllowedIndexSet(0));
|
|
peer->addAmAllowedIndex(0);
|
|
CPPUNIT_ASSERT(peer->isInAmAllowedIndexSet(0));
|
|
}
|
|
|
|
void PeerTest::testGetId() {
|
|
CPPUNIT_ASSERT_EQUAL(string("f05897fc14a41cb3400e283e189158656d7184da"),
|
|
peer->getId());
|
|
}
|