1
# Copyright (C) 2006 Canonical Ltd
3
# This program is free software; you can redistribute it and/or modify
4
# it under the terms of the GNU General Public License as published by
5
# the Free Software Foundation; either version 2 of the License, or
6
# (at your option) any later version.
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
# GNU General Public License for more details.
13
# You should have received a copy of the GNU General Public License
14
# along with this program; if not, write to the Free Software
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
from bzrlib.tests import TestCaseInTempDir
18
from bzrlib.win32utils import glob_expand
21
class Win32UtilsGlobExpand(TestCaseInTempDir):
23
def test_empty_tree(self):
26
testset = [[['a'], ['a']],
29
[['a', 'a'], ['a', 'a']]]
31
self._run_testset(testset)
34
self.build_tree(['a', 'a1', 'a2', 'a11', 'a.1',
35
'b', 'b1', 'b2', 'b3',
37
'd/', 'd/d1', 'd/d2'])
39
testset = [# no wildcards
41
[['a', 'a' ], ['a', 'a']],
49
[['a*'], ['a', 'a1', 'a2', 'a11', 'a.1']],
50
[['?'], ['a', 'b', 'c', 'd']],
51
[['a?'], ['a1', 'a2']],
52
[['a??'], ['a11', 'a.1']],
53
[['b[1-2]'], ['b1', 'b2']],
54
[['A?'], ['a1', 'a2']],
56
[['d/*'], ['d\\d1', 'd\\d2']],
57
[['d\\*'], ['d\\d1', 'd\\d2']],
58
[['?\\*'], ['c\\c1', 'c\\c2', 'd\\d1', 'd\\d2']],
59
[['*\\*'], ['c\\c1', 'c\\c2', 'd\\d1', 'd\\d2']],
60
[['*/'], ['c\\', 'd\\']],
61
[['*\\'], ['c\\', 'd\\']]]
63
self._run_testset(testset)
65
def _run_testset(self, testset):
66
for pattern, expected in testset:
67
result = glob_expand(pattern)
70
self.assertEqual(expected, result, 'pattern %s' % pattern)