~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_tree.py

  • Committer: John Arbash Meinel
  • Date: 2008-08-01 17:24:24 UTC
  • mto: This revision was merged to the branch mainline in revision 3600.
  • Revision ID: john@arbash-meinel.com-20080801172424-rwe2i959lhuwe4jt
Found some problems in _path_key, and made sure to have proper testing of _cmp_paths_by_dirblock

Show diffs side-by-side

added added

removed removed

Lines of Context:
386
386
        self.assertWalkerNext(u'c/d', 'b-id', True, [u'c/d', u'b'], iterator)
387
387
        self.assertWalkerNext(u'c/e', 'a-id', True, [u'a', u'a'], iterator)
388
388
        self.assertRaises(StopIteration, iterator.next)
 
389
 
 
390
    def assertCmpByDirblock(self, cmp_val, path1, path2):
 
391
        self.assertEqual(cmp_val,
 
392
            _mod_tree.MultiWalker._cmp_path_by_dirblock(path1, path2))
 
393
 
 
394
    def test__cmp_path_by_dirblock(self):
 
395
        # We only support Unicode strings at this point
 
396
        self.assertRaises(TypeError,
 
397
            _mod_tree.MultiWalker._cmp_path_by_dirblock, '', 'b')
 
398
        self.assertCmpByDirblock(0, u'', u'')
 
399
        self.assertCmpByDirblock(0, u'a', u'a')
 
400
        self.assertCmpByDirblock(0, u'a/b', u'a/b')
 
401
        self.assertCmpByDirblock(0, u'a/b/c', u'a/b/c')
 
402
        self.assertCmpByDirblock(1, u'a-a', u'a')
 
403
        self.assertCmpByDirblock(-1, u'a-a', u'a/a')
 
404
        self.assertCmpByDirblock(-1, u'a=a', u'a/a')
 
405
        self.assertCmpByDirblock(1, u'a-a/a', u'a/a')
 
406
        self.assertCmpByDirblock(1, u'a=a/a', u'a/a')
 
407
        self.assertCmpByDirblock(1, u'a-a/a', u'a/a/a')
 
408
        self.assertCmpByDirblock(1, u'a=a/a', u'a/a/a')
 
409
        self.assertCmpByDirblock(1, u'a-a/a/a', u'a/a/a')
 
410
        self.assertCmpByDirblock(1, u'a=a/a/a', u'a/a/a')
 
411
 
 
412
    def assertPathKey(self, expected, path):
 
413
        self.assertEqual(expected, _mod_tree.MultiWalker._path_key(path))
 
414
 
 
415
    def test__path_key(self):
 
416
        self.assertPathKey(([u''], u''), u'')
 
417
        self.assertPathKey(([u''], u'a'), u'a')
 
418
        self.assertPathKey(([u'a'], u'b'), u'a/b')
 
419
        self.assertPathKey(([u'a', u'b'], u'c'), u'a/b/c')