Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Alchemy Viewer
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Package registry
Operate
Terraform modules
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Silent mode is enabled
All outbound communications are blocked.
Learn more
.
Show more breadcrumbs
Alchemy Viewer
Alchemy Viewer
Commits
291cc7a7
Commit
291cc7a7
authored
13 years ago
by
Brad Payne (Vir Linden)
Browse files
Options
Downloads
Plain Diff
merge
parents
ff605460
bf906ac9
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
indra/llcommon/llinstancetracker.h
+1
-1
1 addition, 1 deletion
indra/llcommon/llinstancetracker.h
indra/llcommon/tests/llinstancetracker_test.cpp
+72
-72
72 additions, 72 deletions
indra/llcommon/tests/llinstancetracker_test.cpp
with
73 additions
and
73 deletions
indra/llcommon/llinstancetracker.h
+
1
−
1
View file @
291cc7a7
...
...
@@ -92,7 +92,7 @@ class LLInstanceTracker : public LLInstanceTrackerBase
public:
typedef
boost
::
iterator_facade
<
key_iter
,
KEY
,
boost
::
forward_traversal_tag
>
super_t
;
key_iter
(
typename
InstanceMap
::
iterator
&
it
)
key_iter
(
typename
InstanceMap
::
iterator
it
)
:
mIterator
(
it
)
{
++
sIterationNestDepth
;
...
...
This diff is collapsed.
Click to expand it.
indra/llcommon/tests/llinstancetracker_test.cpp
+
72
−
72
View file @
291cc7a7
...
...
@@ -90,79 +90,79 @@ namespace tut
ensure_equals
(
Keyed
::
instanceCount
(),
0
);
}
//
template<> template<>
//
void object::test<2>()
//
{
//
ensure_equals(Unkeyed::instanceCount(), 0);
//
{
//
Unkeyed one;
//
ensure_equals(Unkeyed::instanceCount(), 1);
//
Unkeyed* found = Unkeyed::getInstance(&one);
//
ensure_equals(found, &one);
//
{
//
boost::scoped_ptr<Unkeyed> two(new Unkeyed);
//
ensure_equals(Unkeyed::instanceCount(), 2);
//
Unkeyed* found = Unkeyed::getInstance(two.get());
//
ensure_equals(found, two.get());
//
}
//
ensure_equals(Unkeyed::instanceCount(), 1);
//
}
//
ensure_equals(Unkeyed::instanceCount(), 0);
//
}
template
<
>
template
<
>
void
object
::
test
<
2
>
()
{
ensure_equals
(
Unkeyed
::
instanceCount
(),
0
);
{
Unkeyed
one
;
ensure_equals
(
Unkeyed
::
instanceCount
(),
1
);
Unkeyed
*
found
=
Unkeyed
::
getInstance
(
&
one
);
ensure_equals
(
found
,
&
one
);
{
boost
::
scoped_ptr
<
Unkeyed
>
two
(
new
Unkeyed
);
ensure_equals
(
Unkeyed
::
instanceCount
(),
2
);
Unkeyed
*
found
=
Unkeyed
::
getInstance
(
two
.
get
());
ensure_equals
(
found
,
two
.
get
());
}
ensure_equals
(
Unkeyed
::
instanceCount
(),
1
);
}
ensure_equals
(
Unkeyed
::
instanceCount
(),
0
);
}
//
template<> template<>
//
void object::test<3>()
//
{
//
Keyed one("one"), two("two"), three("three");
//
// We don't want to rely on the underlying container delivering keys
//
// in any particular order. That allows us the flexibility to
//
// reimplement LLInstanceTracker using, say, a hash map instead of a
//
// std::map. We DO insist that every key appear exactly once.
//
typedef std::vector<std::string> StringVector;
//
StringVector keys(Keyed::beginKeys(), Keyed::endKeys());
//
std::sort(keys.begin(), keys.end());
//
StringVector::const_iterator ki(keys.begin());
//
ensure_equals(*ki++, "one");
//
ensure_equals(*ki++, "three");
//
ensure_equals(*ki++, "two");
//
// Use ensure() here because ensure_equals would want to display
//
// mismatched values, and frankly that wouldn't help much.
//
ensure("didn't reach end", ki == keys.end());
template
<
>
template
<
>
void
object
::
test
<
3
>
()
{
Keyed
one
(
"one"
),
two
(
"two"
),
three
(
"three"
);
// We don't want to rely on the underlying container delivering keys
// in any particular order. That allows us the flexibility to
// reimplement LLInstanceTracker using, say, a hash map instead of a
// std::map. We DO insist that every key appear exactly once.
typedef
std
::
vector
<
std
::
string
>
StringVector
;
StringVector
keys
(
Keyed
::
beginKeys
(),
Keyed
::
endKeys
());
std
::
sort
(
keys
.
begin
(),
keys
.
end
());
StringVector
::
const_iterator
ki
(
keys
.
begin
());
ensure_equals
(
*
ki
++
,
"one"
);
ensure_equals
(
*
ki
++
,
"three"
);
ensure_equals
(
*
ki
++
,
"two"
);
// Use ensure() here because ensure_equals would want to display
// mismatched values, and frankly that wouldn't help much.
ensure
(
"didn't reach end"
,
ki
==
keys
.
end
());
// // Use a somewhat different approach to order independence with
// // beginInstances(): explicitly capture the instances we know in a
// // set, and delete them as we iterate through.
// typedef std::set<Keyed*> InstanceSet;
// InstanceSet instances;
// instances.insert(&one);
// instances.insert(&two);
// instances.insert(&three);
// for (Keyed::instance_iter ii(Keyed::beginInstances()), iend(Keyed::endInstances());
// ii != iend; ++ii)
// {
// Keyed& ref = *ii;
// ensure_equals("spurious instance", instances.erase(&ref), 1);
// }
// ensure_equals("unreported instance", instances.size(), 0);
// }
// Use a somewhat different approach to order independence with
// beginInstances(): explicitly capture the instances we know in a
// set, and delete them as we iterate through.
typedef
std
::
set
<
Keyed
*>
InstanceSet
;
InstanceSet
instances
;
instances
.
insert
(
&
one
);
instances
.
insert
(
&
two
);
instances
.
insert
(
&
three
);
for
(
Keyed
::
instance_iter
ii
(
Keyed
::
beginInstances
()),
iend
(
Keyed
::
endInstances
());
ii
!=
iend
;
++
ii
)
{
Keyed
&
ref
=
*
ii
;
ensure_equals
(
"spurious instance"
,
instances
.
erase
(
&
ref
),
1
);
}
ensure_equals
(
"unreported instance"
,
instances
.
size
(),
0
);
}
template
<
>
template
<
>
void
object
::
test
<
4
>
()
{
Unkeyed
one
,
two
,
three
;
typedef
std
::
set
<
Unkeyed
*>
KeySet
;
KeySet
instances
;
instances
.
insert
(
&
one
);
instances
.
insert
(
&
two
);
instances
.
insert
(
&
three
);
// template<> template<>
// void object::test<4>()
// {
// Unkeyed one, two, three;
// typedef std::set<Unkeyed*> KeySet;
//
// KeySet instances;
// instances.insert(&one);
// instances.insert(&two);
// instances.insert(&three);
//for (Unkeyed::instance_iter ii(Unkeyed::beginInstances()), iend(Unkeyed::endInstances()); ii != iend; ++ii)
//{
// Unkeyed& ref = *ii;
// ensure_equals("spurious instance", instances.erase(&ref), 1);
//}
// ensure_equals("unreported instance", instances.size(), 0);
// }
for
(
Unkeyed
::
instance_iter
ii
(
Unkeyed
::
beginInstances
()),
iend
(
Unkeyed
::
endInstances
());
ii
!=
iend
;
++
ii
)
{
Unkeyed
&
ref
=
*
ii
;
ensure_equals
(
"spurious instance"
,
instances
.
erase
(
&
ref
),
1
);
}
ensure_equals
(
"unreported instance"
,
instances
.
size
(),
0
);
}
}
// namespace tut
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment