python/dist/src/Lib/test test_sets.py,1.27,1.28
Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1:/tmp/cvs-serv13992 Modified Files: test_sets.py Log Message: Improve and expand identity tests. Index: test_sets.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_sets.py,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** test_sets.py 30 Aug 2003 22:54:55 -0000 1.27 --- test_sets.py 21 Sep 2003 08:14:11 -0000 1.28 *************** *** 1,5 **** #!/usr/bin/env python ! import unittest, operator, copy, pickle from sets import Set, ImmutableSet from test import test_support --- 1,5 ---- #!/usr/bin/env python ! import unittest, operator, copy, pickle, random from sets import Set, ImmutableSet from test import test_support *************** *** 712,727 **** class TestIdentities(unittest.TestCase): def setUp(self): ! self.a = Set('abracadabra') ! self.b = Set('alacazam') def test_binopsVsSubsets(self): a, b = self.a, self.b ! self.assert_(a - b < a) ! self.assert_(b - a < b) ! self.assert_(a & b < a) ! self.assert_(a & b < b) ! self.assert_(a | b > a) ! self.assert_(a | b > b) ! self.assert_(a ^ b < a | b) def test_commutativity(self): --- 712,727 ---- class TestIdentities(unittest.TestCase): def setUp(self): ! self.a = Set([random.randrange(100) for i in xrange(50)]) ! self.b = Set([random.randrange(100) for i in xrange(50)]) def test_binopsVsSubsets(self): a, b = self.a, self.b ! self.assert_(a - b <= a) ! self.assert_(b - a <= b) ! self.assert_(a & b <= a) ! self.assert_(a & b <= b) ! self.assert_(a | b >= a) ! self.assert_(a | b >= b) ! self.assert_(a ^ b <= a | b) def test_commutativity(self): *************** *** 745,753 **** def test_exclusion(self): ! # check that inverse operations show non-overlap a, b, zero = self.a, self.b, Set() self.assertEqual((a-b)&b, zero) self.assertEqual((b-a)&a, zero) self.assertEqual((a&b)&(a^b), zero) #============================================================================== --- 745,760 ---- def test_exclusion(self): ! # check that inverse operations do not overlap a, b, zero = self.a, self.b, Set() self.assertEqual((a-b)&b, zero) self.assertEqual((b-a)&a, zero) self.assertEqual((a&b)&(a^b), zero) + + def test_cardinality_relations(self): + a, b = self.a, self.b + self.assertEqual(len(a), len(a-b) + len(a&b)) + self.assertEqual(len(b), len(b-a) + len(a&b)) + self.assertEqual(len(a^b), len(a-b) + len(b-a)) + self.assertEqual(len(a|b), len(a-b) + len(a&b) + len(b-a)) #==============================================================================
participants (1)
-
rhettingerīŧ users.sourceforge.net