summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNat Goodspeed <nat@lindenlab.com>2011-09-07 17:29:08 -0400
committerNat Goodspeed <nat@lindenlab.com>2011-09-07 17:29:08 -0400
commitb4a1d339fc9bc69c1045a622bf59df815fdc77ad (patch)
tree99ecda7b24e4030a965970ed2f55b448f74e70b6
parent8c6f752982e83a50e328b9c83f762721f38836d7 (diff)
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.
-rw-r--r--indra/llcommon/tests/llinstancetracker_test.cpp64
1 files changed, 64 insertions, 0 deletions
diff --git a/indra/llcommon/tests/llinstancetracker_test.cpp b/indra/llcommon/tests/llinstancetracker_test.cpp
index 80b35bbdc3..b34d1c5fd3 100644
--- a/indra/llcommon/tests/llinstancetracker_test.cpp
+++ b/indra/llcommon/tests/llinstancetracker_test.cpp
@@ -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