forked from premiere/premiere-libtorrent
fix ip_voter test and try to narrow down flapping in test heterogeneous test
This commit is contained in:
parent
2714e3d4ba
commit
3073be4bbd
|
@ -137,13 +137,12 @@ private:
|
|||
F& operator=(F const& f);
|
||||
};
|
||||
|
||||
TORRENT_TEST(heterogeneuous_queue)
|
||||
// test push_back of heterogeneous types
|
||||
// and retrieval of their pointers
|
||||
TORRENT_TEST(heterogeneuous_queue_push_back)
|
||||
{
|
||||
using namespace libtorrent;
|
||||
|
||||
// test push_back of heterogeneous types
|
||||
// and retrieval of their pointers
|
||||
{
|
||||
heterogeneous_queue<A> q;
|
||||
q.push_back(B(0, 1));
|
||||
TEST_EQUAL(q.size(), 1);
|
||||
|
@ -186,10 +185,13 @@ TORRENT_TEST(heterogeneuous_queue)
|
|||
|
||||
TEST_EQUAL(static_cast<C*>(ptrs[5])->a, 10);
|
||||
TEST_EQUAL(static_cast<C*>(ptrs[5])->c[0], 11);
|
||||
}
|
||||
}
|
||||
|
||||
// test swap
|
||||
TORRENT_TEST(heterogeneuous_queue_swap)
|
||||
{
|
||||
using namespace libtorrent;
|
||||
|
||||
// test swap
|
||||
{
|
||||
heterogeneous_queue<A> q1;
|
||||
heterogeneous_queue<A> q2;
|
||||
|
||||
|
@ -232,10 +234,13 @@ TORRENT_TEST(heterogeneuous_queue)
|
|||
TEST_EQUAL(ptrs[0]->type(), 1);
|
||||
TEST_EQUAL(ptrs[1]->type(), 1);
|
||||
TEST_EQUAL(ptrs[2]->type(), 1);
|
||||
}
|
||||
}
|
||||
|
||||
// test destruction
|
||||
TORRENT_TEST(heterogeneuous_queue_destruction)
|
||||
{
|
||||
using namespace libtorrent;
|
||||
|
||||
// test destruction
|
||||
{
|
||||
heterogeneous_queue<D> q;
|
||||
TEST_EQUAL(D::instances, 0);
|
||||
|
||||
|
@ -251,10 +256,13 @@ TORRENT_TEST(heterogeneuous_queue)
|
|||
q.clear();
|
||||
|
||||
TEST_EQUAL(D::instances, 0);
|
||||
}
|
||||
}
|
||||
|
||||
// test copy/move
|
||||
TORRENT_TEST(heterogeneuous_queue_copy_move)
|
||||
{
|
||||
using namespace libtorrent;
|
||||
|
||||
// test copy/move
|
||||
{
|
||||
heterogeneous_queue<F> q;
|
||||
|
||||
// make sure the queue has to grow at some point, to exercise its
|
||||
|
@ -275,16 +283,17 @@ TORRENT_TEST(heterogeneuous_queue)
|
|||
|
||||
// destroy all objects, asserting that their invariant still holds
|
||||
q.clear();
|
||||
}
|
||||
}
|
||||
|
||||
TORRENT_TEST(heterogeneuous_queue_nontrivial)
|
||||
{
|
||||
using namespace libtorrent;
|
||||
|
||||
{
|
||||
heterogeneous_queue<E> q;
|
||||
for (int i = 0; i < 10000; ++i)
|
||||
{
|
||||
q.push_back(E("testing to allocate non-trivial objects"));
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -60,13 +60,17 @@ TORRENT_TEST(ip_voter_test_random)
|
|||
{
|
||||
ip_voter ipv;
|
||||
|
||||
bool new_ip = cast_vote(ipv, rand_v4(), rand_v4());
|
||||
address_v4 addr1(address_v4::from_string("51.41.61.132"));
|
||||
|
||||
bool new_ip = cast_vote(ipv, addr1, rand_v4());
|
||||
TEST_CHECK(new_ip);
|
||||
TEST_CHECK(ipv.external_address() == addr1);
|
||||
for (int i = 0; i < 1000; ++i)
|
||||
{
|
||||
new_ip = cast_vote(ipv, rand_v4(), rand_v4());
|
||||
TEST_CHECK(!new_ip);
|
||||
}
|
||||
TEST_CHECK(ipv.external_address() == addr1);
|
||||
}
|
||||
|
||||
TORRENT_TEST(ip_voter_two_ips)
|
||||
|
|
Loading…
Reference in New Issue