\seekquarry\yioop\testsHashTableTest

Used to test that the HashTable class properly stores key value pairs, handles insert, deletes, collisions okay. It should also detect when table is full

Summary

Methods
Properties
Constants
__construct()
run()
assertTrue()
assertFalse()
assertEqual()
assertNotEqual()
setUp()
tearDown()
insertLookupTestCase()
insertDeleteLookupTestCase()
completeFillTestCase()
reinsertCollisionAndIndexTestCase()
timingTestCase()
$test_case_results
$test_objects
case_name
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()

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() 

We'll use two different tables one more representative of how the table is going to be used by the web_queue_bundle, the other small enough that we can manually figure out what the result should be

tearDown()

tearDown() 

Since a HashTable is a PersistentStructure it periodically saves itself to a file. To clean up we delete the files that might be created

insertLookupTestCase()

insertLookupTestCase() 

Check if for the big hash table we insert something then later look it up, that we in fact find it. Moreover, the value we associated with the insert key is as expected

insertDeleteLookupTestCase()

insertDeleteLookupTestCase() 

Checks insert an item, delete that item, then look it up. Make sure we don't find it after deletion.

completeFillTestCase()

completeFillTestCase() 

Completety fill table. Next insert should fail. Then delete all the items. Then check that we can't find any of them

reinsertCollisionAndIndexTestCase()

reinsertCollisionAndIndexTestCase() 

First check that inserting an item twice does not change its index in the table. Then inserts an item which should hash to the same value. So there is a collision which is resolved by linear offset. Check lookup of new item succeeds.Then delete first insert, check lookup of second insert still works. Check delete of second item, reinsert of first item and lookup. Index should change

timingTestCase()

timingTestCase() 

Test how fast insertion and deletions can be done