CS2613/tests/Final/Q2 Python/test_invert.py
2022-12-20 21:49:28 -04:00

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