1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
# gemato: Utility function tests
# (c) 2017-2022 Michał Górny
# SPDX-License-Identifier: GPL-2.0-or-later
import pytest
from gemato.util import (
path_starts_with,
path_inside_dir,
)
@pytest.mark.parametrize(
'p1,p2,expected',
[("", "", True),
("foo", "", True),
("foo/", "", True),
("foo/bar", "", True),
("bar", "", True),
("bar/", "", True),
("bar/bar", "", True),
("foo", "foo", True),
("foo/", "foo", True),
("foo/bar", "foo", True),
("bar", "foo", False),
("fooo", "foo", False),
("foo.", "foo", False),
("foo", "foo/", True),
("foo/", "foo/", True),
("foo/bar", "foo/bar/", True),
])
def test_path_starts_with(p1, p2, expected):
assert path_starts_with(p1, p2) is expected
@pytest.mark.parametrize(
'p1,p2,expected',
[("", "", False),
("foo", "", True),
("foo/", "", True),
("foo/bar", "", True),
("bar", "", True),
("bar/", "", True),
("bar/bar", "", True),
("foo", "foo", False),
("foo/", "foo", False),
("foo/bar", "foo", True),
("bar", "foo", False),
("fooo", "foo", False),
("foo.", "foo", False),
("foo", "foo/", False),
("foo/", "foo/", False),
("foo/bar", "foo/bar/", False),
])
def test_path_inside_dir(p1, p2, expected):
assert path_inside_dir(p1, p2) is expected
|