@@ -31,6 +31,13 @@ def test_empty_history_has_no_length() -> None:
31
31
assert len (History ()) == 0
32
32
33
33
34
+ ##############################################################################
35
+ def test_empty_history_has_nowhere_to_go () -> None :
36
+ """An empty history should not be able to move."""
37
+ assert History ().can_go_backward is False
38
+ assert History ().can_go_forward is False
39
+
40
+
34
41
##############################################################################
35
42
@mark .parametrize ("initial" , ([1 ], [1 , 2 ], range (100 )))
36
43
def test_pre_populate_history_has_location (initial : Sequence [int ]) -> None :
@@ -105,10 +112,13 @@ def test_backward() -> None:
105
112
"""We should be able to move backward through history until we can't."""
106
113
history = History [int ]([1 , 2 , 3 ])
107
114
assert history .current_location == 2
115
+ assert history .can_go_backward is True
108
116
assert history .backward () is True
109
117
assert history .current_location == 1
118
+ assert history .can_go_backward is True
110
119
assert history .backward () is True
111
120
assert history .current_location == 0
121
+ assert history .can_go_backward is False
112
122
assert history .backward () is False
113
123
assert history .current_location == 0
114
124
@@ -129,11 +139,15 @@ def test_forward() -> None:
129
139
assert history .backward () is True
130
140
assert history .backward () is True
131
141
assert history .backward () is False
142
+ assert history .can_go_backward is False
132
143
assert history .current_location == 0
144
+ assert history .can_go_forward is True
133
145
assert history .forward () is True
134
146
assert history .current_location == 1
147
+ assert history .can_go_forward is True
135
148
assert history .forward () is True
136
149
assert history .current_location == 2
150
+ assert history .can_go_forward is False
137
151
assert history .forward () is False
138
152
assert history .current_location == 2
139
153
0 commit comments