~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_index.py

  • Committer: Robert Collins
  • Date: 2007-07-13 06:47:07 UTC
  • mto: (2592.5.3 pack-repository)
  • mto: This revision was merged to the branch mainline in revision 2624.
  • Revision ID: robertc@robertcollins.net-20070713064707-c40uq3k00sk68fev
Detect bad reference key values.

Show diffs side-by-side

added added

removed removed

Lines of Context:
51
51
 
52
52
    def test_add_node_bad_key(self):
53
53
        builder = GraphIndexBuilder()
54
 
        self.assertRaises(errors.BadIndexKey, builder.add_node, 'a key',
55
 
            (), 'data')
 
54
        for bad_char in '\t\n\x0b\x0c\r\x00 ':
 
55
            self.assertRaises(errors.BadIndexKey, builder.add_node,
 
56
                'a%skey' % bad_char, (), 'data')
56
57
 
57
58
    def test_add_node_bad_data(self):
58
59
        builder = GraphIndexBuilder()
78
79
        self.assertRaises(errors.BadIndexValue, builder.add_node, 'akey',
79
80
            ([], [], []), 'data aa')
80
81
 
 
82
    def test_add_node_bad_key_in_reference_lists(self):
 
83
        # first list, first key - trivial
 
84
        builder = GraphIndexBuilder(reference_lists=1)
 
85
        self.assertRaises(errors.BadIndexKey, builder.add_node, 'akey',
 
86
            (['a key'], ), 'data aa')
 
87
        # need to check more than the first key in the list
 
88
        self.assertRaises(errors.BadIndexKey, builder.add_node, 'akey',
 
89
            (['agoodkey', 'this is a bad key'], ), 'data aa')
 
90
        # and if there is more than one list it should be getting checked
 
91
        # too
 
92
        builder = GraphIndexBuilder(reference_lists=2)
 
93
        self.assertRaises(errors.BadIndexKey, builder.add_node, 'akey',
 
94
            ([], ['a bad key']), 'data aa')
 
95
 
81
96
 
82
97
class TestGraphIndex(TestCaseWithMemoryTransport):
83
98