merged fix from RC_0_16

This commit is contained in:
Arvid Norberg 2013-01-20 19:35:47 +00:00
parent 36202c5dea
commit a67640bddb
2 changed files with 30 additions and 0 deletions

View File

@ -134,6 +134,7 @@ namespace libtorrent
m_number[i] <<= n;
m_number[i] |= m_number[i+1] >> (8 - n);
}
m_number[number_size-1] <<= n;
}
return *this;
}
@ -160,6 +161,7 @@ namespace libtorrent
m_number[i] >>= n;
m_number[i] |= m_number[i-1] << (8 - n);
}
m_number[0] >>= n;
}
return *this;
}

View File

@ -1835,6 +1835,34 @@ int test_main()
std::cerr << h1 << std::endl;
#endif
TEST_CHECK(h1 == to_hash("000fffffff0000000000ffffffffff0000000000"));
h1 = to_hash("7000000000000000000000000000000000000000");
h1 <<= 1;
#if TORRENT_USE_IOSTREAM
std::cerr << h1 << std::endl;
#endif
TEST_CHECK(h1 == to_hash("e000000000000000000000000000000000000000"));
h1 = to_hash("0000000000000000000000000000000000000007");
h1 <<= 1;
#if TORRENT_USE_IOSTREAM
std::cerr << h1 << std::endl;
#endif
TEST_CHECK(h1 == to_hash("000000000000000000000000000000000000000e"));
h1 = to_hash("0000000000000000000000000000000000000007");
h1 >>= 1;
#if TORRENT_USE_IOSTREAM
std::cerr << h1 << std::endl;
#endif
TEST_CHECK(h1 == to_hash("0000000000000000000000000000000000000003"));
h1 = to_hash("7000000000000000000000000000000000000000");
h1 >>= 1;
#if TORRENT_USE_IOSTREAM
std::cerr << h1 << std::endl;
#endif
TEST_CHECK(h1 == to_hash("3800000000000000000000000000000000000000"));
// CIDR distance test
h1 = to_hash("0123456789abcdef01232456789abcdef0123456");