예제 #1
0
    def test_merge_indirect(self):
        s = PartitionState()

        for i in range(10):
            s.insert(i)

        for i in range(9):
            s.merge(i, i + 1)

        for i in range(10):
            self.assertTrue(s.same_partition(0, i))
예제 #2
0
    def test_merge(self):
        s = PartitionState()

        for i in range(10):
            s.insert(i)

        for i in range(5):
            s.merge(i, i + 5)

        for i in range(5):
            self.assertTrue(s.same_partition(i, i + 5))
예제 #3
0
def _recursive_update(lhs, rhs, analysis: PartitionState, merge: bool):
    if isinstance(lhs, TupleExpr) and isinstance(rhs, TupleExpr):
        for l, r in zip(lhs.elements, rhs.elements):
            _recursive_update(l, r, analysis, merge)
    else:
        lhs = lhs.privacy_annotation_label()
        rhs = rhs.privacy_annotation_label()
        if lhs and rhs:
            if merge:
                analysis.merge(lhs, rhs)
            else:
                analysis.move_to(lhs, rhs)
예제 #4
0
    def test_remove(self):
        s = PartitionState()

        for i in range(10):
            s.insert(i)

        for i in range(9):
            s.merge(i, i + 1)

        for i in range(5, 10):
            s.remove(i)

        for i in range(5):
            self.assertTrue(s.same_partition(0, i))
예제 #5
0
    def test_move_to(self):
        s = PartitionState()

        for i in range(10):
            s.insert(i)

        for i in range(5):
            s.merge(0, i)

        for i in range(5, 10):
            s.merge(5, i)

        s.move_to(0, 5)

        for i in range(1, 5):
            self.assertTrue(s.same_partition(1, i))

        for i in range(5, 10):
            self.assertTrue(s.same_partition(0, i))
예제 #6
0
 def test_self_merge(self):
     s = PartitionState()
     s.insert(0)
     s.merge(0, 0)
     self.assertTrue(s.same_partition(0, 0))