| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
from pyocd.utility.strings import ( |
| 18 |
uniquify_name, |
| 19 |
) |
| 20 |
|
| 21 |
class TestUniquifyName: |
| 22 |
def test_empty_with_no_others(self): |
| 23 |
assert uniquify_name('', []) == '' |
| 24 |
|
| 25 |
def test_empty_with_others(self): |
| 26 |
assert uniquify_name('', ['bar', 'buz']) == '' |
| 27 |
|
| 28 |
def test_empty_with_another_empty(self): |
| 29 |
assert uniquify_name('', ['bar', 'buz', '']) == '_1' |
| 30 |
|
| 31 |
def test_no_others(self): |
| 32 |
assert uniquify_name('foo', []) == 'foo' |
| 33 |
|
| 34 |
def test_already_unique(self): |
| 35 |
assert uniquify_name('foo', ['bar']) == 'foo' |
| 36 |
|
| 37 |
def test_no_trailing_int(self): |
| 38 |
assert uniquify_name('foo', ['foo']) == 'foo_1' |
| 39 |
|
| 40 |
def test_1_trailing_int(self): |
| 41 |
assert uniquify_name('foo1', ['foo1']) == 'foo2' |
| 42 |
|
| 43 |
def test_multiple_trailing_ints(self): |
| 44 |
assert uniquify_name('foo1', ['foo1', 'foo2']) == 'foo3' |
| 45 |
|
| 46 |
def test_name_has_int(self): |
| 47 |
assert uniquify_name('foo2', ['foo2', 'bar', 'foo3']) == 'foo4' |
| 48 |
|
| 49 |
def test_multiple_ints_in_name(self): |
| 50 |
assert uniquify_name('baz 2 monkey-3', ['fun', 'baz 2 monkey-3']) == 'baz 2 monkey-4' |
| 51 |
|