2006-12-24 06:25:21 +00:00
|
|
|
#include "Peer.h"
|
|
|
|
#include <cppunit/extensions/HelperMacros.h>
|
|
|
|
|
2008-02-08 15:53:45 +00:00
|
|
|
namespace aria2 {
|
2006-12-24 06:25:21 +00:00
|
|
|
|
|
|
|
class PeerTest:public CppUnit::TestFixture {
|
|
|
|
|
|
|
|
CPPUNIT_TEST_SUITE(PeerTest);
|
|
|
|
CPPUNIT_TEST(testPeerAllowedIndexSet);
|
|
|
|
CPPUNIT_TEST(testAmAllowedIndexSet);
|
|
|
|
CPPUNIT_TEST(testGetId);
|
2008-01-10 14:59:11 +00:00
|
|
|
CPPUNIT_TEST(testOperatorEqual);
|
2006-12-24 06:25:21 +00:00
|
|
|
CPPUNIT_TEST_SUITE_END();
|
|
|
|
private:
|
2008-02-08 15:53:45 +00:00
|
|
|
SharedHandle<Peer> peer;
|
2006-12-24 06:25:21 +00:00
|
|
|
public:
|
|
|
|
PeerTest():peer(0) {}
|
|
|
|
|
|
|
|
void setUp() {
|
2007-12-26 14:26:55 +00:00
|
|
|
peer = new Peer("localhost", 6969);
|
2006-12-24 06:25:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void testPeerAllowedIndexSet();
|
|
|
|
void testAmAllowedIndexSet();
|
|
|
|
void testGetId();
|
2008-01-10 14:59:11 +00:00
|
|
|
void testOperatorEqual();
|
2006-12-24 06:25:21 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
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() {
|
2008-02-08 15:53:45 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL(std::string("f05897fc14a41cb3400e283e189158656d7184da"),
|
2006-12-24 06:25:21 +00:00
|
|
|
peer->getId());
|
|
|
|
}
|
2008-01-10 14:59:11 +00:00
|
|
|
|
|
|
|
void PeerTest::testOperatorEqual()
|
|
|
|
{
|
|
|
|
CPPUNIT_ASSERT(Peer("localhost", 6881) == Peer("localhost", 6881));
|
|
|
|
|
|
|
|
{
|
|
|
|
Peer p1("localhost", 6881);
|
|
|
|
Peer p2("localhsot", 0);
|
|
|
|
p2.port = 6881;
|
|
|
|
CPPUNIT_ASSERT(p1 != p2);
|
|
|
|
}
|
|
|
|
}
|
2008-02-08 15:53:45 +00:00
|
|
|
|
|
|
|
} // namespace aria2
|