check for self-assignment in bitfield operator=
This commit is contained in:
parent
1dc8c1c127
commit
8c18baf10e
|
@ -145,6 +145,7 @@ namespace libtorrent {
|
|||
// assignment operator
|
||||
bitfield& operator=(bitfield const& rhs)
|
||||
{
|
||||
if (&rhs == this) return *this;
|
||||
assign(rhs.data(), rhs.size());
|
||||
return *this;
|
||||
}
|
||||
|
|
|
@ -387,6 +387,14 @@ TORRENT_TEST(not_initialized)
|
|||
// get_bit, clear_bit, set_bit
|
||||
}
|
||||
|
||||
TORRENT_TEST(self_assign)
|
||||
{
|
||||
bitfield test1(123, false);
|
||||
test1 = test1;
|
||||
TEST_EQUAL(test1.size(), 123);
|
||||
TEST_EQUAL(test1.count(), 0);
|
||||
}
|
||||
|
||||
TORRENT_TEST(not_initialized_assign)
|
||||
{
|
||||
// check a not initialized empty bitfield
|
||||
|
|
Loading…
Reference in New Issue