def test_peek_next_ubyte_with_negative(self): x = ByteScanner("Hi \n") x.read_ubyte() x.read_ubyte() self.assertEquals(x.peek_next_ubyte(-1), "i") self.assertEquals(x.peek_next_ubyte(-2), "H") self.assertEquals(x.peek_next_ubyte(-3, none_if_bad_index=True), None) self.assertRaises(IndexError, x.peek_next_ubyte, (-3))
def test_peek_next_ubyte(self): x = ByteScanner("Hi \n") x.read_ubyte() x.read_ubyte() self.assertEquals(x.peek_next_ubyte(), " ") self.assertEquals(x.peek_next_ubyte(1), "\n") self.assertEquals(x.peek_next_ubyte(2, none_if_bad_index=True), None) self.assertRaises(IndexError, x.peek_next_ubyte, 2)