Skip to content

Commit fbaa936

Browse files
committed
Fix bug in ReplayBuffer.empty, add regression test.
1 parent cecc47a commit fbaa936

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

sc2reader/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ def left(self):
130130

131131
@property
132132
def empty(self):
133-
return self.tell() != self.length
133+
return self.tell() == self.length
134134

135135
@property
136136
def cursor(self):

tests/tests.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@ class ReplayBufferTests(unittest.TestCase):
4040
"""All methods should throw EOFError when they hit the end of the
4141
wrapped buffer."""
4242

43+
def test_empty(self):
44+
buffer = sc2reader.utils.ReplayBuffer("T35T")
45+
self.assertEquals(buffer.empty, False)
46+
buffer.read(4)
47+
self.assertEquals(buffer.empty, True)
48+
4349
def test_seek(self):
4450
"""Should preserve the bitshift unless seeking back to beginning of
4551
the file. Seeking to position 0 leaves no bits behind to shift.

0 commit comments

Comments
 (0)