14 lines
407 B
Python
14 lines
407 B
Python
from invert import invert
|
|
def test_empty():
|
|
assert invert([]) == {}
|
|
def test_simple():
|
|
invert(["three","two","one"]) == {"three": 0, "two":1, "one":2}
|
|
def test_duplicate():
|
|
assert invert(["bob","bob"]) == None
|
|
def test_numeric():
|
|
assert invert(range(0,6)) == { 0:0, 1:1, 2:2, 3:3, 4:4, 5:5 }
|
|
def test_invert():
|
|
L=[-8,"pineapple",3]
|
|
D=invert(L)
|
|
assert [ L[D[j]] for j in L ] == L
|