Skip to content
Snippets Groups Projects
Commit b4a1d339 authored by Nat Goodspeed's avatar Nat Goodspeed
Browse files

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.
parent 8c6f7529
No related branches found
No related tags found
No related merge requests found
...@@ -40,6 +40,7 @@ ...@@ -40,6 +40,7 @@
#include <boost/scoped_ptr.hpp> #include <boost/scoped_ptr.hpp>
// other Linden headers // other Linden headers
#include "../test/lltut.h" #include "../test/lltut.h"
#include "wrapllerrs.h"
struct Keyed: public LLInstanceTracker<Keyed, std::string> struct Keyed: public LLInstanceTracker<Keyed, std::string>
{ {
...@@ -165,4 +166,67 @@ namespace tut ...@@ -165,4 +166,67 @@ namespace tut
ensure_equals("unreported instance", instances.size(), 0); 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 } // namespace tut
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment