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))
Esempio n. 2
0
    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]))
Esempio n. 3
0
    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]))
Esempio n. 4
0
    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]))
Esempio n. 5
0
    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))
Esempio n. 6
0
    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]))
Esempio n. 8
0
    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]))
Esempio n. 10
0
    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]))
Esempio n. 11
0
    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)
Esempio n. 12
0
    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))
Esempio n. 13
0
    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])
Esempio n. 14
0
    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)
Esempio n. 15
0
    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)
Esempio n. 16
0
    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 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)
Esempio n. 18
0
    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)
Esempio n. 19
0
    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)
Esempio n. 20
0
    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))
Esempio n. 21
0
    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))
Esempio n. 22
0
    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)
Esempio n. 24
0
    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))
Esempio n. 25
0
    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)
Esempio n. 26
0
        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)
Esempio n. 28
0
    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]))
Esempio n. 29
0
    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)
Esempio n. 31
0
    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())
Esempio n. 34
0
    def testRemoveAllObjects(self):
        s = self.setClass([1,2,3])

        OC_TestSet.removeAllObjecsFromSet_(s)
        self.assertEqual(s, self.setClass())
Esempio n. 35
0
    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]))
Esempio n. 36
0
 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)
Esempio n. 38
0
 def testDescription(self):
     s = self.setClass([OC_TestElem(1), 2])
     o = OC_TestSet.descriptionOfSet_(s)
     self.assertIsInstance(o, unicode)
Esempio n. 39
0
    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]))
Esempio n. 40
0
    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))
Esempio n. 41
0
    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)
Esempio n. 42
0
    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]))
Esempio n. 47
0
 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]))
Esempio n. 49
0
 def testProxyClass(self):
     # Ensure that the right class is used to proxy sets
     self.assert_(OC_TestSet.classOf_(self.seqClass()) is OC_PythonArray)
Esempio n. 50
0
 def testProxyClass(self):
     # Ensure that the right class is used to proxy sets
     self.assertIs(OC_TestSet.classOf_(self.setClass()), OC_PythonSet)
Esempio n. 51
0
 def testProxyClass(self):
     # Ensure that the right class is used to proxy sets
     self.assert_(OC_TestSet.classOf_(self.seqClass()) is OC_PythonArray)
Esempio n. 52
0
 def testProxyClass(self):
     # Ensure that the right class is used to proxy sets
     self.assertIs(OC_TestSet.classOf_(self.mapClass()),
                   OC_BuiltinPythonDictionary)