122 |
except BlockId.WrongIdException: return 0 |
except BlockId.WrongIdException: return 0 |
123 |
else: return 1 |
else: return 1 |
124 |
|
|
125 |
|
def check3(id, data): |
126 |
|
s = java.io.ByteArrayInputStream(data) |
127 |
|
s2 = id.getCheckedInputStream(s) |
128 |
|
|
129 |
|
try: s2.close() |
130 |
|
except BlockId.WrongIdException: return 0 |
131 |
|
else: return 1 |
132 |
|
|
133 |
|
|
134 |
def testCheck(): |
def testCheck(): |
135 |
id_1 = BlockId(uri_1) |
id_1 = BlockId(uri_1) |
147 |
|
|
148 |
assert check2(id_3, data_3) |
assert check2(id_3, data_3) |
149 |
assert (not check2(id_1, data_3)) and (not check2(id_2, data_3)) |
assert (not check2(id_1, data_3)) and (not check2(id_2, data_3)) |
150 |
|
|
151 |
|
assert check3(id_2, data_2) |
152 |
|
assert (not check3(id_1, data_2)) and (not check3(id_3, data_2)) |
153 |
|
|
154 |
|
assert check3(id_3, data_3) |
155 |
|
assert (not check3(id_1, data_3)) and (not check3(id_2, data_3)) |