~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_versionedfile.py

  • Committer: Robert Collins
  • Date: 2007-09-10 03:37:19 UTC
  • mto: (2592.3.132 repository)
  • mto: This revision was merged to the branch mainline in revision 2817.
  • Revision ID: robertc@robertcollins.net-20070910033719-nqsmg72617f0tvyo
* The ``VersionedFile`` interface no longer protects against misuse when
  lines that are not lines, or are not strings are supplied. This saves
  nearly 30% of the minimum cost to store a version of a file.
  (Robert Collins)

Show diffs side-by-side

added added

removed removed

Lines of Context:
115
115
        f = self.reopen_file()
116
116
        verify_file(f)
117
117
 
118
 
    def test_add_unicode_content(self):
119
 
        # unicode content is not permitted in versioned files. 
120
 
        # versioned files version sequences of bytes only.
121
 
        vf = self.get_file()
122
 
        self.assertRaises(errors.BzrBadParameterUnicode,
123
 
            vf.add_lines, 'a', [], ['a\n', u'b\n', 'c\n'])
124
 
        self.assertRaises(
125
 
            (errors.BzrBadParameterUnicode, NotImplementedError),
126
 
            vf.add_lines_with_ghosts, 'a', [], ['a\n', u'b\n', 'c\n'])
127
 
 
128
118
    def test_add_follows_left_matching_blocks(self):
129
119
        """If we change left_matching_blocks, delta changes
130
120
 
142
132
                     left_matching_blocks=[(0, 2, 1), (1, 3, 0)])
143
133
        self.assertEqual(['a\n', 'a\n', 'a\n'], vf.get_lines('3'))
144
134
 
145
 
    def test_inline_newline_throws(self):
146
 
        # \r characters are not permitted in lines being added
147
 
        vf = self.get_file()
148
 
        self.assertRaises(errors.BzrBadParameterContainsNewline, 
149
 
            vf.add_lines, 'a', [], ['a\n\n'])
150
 
        self.assertRaises(
151
 
            (errors.BzrBadParameterContainsNewline, NotImplementedError),
152
 
            vf.add_lines_with_ghosts, 'a', [], ['a\n\n'])
153
 
        # but inline CR's are allowed
154
 
        vf.add_lines('a', [], ['a\r\n'])
155
 
        try:
156
 
            vf.add_lines_with_ghosts('b', [], ['a\r\n'])
157
 
        except NotImplementedError:
158
 
            pass
159
 
 
160
135
    def test_add_reserved(self):
161
136
        vf = self.get_file()
162
137
        self.assertRaises(errors.ReservedId,