~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_osutils.py

  • Committer: Robert Collins
  • Date: 2006-06-15 20:49:03 UTC
  • mto: (1780.1.1 integration)
  • mto: This revision was merged to the branch mainline in revision 1781.
  • Revision ID: robertc@robertcollins.net-20060615204903-994181bbe8cd4ec1
Add path_prefix_key and compare_paths_prefix_order utility functions.

Show diffs side-by-side

added added

removed removed

Lines of Context:
266
266
        self.assertEqual(expected_dirblocks[1:],
267
267
            [[line[0:3] for line in block] for block in result])
268
268
 
 
269
    def assertPathCompare(self, path_less, path_greater):
 
270
        """check that path_less and path_greater compare correctly."""
 
271
        self.assertEqual(0, osutils.compare_paths_prefix_order(
 
272
            path_less, path_less))
 
273
        self.assertEqual(0, osutils.compare_paths_prefix_order(
 
274
            path_greater, path_greater))
 
275
        self.assertEqual(-1, osutils.compare_paths_prefix_order(
 
276
            path_less, path_greater))
 
277
        self.assertEqual(1, osutils.compare_paths_prefix_order(
 
278
            path_greater, path_less))
 
279
 
 
280
    def test_compare_paths_prefix_order(self):
 
281
        # root before all else
 
282
        self.assertPathCompare("/", "/a")
 
283
        # alpha within a dir
 
284
        self.assertPathCompare("/a", "/b")
 
285
        self.assertPathCompare("/b", "/z")
 
286
        # high dirs before lower.
 
287
        self.assertPathCompare("/z", "/a/a")
 
288
        # lexical betwen dirs of the same height
 
289
        self.assertPathCompare("/a/z", "/z/z")
 
290
        self.assertPathCompare("/a/c/z", "/a/d/e")
 
291
 
 
292
        # this should also be consistent for no leading / paths
 
293
        # root before all else
 
294
        self.assertPathCompare("", "a")
 
295
        # alpha within a dir
 
296
        self.assertPathCompare("a", "b")
 
297
        self.assertPathCompare("b", "z")
 
298
        # high dirs before lower.
 
299
        self.assertPathCompare("z", "a/a")
 
300
        # lexical betwen dirs of the same height
 
301
        self.assertPathCompare("a/z", "z/z")
 
302
        self.assertPathCompare("a/c/z", "a/d/e")
 
303