master > master: code - assertions korrigiert (index == -1 ist in Ordnung, wenn erwartet)

This commit is contained in:
RD
2021-10-25 11:33:22 +02:00
parent 965cd48ae6
commit 82962e376d
5 changed files with 24 additions and 12 deletions

View File

@@ -28,8 +28,11 @@ def preChecks(L: List[int], **_):
return;
def postChecks(L: List[int], x: int, index: int, **_):
value = L[index] if index >= 0 else None;
assert value == x, 'Der Algorithmus hat versagt.';
if x in L:
assert index >= 0, 'Der Algorithmus sollte nicht -1 zurückgeben.';
assert L[index] == x, 'Der Algorithmus hat den falschen Index bestimmt.';
else:
assert index == -1, 'Der Algorithmus sollte -1 zurückgeben.';
return;
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~