MCPcopy Create free account
hub / github.com/ActiveState/code / test

Function test

recipes/Python/492209_dal1py/recipe-492209.py:195–224  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

193################################################################################
194
195def test():
196 from os import urandom
197 from random import randint
198 BLOCKS = DAL1.BLOCKS = 100
199 SIZE = DAL1.SIZE = 100
200 test1 = DAL1()
201 test2 = Test(BLOCKS * SIZE)
202 test1.fail(0.999)
203 for temp in range(BLOCKS / 2):
204 print 'Write:', temp + 1, '/', BLOCKS / 2
205 write = randint(0, (BLOCKS * SIZE) / 2), urandom(randint(1, SIZE * 2))
206 test1.write(*write)
207 test2.write(*write)
208 index = randint((BLOCKS * SIZE) / 2, BLOCKS * SIZE)
209 data = urandom(randint(1, SIZE * 2))
210 write = index - len(data) + 1, data
211 test1.write(*write)
212 test2.write(*write)
213 for temp in range(BLOCKS / 20):
214 print 'Erase:', temp + 1, '/', BLOCKS / 20
215 erase = randint(0, (BLOCKS * SIZE) / 2), randint(1, SIZE * 2)
216 test1.erase(*erase)
217 test2.erase(*erase)
218 index = randint((BLOCKS * SIZE) / 2, BLOCKS * SIZE)
219 size = randint(1, SIZE * 2)
220 erase = index - size + 1, size
221 test1.erase(*erase)
222 test2.erase(*erase)
223 raw_input('Tested To ' + str(test1.read(0, BLOCKS * SIZE) == \
224 test2.read(0, BLOCKS * SIZE)))
225
226################################################################################
227

Callers 1

recipe-492209.pyFile · 0.70

Calls 11

failMethod · 0.95
writeMethod · 0.95
writeMethod · 0.95
eraseMethod · 0.95
eraseMethod · 0.95
readMethod · 0.95
readMethod · 0.95
DAL1Class · 0.85
rangeFunction · 0.85
strFunction · 0.85
TestClass · 0.70

Tested by

no test coverage detected