def testIsSubSet(self): s1 = self.setClass(range(10)) s2 = self.setClass(range(5)) self.assertTrue(OC_TestSet.set_isSubsetOfSet_(s2, s1)) self.assertTrue(OC_TestSet.set_isSubsetOfSet_(s2, s2)) self.assertFalse(OC_TestSet.set_isSubsetOfSet_(s1, s2))
def testRemoveObject(self): s = self.setClass([1, 2, 3]) OC_TestSet.set_removeObject_(s, 1) self.assertEqual(s, self.setClass([2, 3])) OC_TestSet.set_removeObject_(s, 9) self.assertEqual(s, self.setClass([2, 3]))
def testAddObjectsFromArray(self): s = self.setClass([1, 2, 3]) OC_TestSet.set_addObjectsFromArray_(s, [1, 2]) self.assertEqual(s, self.setClass([1, 2, 3])) OC_TestSet.set_addObjectsFromArray_(s, [9, 5, 4]) self.assertEqual(s, self.setClass([1, 2, 3, 9, 5, 4]))
def testAddObject(self): s = self.setClass([1, 2, 3]) OC_TestSet.set_addObject_(s, 1) self.assertEqual(s, self.setClass([1, 2, 3])) OC_TestSet.set_addObject_(s, 9) self.assertEqual(s, self.setClass([1, 2, 3, 9]))
def testIntersects(self): s1 = self.setClass([1, 2, 3, 4]) s2 = self.setClass([3, 4, 5, 6]) s3 = self.setClass([5, 6, 7, 8]) self.assertTrue(OC_TestSet.set_intersectsSet_(s1, s2)) self.assertTrue(OC_TestSet.set_intersectsSet_(s2, s3)) self.assertFalse(OC_TestSet.set_intersectsSet_(s1, s3))
def testAllObject(self): s = self.setClass() self.assertEqual(OC_TestSet.allObjectsOfSet_(s), []) s = self.setClass([1, 2, 3]) o = OC_TestSet.allObjectsOfSet_(s) o.sort() self.assertEqual(o, [1, 2, 3])
def testRemoveObject(self): s = self.setClass([1,2,3]) OC_TestSet.set_removeObject_(s, 1) self.assertEqual(s, self.setClass([2,3])) OC_TestSet.set_removeObject_(s, 9) self.assertEqual(s, self.setClass([2,3]))
def testCopy(self): s = self.seqClass() o = OC_TestSet.set_copyWithZone_(s, None) self.assertEquals(s, o) s = self.seqClass(range(20)) o = OC_TestSet.set_copyWithZone_(s, None) self.assertEquals(s, o)
def testAddObject(self): s = self.setClass([1,2,3]) OC_TestSet.set_addObject_(s, 1) self.assertEqual(s, self.setClass([1,2,3])) OC_TestSet.set_addObject_(s, 9) self.assertEqual(s, self.setClass([1,2,3,9]))
def testAddObjectsFromArray(self): s = self.setClass([1,2,3]) OC_TestSet.set_addObjectsFromArray_(s, [1,2]) self.assertEqual(s, self.setClass([1,2,3])) OC_TestSet.set_addObjectsFromArray_(s, [9,5,4]) self.assertEqual(s, self.setClass([1,2,3,9,5,4]))
def testCopy(self): s = self.seqClass() o = OC_TestSet.set_copyWithZone_(s, None) self.assertEqual(s, o) s = self.seqClass(range(20)) o = OC_TestSet.set_copyWithZone_(s, None) self.assertEqual(s, o)
def testIntersects(self): s1 = self.setClass([1,2,3,4]) s2 = self.setClass([3,4,5,6]) s3 = self.setClass([5,6,7,8]) self.assertTrue(OC_TestSet.set_intersectsSet_(s1, s2)) self.assertTrue(OC_TestSet.set_intersectsSet_(s2, s3)) self.assertFalse(OC_TestSet.set_intersectsSet_(s1, s3))
def testAllObject(self): s = self.setClass() self.assertEqual(OC_TestSet.allObjectsOfSet_(s), []) s = self.setClass([1,2,3]) o = OC_TestSet.allObjectsOfSet_(s) o.sort() self.assertEqual(o, [1,2,3])
def testCopy(self): s = self.mapClass() o = OC_TestSet.set_copyWithZone_(s, None) self.assertEqual(s, o) self.assertIsNot(s, o) s = self.mapClass({1: 2, 'a': 'c'}) o = OC_TestSet.set_copyWithZone_(s, None) self.assertEqual(s, o) self.assertIsNot(s, o)
def testCopy(self): s = self.mapClass() o = OC_TestSet.set_copyWithZone_(s, None) self.assertEquals(s, o) self.assert_(s is not o) s = self.mapClass({1:2, 'a':'c'}) o = OC_TestSet.set_copyWithZone_(s, None) self.assertEquals(s, o) self.assert_(s is not o)
def testMakeObjectsPerform(self): o1 = OC_TestElem(1) o2 = OC_TestElem(2) o3 = OC_TestElem(3) s = self.setClass([o1, o2, o3]) o = OC_TestSet.set_member_(s, OC_TestElem(4)) self.assertIsNone(o) o = OC_TestSet.set_member_(s, OC_TestElem(2)) self.assertIs(o, o2)
def testMutableCopy(self): s = self.mapClass({1: 2, 'a': 'c'}) o = OC_TestSet.set_mutableCopyWithZone_(s, None) self.assertEqual(dict(s), o) self.assertIsNot(s, o) self.assertIsInstance(o, dict) s = self.mapClass() o = OC_TestSet.set_mutableCopyWithZone_(s, None) self.assertEqual(dict(s), o) self.assertIsNot(s, o) self.assertIsInstance(o, dict)
def testMutableCopy(self): s = self.mapClass({1:2, 'a':'c'}) o = OC_TestSet.set_mutableCopyWithZone_(s, None) self.assertEqual(dict(s), o) self.assertIsNot(s, o) self.assertIsInstance(o, dict) s = self.mapClass() o = OC_TestSet.set_mutableCopyWithZone_(s, None) self.assertEqual(dict(s), o) self.assertIsNot(s, o) self.assertIsInstance(o, dict)
def testMutableCopy(self): s = self.mapClass({1: 2, 'a': 'c'}) o = OC_TestSet.set_mutableCopyWithZone_(s, None) self.assertEquals(dict(s), o) self.assert_(s is not o) self.assert_(isinstance(o, dict)) s = self.mapClass() o = OC_TestSet.set_mutableCopyWithZone_(s, None) self.assertEquals(dict(s), o) self.assert_(s is not o) self.assert_(isinstance(o, dict))
def testMutableCopy(self): s = self.seqClass(range(20)) o = OC_TestSet.set_mutableCopyWithZone_(s, None) self.assertEquals(list(s), o) self.assert_(s is not o) self.assert_(isinstance(o, list)) s = self.seqClass() o = OC_TestSet.set_mutableCopyWithZone_(s, None) self.assertEquals(list(s), o) self.assert_(s is not o) self.assert_(isinstance(o, list))
def testMutableCopy(self): s = self.setClass(range(20)) o = OC_TestSet.set_mutableCopyWithZone_(s, None) self.assertEquals(s, o) self.assertIsNot(s, o) self.assertIsInstance(o, set) s = self.setClass() o = OC_TestSet.set_mutableCopyWithZone_(s, None) self.assertEquals(s, o) self.assertIsNot(s, o) self.assertIsInstance(o, set)
def testMutableCopy(self): s = self.mapClass({1:2, 'a':'c'}) o = OC_TestSet.set_mutableCopyWithZone_(s, None) self.assertEquals(dict(s), o) self.assert_(s is not o) self.assert_(isinstance(o, dict)) s = self.mapClass() o = OC_TestSet.set_mutableCopyWithZone_(s, None) self.assertEquals(dict(s), o) self.assert_(s is not o) self.assert_(isinstance(o, dict))
def testMutableCopy(self): s = self.setClass(range(20)) o = OC_TestSet.set_mutableCopyWithZone_(s, None) self.assertEqual(s, o) self.assertIsNot(s, o) self.assertIsInstance(o, set) s = self.setClass() o = OC_TestSet.set_mutableCopyWithZone_(s, None) self.assertEqual(s, o) self.assertIsNot(s, o) self.assertIsInstance(o, set)
def testFilteredSetUsingPredicate(self): s = self.setClass(range(10)) p = OC_SetPredicate.alloc().initWithFunction_(lambda x: x % 2 == 0) o = OC_TestSet.set_filteredSetUsingPredicate_(s, p) self.assertEqual(o, self.setClass([0, 2, 4, 6, 8])) self.assertEqual(len(s), 10)
def testFilteredSetUsingPredicate(self): s = self.setClass(range(10)) p = OC_SetPredicate.alloc().initWithFunction_(lambda x: x % 2 == 0) o = OC_TestSet.set_filteredSetUsingPredicate_(s, p) self.assertEquals(o, self.setClass([0, 2, 4, 6, 8])) self.assertEquals(len(s), 10)
def testObjectEnumerator(self): s = self.setClass(range(10)) enum = OC_TestSet.objectEnumeratorOfSet_(s) l = [] v = enum.nextObject() while v is not None: l.append(v) v = enum.nextObject() self.assertEqual(l, list(range(10))) s = self.setClass([1, 2, None, 3]) enum = OC_TestSet.objectEnumeratorOfSet_(s) l = [] v = enum.nextObject() while v is not None: l.append(v) v = enum.nextObject() self.assertEqual(dict.fromkeys(l), dict.fromkeys([1, 2, NSNull.null(), 3]))
def testObjectEnumerator(self): s = self.setClass(range(10)) enum = OC_TestSet.objectEnumeratorOfSet_(s) l = [] v = enum.nextObject() while v is not None: l.append(v) v = enum.nextObject() self.assertEqual(l, list(range(10))) s = self.setClass([1, 2, None, 3]) enum = OC_TestSet.objectEnumeratorOfSet_(s) l = [] v = enum.nextObject() while v is not None: l.append(v) v = enum.nextObject() self.assertEqual(dict.fromkeys(l), dict.fromkeys([1,2,NSNull.null(),3]))
def testCount(self): s = self.setClass() self.assertEquals(OC_TestSet.countOfSet_(s), 0) s = self.setClass([1, 2, 3]) self.assertEquals(OC_TestSet.countOfSet_(s), 3)
def testMinusSet(self): s1 = self.setClass([1,2,3]) s2 = self.setClass([3,4,5]) OC_TestSet.set_minusSet_(s1, s2) self.assertEqual(s1, self.setClass([1, 2]))
def testProxyClass(self): # Ensure that the right class is used to proxy sets self.assertIs(OC_TestSet.classOf_(self.setClass()), OC_PythonSet)
def testRemoveAllObjects(self): s = self.setClass([1, 2, 3]) OC_TestSet.removeAllObjecsFromSet_(s) self.assertEquals(s, self.setClass())
def testRemoveAllObjects(self): s = self.setClass([1,2,3]) OC_TestSet.removeAllObjecsFromSet_(s) self.assertEqual(s, self.setClass())
def testUnionSet(self): s1 = self.setClass([1,2,3]) s2 = self.setClass([3,4,5]) OC_TestSet.set_unionSet_(s1, s2) self.assertEqual(s1, self.setClass([1,2,3,4,5]))
def testProxyClass(self): # Ensure that the right class is used to proxy sets self.assertIs(OC_TestSet.classOf_(self.seqClass()), OC_BuiltinPythonArray)
def testDescription(self): s = self.setClass([OC_TestElem(1), 2]) o = OC_TestSet.descriptionOfSet_(s) self.assertIsInstance(o, unicode)
def testIntersectSet(self): s1 = self.setClass([1,2,3]) s2 = self.setClass([3,4,5]) OC_TestSet.set_intersectSet_(s1, s2) self.assertEqual(s1, self.setClass([3]))
def testContainsObject_(self): s = self.setClass([1,2,3]) self.assertFalse(OC_TestSet.set_containsObject_(s, 4)) self.assertTrue(OC_TestSet.set_containsObject_(s, 2))
def testAnyObject(self): s = self.setClass() self.assertEqual(OC_TestSet.anyObjectOfSet_(s), None) s = self.setClass([1,2,3,4]) self.assertIn(OC_TestSet.anyObjectOfSet_(s), s)
def testCount(self): s = self.setClass() self.assertEqual(OC_TestSet.countOfSet_(s), 0) s = self.setClass([1,2,3]) self.assertEqual(OC_TestSet.countOfSet_(s), 3)
def testAnyObject(self): s = self.setClass() self.assertEquals(OC_TestSet.anyObjectOfSet_(s), None) s = self.setClass([1, 2, 3, 4]) self.assertIn(OC_TestSet.anyObjectOfSet_(s), s)
def testUnionSet(self): s1 = self.setClass([1, 2, 3]) s2 = self.setClass([3, 4, 5]) OC_TestSet.set_unionSet_(s1, s2) self.assertEquals(s1, self.setClass([1, 2, 3, 4, 5]))
def testContainsObject_(self): s = self.setClass([1, 2, 3]) self.assertFalse(OC_TestSet.set_containsObject_(s, 4)) self.assertTrue(OC_TestSet.set_containsObject_(s, 2))
def testMinusSet(self): s1 = self.setClass([1, 2, 3]) s2 = self.setClass([3, 4, 5]) OC_TestSet.set_minusSet_(s1, s2) self.assertEquals(s1, self.setClass([1, 2]))
def testProxyClass(self): # Ensure that the right class is used to proxy sets self.assert_(OC_TestSet.classOf_(self.mapClass()) is OC_PythonDictionary)
def testIntersectSet(self): s1 = self.setClass([1, 2, 3]) s2 = self.setClass([3, 4, 5]) OC_TestSet.set_intersectSet_(s1, s2) self.assertEquals(s1, self.setClass([3]))
def testProxyClass(self): # Ensure that the right class is used to proxy sets self.assert_(OC_TestSet.classOf_(self.seqClass()) is OC_PythonArray)
def testProxyClass(self): # Ensure that the right class is used to proxy sets self.assertIs(OC_TestSet.classOf_(self.mapClass()), OC_BuiltinPythonDictionary)