def test_hash_str(): buf = ('garbage0' 'hello capnproto\0') # string p = ptr.new_list(0, ptr.LIST_SIZE_8, 16) b = Segment(buf) h = b.hash_str(p, 0, 0, additional_size=-1) assert h == hash("hello capnproto") h = b.hash_str(p, 0, 0, additional_size=0) assert h == hash("hello capnproto\0")
def test_hash_str_exception(): buf = b'' p = ptr.new_struct(0, 1, 1) # this is the wrong type of pointer bb = Segment(buf) with pytest.raises(AssertionError): bb.hash_str(p, 0, 0, 0)