Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
Zope
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
Zope
Commits
d0584c06
Commit
d0584c06
authored
May 15, 2002
by
Tim Peters
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
New testMany() -- a meatier test of the mass set ops.
parent
660aeac5
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
46 additions
and
0 deletions
+46
-0
lib/python/Products/ZCTextIndex/tests/testSetOps.py
lib/python/Products/ZCTextIndex/tests/testSetOps.py
+46
-0
No files found.
lib/python/Products/ZCTextIndex/tests/testSetOps.py
View file @
d0584c06
...
...
@@ -82,6 +82,52 @@ class TestSetOps(TestCase):
got
=
mass_weightedIntersection
([(
y
,
w2
),
(
x
,
w1
)])
self
.
assertEqual
(
expected
,
list
(
got
.
items
()))
def
testMany
(
self
):
import
random
N
=
15
# number of IIBTrees to feed in
L
=
[]
commonkey
=
N
*
1000
allkeys
=
{
commonkey
:
1
}
for
i
in
range
(
N
):
t
=
IIBTree
()
t
[
commonkey
]
=
i
for
j
in
range
(
N
-
i
):
key
=
i
+
j
allkeys
[
key
]
=
1
t
[
key
]
=
N
*
i
+
j
L
.
append
((
t
,
i
+
1
))
random
.
shuffle
(
L
)
allkeys
=
allkeys
.
keys
()
allkeys
.
sort
()
# Test the union.
expected
=
[]
for
key
in
allkeys
:
sum
=
0
for
t
,
w
in
L
:
if
t
.
has_key
(
key
):
sum
+=
t
[
key
]
*
w
expected
.
append
((
key
,
sum
))
# print 'union', expected
got
=
mass_weightedUnion
(
L
)
self
.
assertEqual
(
expected
,
list
(
got
.
items
()))
# Test the intersection.
expected
=
[]
for
key
in
allkeys
:
sum
=
0
for
t
,
w
in
L
:
if
t
.
has_key
(
key
):
sum
+=
t
[
key
]
*
w
else
:
break
else
:
# We didn't break out of the loop so it's in the intersection.
expected
.
append
((
key
,
sum
))
# print 'intersection', expected
got
=
mass_weightedIntersection
(
L
)
self
.
assertEqual
(
expected
,
list
(
got
.
items
()))
def
test_suite
():
return
makeSuite
(
TestSetOps
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment