Skip to content

Commit 57bfd6e

Browse files
committed
rpc_next_message off-by-one, fixes #9
1 parent c24bce5 commit 57bfd6e

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

python/makerbotapi/makerbotapi.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ def _rpc_get_next_message(self, buffer):
475475
parenindex -= 1
476476
if parenindex == 0:
477477
message = buffer[0:pos]
478-
return message, buffer[pos + 1:]
478+
return message, buffer[pos:]
479479
return None, buffer
480480

481481
def _handle_response(self, response):

python/makerbotapi/makerbotapi_test.py

+10
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,16 @@ def test__get_raw_camera_image_data(self):
164164
tpl = self.makerbot._get_raw_camera_image_data()
165165
self.assertEquals(tpl[:4], (153616, 320, 240, 1))
166166

167+
def test__rpc_get_next_message(self):
168+
self.assertEqual(
169+
self.makerbot._rpc_get_next_message("{foo}"), ("{foo}", ""),)
170+
self.assertEqual(
171+
self.makerbot._rpc_get_next_message("{foo}{bar}"), ("{foo}", "{bar}"),)
172+
self.assertEqual(self.makerbot._rpc_get_next_message(
173+
"{foo}{bar{baz}}"), ("{foo}", "{bar{baz}}"),)
174+
self.assertEqual(self.makerbot._rpc_get_next_message(
175+
"{foo{baz}}{bar{baz}}"), ("{foo{baz}}", "{bar{baz}}"),)
176+
167177

168178
class ModuleTest(unittest.TestCase):
169179

0 commit comments

Comments
 (0)