\seekquarry\yioop\testsBTreeTest

Yioop B-tree Unit Class

Used to test insert, lookup, and deletion of key-value pairs on the B-Tree.

Summary

Methods
Properties
Constants
__construct()
run()
assertTrue()
assertFalse()
assertEqual()
assertNotEqual()
setUp()
tearDown()
emptyBTreeNoSaveTestCase()
insertLookupTestCase()
deleteFromLeafNodeTestCase()
deleteFromInternalNodeTestCase()
deleteLookupTestCase()
$test_case_results
$test_objects
case_name
NUM_VALS
DEGREE
TEST_DIR
No protected methods found
No protected properties found
N/A
No private methods found
No private properties found
N/A

Constants

case_name

case_name

The suffix that all TestCase methods need to have to be called by run()

NUM_VALS

NUM_VALS

Number of key value pairs to insert for unit tests

DEGREE

DEGREE

Minimum degree of BTree

TEST_DIR

TEST_DIR

Test directory to hold btree used for these unit tests

Properties

$test_case_results

$test_case_results : 

Used to store the results for each test sub case

Type

$test_objects

$test_objects : array

Used to hold objects to be used in tests

Type

array

Methods

__construct()

__construct() 

Contructor should be overriden to do any set up that occurs before and test cases

run()

run() : array

Execute each of the test cases of this unit test and return the results

Returns

array —

test case results

assertTrue()

assertTrue(mixed  $x, string  $description = "") 

Checks that $x can coerced to true, the result of the test is added to $this->test_case_results

Parameters

mixed $x

item to check

string $description

information about this test subcase

assertFalse()

assertFalse(mixed  $x, string  $description = "") 

Checks that $x can coerced to false, the result of the test is added to $this->test_case_results

Parameters

mixed $x

item to check

string $description

information about this test subcase

assertEqual()

assertEqual(mixed  $x, mixed  $y, string  $description = "") 

Checks that $x and $y are the same, the result of the test is added to $this->test_case_results

Parameters

mixed $x

a first item to compare

mixed $y

a second item to compare

string $description

information about this test subcase

assertNotEqual()

assertNotEqual(mixed  $x, mixed  $y, string  $description = "") 

Checks that $x and $y are not the same, the result of the test is added to $this->test_case_results

Parameters

mixed $x

a first item to compare

mixed $y

a second item to compare

string $description

information about this test subcase

setUp()

setUp() 

Minimum degree is set to 2 and the number of key-value pairs is set to 25

tearDown()

tearDown() 

Delete the B-Tree files created during the test

emptyBTreeNoSaveTestCase()

emptyBTreeNoSaveTestCase() 

Test to check that an empty B-Tree is not saved to disk.

A B-Tree object is created. The test directory is checked for B-Tree files. A value is inserted, the test directory is again checked. The inserted value is removed and the test directory is again checked for B-Tree files.

insertLookupTestCase()

insertLookupTestCase() 

Test to check insertion and lookup in a B-Tree Key-value pairs are inserted in the B-Tree and then looked up using keys.

deleteFromLeafNodeTestCase()

deleteFromLeafNodeTestCase() 

Test to check that a key is deleted successfully from a leaf node Key-value pairs are inserted in the B-Tree. key-value pairs present in leaf nodes are then deleted from the B-Tree. The deleted key-value pairs are looked up to check if they were removed successfully.

deleteFromInternalNodeTestCase()

deleteFromInternalNodeTestCase() 

Test to check that a key is deleted successfully from an internal node Key-value pairs are first added to the B-Tree. Key-value pairs are then deleted successively from the root node. The deleted key-value pairs are then looked up to check if they were successfully

deleteLookupTestCase()

deleteLookupTestCase() 

Function to check that keys are successfully deleted from the B-Tree Random key-value pairs are firs inserted in the B-Tree. From the inserted key-value pairs, key-value pairs are randomly selected and deleted from the B-Tree. The deleted key-value pairs are then looked up using their keys to check if they were successfully deleted.