~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to tests/test_equivalence_table.py

Remove the equivalence table tests, since we don't use it anymore.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2008 Canonical Limited.
2
 
#
3
 
# This program is free software; you can redistribute it and/or modify
4
 
# it under the terms of the GNU General Public License version 2 as published
5
 
# by the Free Software Foundation.
6
 
#
7
 
# This program is distributed in the hope that it will be useful,
8
 
# but WITHOUT ANY WARRANTY; without even the implied warranty of
9
 
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10
 
# GNU General Public License for more details.
11
 
#
12
 
# You should have received a copy of the GNU General Public License
13
 
# along with this program; if not, write to the Free Software
14
 
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
15
 
#
16
 
 
17
 
from bzrlib import tests
18
 
 
19
 
from bzrlib.plugins.groupcompress import equivalence_table
20
 
from bzrlib.plugins.groupcompress.tests.test__groupcompress_c import (
21
 
    CompiledGroupCompress
22
 
    )
23
 
 
24
 
 
25
 
class TestEquivalenceTable(tests.TestCase):
26
 
 
27
 
    eq_class = equivalence_table.EquivalenceTable
28
 
 
29
 
    def test_create(self):
30
 
        eq = self.eq_class(['a', 'b'])
31
 
 
32
 
    def test_matching_lines(self):
33
 
        lines = ['a', 'b', 'c', 'b']
34
 
        eq = self.eq_class(lines)
35
 
        self.assertEqual(lines, eq.lines)
36
 
        self.assertEqual({'a': [0], 'b': [1, 3], 'c': [2]},
37
 
                         eq._get_matching_lines())
38
 
 
39
 
    def test_set_right_lines(self):
40
 
        eq = self.eq_class(['a', 'b', 'c', 'b'])
41
 
        eq.set_right_lines(['f', 'b', 'b'])
42
 
        self.assertEqual(None, eq.get_idx_matches(0))
43
 
        self.assertEqual([1, 3], eq.get_idx_matches(1))
44
 
        self.assertEqual([1, 3], eq.get_idx_matches(2))
45
 
 
46
 
    def assertGetLeftMatches(self, expected_left, eq, right):
47
 
        """Assert that we find the right matching lines."""
48
 
        self.assertEqual(expected_left, eq.get_matches(right))
49
 
 
50
 
    def test_get_matching(self):
51
 
        eq = self.eq_class(['a', 'b', 'c', 'b'])
52
 
        self.assertGetLeftMatches([1, 3], eq, 'b')
53
 
        self.assertGetLeftMatches([2], eq, 'c')
54
 
        self.assertGetLeftMatches(None, eq, 'd')
55
 
        self.assertGetLeftMatches([2], eq, 'c')
56
 
 
57
 
    def test_extend_lines(self):
58
 
        eq = self.eq_class(['a', 'b', 'c', 'b'])
59
 
        eq.extend_lines(['d', 'e', 'c'], [True, True, True])
60
 
        self.assertEqual(['a', 'b', 'c', 'b', 'd', 'e', 'c'],
61
 
                         eq.lines)
62
 
        self.assertEqual({'a': [0], 'b': [1, 3],
63
 
                          'c': [2, 6], 'd': [4],
64
 
                          'e': [5]},
65
 
                         eq._get_matching_lines())
66
 
 
67
 
    def test_extend_lines_ignored(self):
68
 
        eq = self.eq_class(['a', 'b', 'c', 'b'])
69
 
        eq.extend_lines(['d', 'e', 'c'], [False, False, True])
70
 
        self.assertEqual(['a', 'b', 'c', 'b', 'd', 'e', 'c'],
71
 
                         eq.lines)
72
 
        self.assertEqual({'a': [0], 'b': [1, 3],
73
 
                          'c': [2, 6], 'd': None, 'e': None},
74
 
                         eq._get_matching_lines())
75
 
 
76
 
    def test_abusive(self):
77
 
        eq = self.eq_class(['a']*1000)
78
 
        self.assertEqual({'a': range(1000)}, eq._get_matching_lines())
79
 
        self.assertGetLeftMatches(range(1000), eq, 'a')
80
 
 
81
 
 
82
 
class TestCompiledEquivalenceTable(TestEquivalenceTable):
83
 
 
84
 
    _tests_need_features = [CompiledGroupCompress]
85
 
 
86
 
    def setUp(self):
87
 
        super(TestCompiledEquivalenceTable, self).setUp()
88
 
        from bzrlib.plugins.groupcompress import _groupcompress_c
89
 
        self.eq_class = _groupcompress_c.EquivalenceTable