LinearHashTableTest
extends UnitTest
in package
Used to test that the LinearHashTable class properly stores key value pairs, handles insert, deletes, retrievals okay.
Tags
Table of Contents
- case_name = "TestCase"
- The suffix that all TestCase methods need to have to be called by run()
- TEST_DIR = '/test_files/linear_test'
- Prefix of folders for linear hashing test
- $current_method : string
- Contains the value of the next test case to be run can be used by setUp
- $table_dirs : array<string|int, mixed>
- Maintains all linear hash tables created for testing
- $test_case_results : array<string|int, mixed>
- Used to store the results for each test sub case
- $test_objects : array<string|int, mixed>
- Used to hold objects to be used in tests
- __construct() : mixed
- Constructor should be overridden to do any set up that occurs before and test cases
- assertEqual() : mixed
- Checks that $x and $y are the same, the result of the test is added to $this->test_case_results
- assertFalse() : mixed
- Checks that $x can coerced to false, the result of the test is added to $this->test_case_results
- assertNotEqual() : mixed
- Checks that $x and $y are not the same, the result of the test is added to $this->test_case_results
- assertTrue() : mixed
- Checks that $x can coerced to true, the result of the test is added to $this->test_case_results
- createTable() : mixed
- Used to create a single hash table in the folder TEST_DIR . $max_items_per_file which allows at most $max_items_per_file to be stored in a bucket
- deleteHashKeyTestCase() : mixed
- Tests whether key value pairs can be deleted from the linear hash table without destroying non-deleted data. This test is for pre-hashed keys
- deleteKeyTestCase() : mixed
- Tests whether key value pairs can be deleted from the linear hash table without destroying non-deleted data. This test is for non-pre-hashed keys
- insertHashKeyLookupTestCase() : mixed
- Tests whether key value pairs inserted into the linear hash table can subsequently be retrieved. This tests the hashed key case
- insertKeyLookupTestCase() : mixed
- Tests whether key value pairs inserted into the linear hash table can subsequently be retrieved. This tests the non-hashed key case
- packUnpackFormatTestCase() : mixed
- This tests that packed records can be successfully unpacked after being put into the linear hash table and retrieved.
- run() : array<string|int, mixed>
- Execute each of the test cases of this unit test and return the results
- setUp() : mixed
- Sets up an array to keep track of what linear hash tables we've made so that we can delete them when done a test.
- tearDown() : mixed
- Deletes all the Linear Hash tables in $this->table_dirs
Constants
case_name
The suffix that all TestCase methods need to have to be called by run()
public
mixed
case_name
= "TestCase"
TEST_DIR
Prefix of folders for linear hashing test
public
mixed
TEST_DIR
= '/test_files/linear_test'
Properties
$current_method
Contains the value of the next test case to be run can be used by setUp
public
string
$current_method
$table_dirs
Maintains all linear hash tables created for testing
public
array<string|int, mixed>
$table_dirs
$test_case_results
Used to store the results for each test sub case
public
array<string|int, mixed>
$test_case_results
$test_objects
Used to hold objects to be used in tests
public
array<string|int, mixed>
$test_objects
Methods
__construct()
Constructor should be overridden to do any set up that occurs before and test cases
public
__construct() : mixed
Return values
mixed —assertEqual()
Checks that $x and $y are the same, the result of the test is added to $this->test_case_results
public
assertEqual(mixed $x, mixed $y[, string $description = "" ]) : mixed
Parameters
- $x : mixed
-
a first item to compare
- $y : mixed
-
a second item to compare
- $description : string = ""
-
information about this test subcase
Return values
mixed —assertFalse()
Checks that $x can coerced to false, the result of the test is added to $this->test_case_results
public
assertFalse(mixed $x[, string $description = "" ]) : mixed
Parameters
- $x : mixed
-
item to check
- $description : string = ""
-
information about this test subcase
Return values
mixed —assertNotEqual()
Checks that $x and $y are not the same, the result of the test is added to $this->test_case_results
public
assertNotEqual(mixed $x, mixed $y[, string $description = "" ]) : mixed
Parameters
- $x : mixed
-
a first item to compare
- $y : mixed
-
a second item to compare
- $description : string = ""
-
information about this test subcase
Return values
mixed —assertTrue()
Checks that $x can coerced to true, the result of the test is added to $this->test_case_results
public
assertTrue(mixed $x[, string $description = "" ]) : mixed
Parameters
- $x : mixed
-
item to check
- $description : string = ""
-
information about this test subcase
Return values
mixed —createTable()
Used to create a single hash table in the folder TEST_DIR . $max_items_per_file which allows at most $max_items_per_file to be stored in a bucket
public
createTable(int $max_items_per_file[, mixed $format = ["PRIMARY KEY" => "KEY", "VALUE" => "BLOB"] ]) : mixed
Parameters
- $max_items_per_file : int
-
number of items allowed to be stored in a bucket
- $format : mixed = ["PRIMARY KEY" => "KEY", "VALUE" => "BLOB"]
Return values
mixed —deleteHashKeyTestCase()
Tests whether key value pairs can be deleted from the linear hash table without destroying non-deleted data. This test is for pre-hashed keys
public
deleteHashKeyTestCase() : mixed
Return values
mixed —deleteKeyTestCase()
Tests whether key value pairs can be deleted from the linear hash table without destroying non-deleted data. This test is for non-pre-hashed keys
public
deleteKeyTestCase() : mixed
Return values
mixed —insertHashKeyLookupTestCase()
Tests whether key value pairs inserted into the linear hash table can subsequently be retrieved. This tests the hashed key case
public
insertHashKeyLookupTestCase() : mixed
Return values
mixed —insertKeyLookupTestCase()
Tests whether key value pairs inserted into the linear hash table can subsequently be retrieved. This tests the non-hashed key case
public
insertKeyLookupTestCase() : mixed
Return values
mixed —packUnpackFormatTestCase()
This tests that packed records can be successfully unpacked after being put into the linear hash table and retrieved.
public
packUnpackFormatTestCase() : mixed
This tests the LinearHashTable use-case for storing ETag data
Return values
mixed —run()
Execute each of the test cases of this unit test and return the results
public
run([string $method = null ]) : array<string|int, mixed>
Parameters
- $method : string = null
-
if not null then the method to run, else run all methods
Return values
array<string|int, mixed> —test case results
setUp()
Sets up an array to keep track of what linear hash tables we've made so that we can delete them when done a test.
public
setUp() : mixed
Return values
mixed —tearDown()
Deletes all the Linear Hash tables in $this->table_dirs
public
tearDown() : mixed