Пример #1
0
    def test_search(self):
        btree = BTree(
            values      = [ 1, 2, 8, 11, 12 ],
            node_size   = 2
        )
        search = btree.search(
            value   = 8
        )
        self.assertTrue( search['found'] )
        self.assertEqual( search['value'], 8 )

        search2 = btree.search( 
            value = 9
        )
        self.assertFalse( search2['found'] )
        self.assertEqual( search2['value'], None )
Пример #2
0
import argparse
from pprint import pprint
from lib.BTree import BTree


if __name__ == "__main__":
    parser = argparse.ArgumentParser(description='Test the BTree package')
    parser.add_argument('--values', dest = 'values' )
    parser.add_argument('--debug',  dest = 'debug' )
    parser.add_argument('--order',  dest = 'order' )
    args = parser.parse_args()

    values = [int(x) for x in args.values.split(',')]
    if 'debug' in args:
        debug_arg = args.debug
    else:
        debug_arg = 0

    if 'order' in args:
        node_size = int(args.order)
    else:
        node_size = 5
    btree = BTree( 
        values      = values, 
        node_size   = node_size,
        debug       = debug_arg
    )
    print(btree)
    data = btree.introspect()
    pprint(data)