STORM-1541: Add LLInstanceTracker tests for active-iterator asserts.

The recent class-static LLInstanceTracker::instance_iter and key_iter
reference count is intended to guard against deleting an instance of an
LLInstanceTracker subclass during iteration. Add tests for that functionality.
meow-7.2.2
Nat Goodspeed 2011-09-07 17:29:08 -04:00
parent 8c6f752982
commit b4a1d339fc
1 changed files with 64 additions and 0 deletions

View File

@ -40,6 +40,7 @@
#include <boost/scoped_ptr.hpp>
// other Linden headers
#include "../test/lltut.h"
#include "wrapllerrs.h"
struct Keyed: public LLInstanceTracker<Keyed, std::string>
{
@ -165,4 +166,67 @@ namespace tut
ensure_equals("unreported instance", instances.size(), 0);
}
template<> template<>
void object::test<5>()
{
set_test_name("delete Keyed with outstanding instance_iter");
std::string what;
Keyed* keyed = new Keyed("one");
{
WrapLL_ERRS wrapper;
Keyed::instance_iter i(Keyed::beginInstances());
try
{
delete keyed;
}
catch (const WrapLL_ERRS::FatalException& e)
{
what = e.what();
}
}
ensure(! what.empty());
}
template<> template<>
void object::test<6>()
{
set_test_name("delete Keyed with outstanding key_iter");
std::string what;
Keyed* keyed = new Keyed("one");
{
WrapLL_ERRS wrapper;
Keyed::key_iter i(Keyed::beginKeys());
try
{
delete keyed;
}
catch (const WrapLL_ERRS::FatalException& e)
{
what = e.what();
}
}
ensure(! what.empty());
}
template<> template<>
void object::test<7>()
{
set_test_name("delete Unkeyed with outstanding instance_iter");
std::string what;
Unkeyed* unkeyed = new Unkeyed;
{
WrapLL_ERRS wrapper;
Unkeyed::instance_iter i(Unkeyed::beginInstances());
try
{
delete unkeyed;
}
catch (const WrapLL_ERRS::FatalException& e)
{
what = e.what();
}
}
ensure(! what.empty());
}
} // namespace tut