MCPcopy Create free account
hub / github.com/apple/foundationdb / vector_test

Function vector_test

layers/containers/vector.py:396–514  ·  view source on GitHub ↗
(tr)

Source from the content-addressed store, hash-verified

394# caution: modifies the database!
395@fdb.transactional
396def vector_test(tr):
397 vector = Vector(Subspace(('test_vector',)), 0)
398
399 with vector.use_transaction(tr):
400 print 'Clearing any previous values in the vector'
401 vector.clear()
402
403 print '\nMODIFIERS'
404
405 # Set + Push
406 vector[0] = 1
407 vector[1] = 2
408 vector.push(3)
409 _print_vector(vector, tr)
410
411 # Swap
412 vector.swap(0, 2)
413 _print_vector(vector, tr)
414
415 # Pop
416 print 'Popped:', vector.pop()
417 _print_vector(vector, tr)
418
419 # Clear
420 vector.clear()
421
422 print 'Pop empty:', vector.pop()
423 _print_vector(vector, tr)
424
425 vector.push('Foo')
426 print 'Pop size 1:', vector.pop()
427 _print_vector(vector, tr)
428
429 print '\nCAPACITY OPERATIONS'
430
431 # Capacity
432 print 'Size:', vector.size()
433 print 'Empty:', vector.empty()
434
435 print 'Resizing to length 5'
436 vector.resize(5)
437 _print_vector(vector, tr)
438 print 'Size:', vector.size()
439
440 print 'Setting values'
441 vector[0] = 'The'
442 vector[1] = 'Quick'
443 vector[2] = 'Brown'
444 vector[3] = 'Fox'
445 vector[4] = 'Jumps'
446 vector[5] = 'Over'
447 _print_vector(vector, tr)
448
449 print '\nFRONT'
450 print vector.front()
451
452 print '\nBACK'
453 print vector.back()

Callers

nothing calls this directly

Calls 13

use_transactionMethod · 0.95
clearMethod · 0.95
pushMethod · 0.95
swapMethod · 0.95
popMethod · 0.95
sizeMethod · 0.95
emptyMethod · 0.95
resizeMethod · 0.95
frontMethod · 0.95
backMethod · 0.95
VectorClass · 0.85
_print_vectorFunction · 0.85

Tested by

no test coverage detected