28 lines
765 B
Python
28 lines
765 B
Python
from undo_doodle import start_stroke, extend_stroke, push_history, undo, MAX_HISTORY
|
|
|
|
|
|
def test_strich_erzeugt_neuen_zustand():
|
|
s0 = []
|
|
s1 = start_stroke(s0, (1, 1))
|
|
s2 = extend_stroke(s1, (2, 2))
|
|
|
|
assert s0 == [] # alter Zustand unverändert
|
|
assert s1 == [[(1, 1)]] # s1 auch unverändert nach extend
|
|
assert s2 == [[(1, 1), (2, 2)]]
|
|
|
|
|
|
def test_undo_stellt_vorzustand_wieder_her():
|
|
s0 = []
|
|
history = push_history([], s0)
|
|
s1 = start_stroke(s0, (1, 1))
|
|
|
|
state, history = undo(s1, history)
|
|
assert state == []
|
|
assert history == []
|
|
|
|
|
|
def test_historie_ist_begrenzt():
|
|
history = []
|
|
for i in range(10):
|
|
history = push_history(history, [i])
|
|
assert len(history) == MAX_HISTORY |