1 # Copyright (C) 2003-2007, 2009-2011 Nominum, Inc.
3 # Permission to use, copy, modify, and distribute this software and its
4 # documentation for any purpose with or without fee is hereby granted,
5 # provided that the above copyright notice and this permission notice
6 # appear in all copies.
8 # THE SOFTWARE IS PROVIDED "AS IS" AND NOMINUM DISCLAIMS ALL WARRANTIES
9 # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NOMINUM BE LIABLE FOR
11 # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
14 # OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
23 class SimpleSetTestCase(unittest
.TestCase
):
27 self
.failUnless(len(s1
) == 0)
31 self
.failUnless(len(s1
) == 3)
34 s1
= S([1, 2, 3, 3, 3])
35 self
.failUnless(len(s1
) == 3)
41 self
.failUnless(s1 | s2
== e
)
47 self
.failUnless(s1 | s2
== e
)
53 self
.failUnless(s1 | s2
== e
)
55 def testIntersection1(self
):
59 self
.failUnless(s1
& s2
== e
)
61 def testIntersection2(self
):
65 self
.failUnless(s1
& s2
== e
)
67 def testIntersection3(self
):
71 self
.failUnless(s1
& s2
== e
)
73 def testIntersection4(self
):
77 self
.failUnless(s1
& s2
== e
)
79 def testDifference1(self
):
83 self
.failUnless(s1
- s2
== e
)
85 def testDifference2(self
):
89 self
.failUnless(s1
- s2
== e
)
91 def testDifference3(self
):
95 self
.failUnless(s1
- s2
== e
)
97 def testDifference4(self
):
101 self
.failUnless(s1
- s2
== e
)
103 def testSubset1(self
):
106 self
.failUnless(s1
.issubset(s2
))
108 def testSubset2(self
):
110 self
.failUnless(s1
.issubset(s1
))
112 def testSubset3(self
):
115 self
.failUnless(s1
.issubset(s2
))
117 def testSubset4(self
):
120 self
.failUnless(s1
.issubset(s2
))
122 def testSubset5(self
):
125 self
.failUnless(s1
.issubset(s2
))
127 def testSubset6(self
):
130 self
.failUnless(not s1
.issubset(s2
))
132 def testSuperset1(self
):
135 self
.failUnless(s1
.issuperset(s2
))
137 def testSuperset2(self
):
139 self
.failUnless(s1
.issuperset(s1
))
141 def testSuperset3(self
):
144 self
.failUnless(s1
.issuperset(s2
))
146 def testSuperset4(self
):
149 self
.failUnless(s1
.issuperset(s2
))
151 def testSuperset5(self
):
154 self
.failUnless(s1
.issuperset(s2
))
156 def testSuperset6(self
):
159 self
.failUnless(not s1
.issuperset(s2
))
161 def testUpdate1(self
):
164 e
= S([1, 2, 3, 4, 5, 6])
166 self
.failUnless(s1
== e
)
168 def testUpdate2(self
):
173 self
.failUnless(s1
== e
)
175 def testGetitem(self
):
181 self
.failUnless(s1
== s2
)
183 def testGetslice(self
):
186 self
.failUnless(len(slice) == 2)
190 self
.failUnless(s1
== s2
)
192 def testDelitem(self
):
197 self
.failUnless(i1
!= i2
)
198 self
.failUnless(i1
== 1 or i1
== 2 or i1
== 3)
199 self
.failUnless(i2
== 1 or i2
== 2 or i2
== 3)
201 def testDelslice(self
):
205 self
.failUnless(i1
== 1 or i1
== 2 or i1
== 3)
207 if __name__
== '__main__':