Skip to content
This repository has been archived by the owner on Nov 6, 2024. It is now read-only.

Commit

Permalink
Merge pull request #44 from AndrewSisley/testLibraryRefactor
Browse files Browse the repository at this point in the history
Test library refactor
  • Loading branch information
AndrewSisley authored Nov 8, 2020
2 parents 90a3e21 + cb6eaf8 commit 929dc9d
Show file tree
Hide file tree
Showing 88 changed files with 6,753 additions and 331 deletions.
2 changes: 1 addition & 1 deletion cql_storage_types/cql_i16/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ path = "src/i16.rs"
[dev-dependencies]
cql_db = "^0.2.4"
serial_test = "0.3.2"
cql_storage_type_testing_lib = "^0.3.0"
cql_storage_type_testing_lib = { path = "../cql_storage_type_testing_lib" }

[dependencies]
cql_model = "^0.2"
Expand Down
61 changes: 3 additions & 58 deletions cql_storage_types/cql_i16/tests/i16.rs
Original file line number Diff line number Diff line change
@@ -1,64 +1,9 @@
mod constants;

use serial_test::serial;
use std::io::{ Cursor };
use constants::DATABASE_LOCATION;
use cql_i16::{ I16, unpack_stream };
use cql_storage_type_testing_lib::tests;

#[test]
#[serial]
fn _1d_i16_database_allows_for_single_point_read_writes() {
tests::_1d_database_allows_for_single_point_read_writes::<I16>(
DATABASE_LOCATION,
42
);
}

#[test]
#[serial]
fn _4d_i16_database_allows_for_single_point_read_writes() {
tests::_4d_database_allows_for_single_point_read_writes::<I16>(
DATABASE_LOCATION,
5
);
}

#[test]
#[serial]
fn _4d_i16_database_allows_for_single_point_read_writes_given_multiple_values_and_overwrites() {
tests::_4d_database_allows_for_single_point_read_writes_given_multiple_values_and_overwrites::<I16>(
DATABASE_LOCATION,
5,
-20,
0,
30000
);
}

#[test]
#[serial]
fn _1d_i16_database_allows_for_stream_reads() {
tests::_1d_database_allows_for_stream_reads::<I16, &dyn Fn(&mut Cursor<Vec<u8>>, usize, &mut [i16])>(
DATABASE_LOCATION,
42,
16,
80,
&unpack_i16_stream
);
}

#[test]
#[serial]
fn _4d_i16_database_allows_for_stream_reads() {
tests::_4d_database_allows_for_stream_reads::<I16, &dyn Fn(&mut Cursor<Vec<u8>>, usize, &mut [i16])>(
DATABASE_LOCATION,
42,
16,
80,
&unpack_i16_stream
);
}
use cql_i16::{ unpack_stream };
pub mod single_point_read_writes;
pub mod stream_read_point_writes;

fn unpack_i16_stream (stream: &mut Cursor<Vec<u8>>, n_values: usize, result: &mut [i16]) {
unpack_stream(stream, n_values, |idx, value| {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
use serial_test::serial;
use crate::constants::DATABASE_LOCATION;
use cql_i16::{ I16 };
use cql_storage_type_testing_lib::tests::single_point_read_writes::_1d_database::first_index;

#[test]
#[serial]
fn unchecked() {
first_index::unchecked::<I16>(
DATABASE_LOCATION,
42
);
}

#[test]
#[serial]
fn checked() {
first_index::checked::<I16>(
DATABASE_LOCATION,
42
);
}

#[test]
#[serial]
fn unchecked_write_checked_read() {
first_index::unchecked_write_checked_read::<I16>(
DATABASE_LOCATION,
42
);
}

#[test]
#[serial]
fn checked_write_unchecked_read() {
first_index::checked_write_unchecked_read::<I16>(
DATABASE_LOCATION,
42
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
use serial_test::serial;
use crate::constants::DATABASE_LOCATION;
use cql_i16::{ I16 };
use cql_storage_type_testing_lib::tests::single_point_read_writes::_1d_database::last_index;

#[test]
#[serial]
fn unchecked() {
last_index::unchecked::<I16>(
DATABASE_LOCATION,
42
);
}

#[test]
#[serial]
fn checked() {
last_index::checked::<I16>(
DATABASE_LOCATION,
42
);
}

#[test]
#[serial]
fn unchecked_write_checked_read() {
last_index::unchecked_write_checked_read::<I16>(
DATABASE_LOCATION,
42
);
}

#[test]
#[serial]
fn checked_write_unchecked_read() {
last_index::checked_write_unchecked_read::<I16>(
DATABASE_LOCATION,
42
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
use serial_test::serial;
use crate::constants::DATABASE_LOCATION;
use cql_i16::{ I16 };
use cql_storage_type_testing_lib::tests::single_point_read_writes::_1d_database::midpoint;

#[test]
#[serial]
fn unchecked() {
midpoint::unchecked::<I16>(
DATABASE_LOCATION,
42
);
}

#[test]
#[serial]
fn checked() {
midpoint::checked::<I16>(
DATABASE_LOCATION,
42
);
}

#[test]
#[serial]
fn unchecked_write_checked_read() {
midpoint::unchecked_write_checked_read::<I16>(
DATABASE_LOCATION,
42
);
}

#[test]
#[serial]
fn checked_write_unchecked_read() {
midpoint::checked_write_unchecked_read::<I16>(
DATABASE_LOCATION,
42
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
pub mod first_index;
pub mod midpoint;
pub mod last_index;
pub mod with_overwrite;
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
use serial_test::serial;
use crate::constants::DATABASE_LOCATION;
use cql_i16::{ I16 };
use cql_storage_type_testing_lib::tests::single_point_read_writes::_1d_database::with_overwrite::first_index;

#[test]
#[serial]
fn unchecked() {
first_index::unchecked::<I16>(
DATABASE_LOCATION,
42,
15
);
}

#[test]
#[serial]
fn checked() {
first_index::checked::<I16>(
DATABASE_LOCATION,
42,
15
);
}

#[test]
#[serial]
fn unchecked_write_unchecked_overwrite_checked_read() {
first_index::unchecked_write_unchecked_overwrite_checked_read::<I16>(
DATABASE_LOCATION,
42,
15
);
}

#[test]
#[serial]
fn unchecked_write_checked_overwrite_checked_read() {
first_index::unchecked_write_checked_overwrite_checked_read::<I16>(
DATABASE_LOCATION,
42,
15
);
}

#[test]
#[serial]
fn checked_write_unchecked_overwrite_checked_read() {
first_index::checked_write_unchecked_overwrite_checked_read::<I16>(
DATABASE_LOCATION,
42,
15
);
}

#[test]
#[serial]
fn checked_write_unchecked_overwrite_unchecked_read() {
first_index::checked_write_unchecked_overwrite_unchecked_read::<I16>(
DATABASE_LOCATION,
42,
15
);
}

#[test]
#[serial]
fn unchecked_write_checked_overwrite_unchecked_read() {
first_index::unchecked_write_checked_overwrite_unchecked_read::<I16>(
DATABASE_LOCATION,
42,
15
);
}

#[test]
#[serial]
fn checked_write_checked_overwrite_unchecked_read() {
first_index::checked_write_checked_overwrite_unchecked_read::<I16>(
DATABASE_LOCATION,
42,
15
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
use serial_test::serial;
use crate::constants::DATABASE_LOCATION;
use cql_i16::{ I16 };
use cql_storage_type_testing_lib::tests::single_point_read_writes::_1d_database::with_overwrite::last_index;

#[test]
#[serial]
fn unchecked() {
last_index::unchecked::<I16>(
DATABASE_LOCATION,
42,
15
);
}

#[test]
#[serial]
fn checked() {
last_index::checked::<I16>(
DATABASE_LOCATION,
42,
15
);
}

#[test]
#[serial]
fn unchecked_write_unchecked_overwrite_checked_read() {
last_index::unchecked_write_unchecked_overwrite_checked_read::<I16>(
DATABASE_LOCATION,
42,
15
);
}

#[test]
#[serial]
fn unchecked_write_checked_overwrite_checked_read() {
last_index::unchecked_write_checked_overwrite_checked_read::<I16>(
DATABASE_LOCATION,
42,
15
);
}

#[test]
#[serial]
fn checked_write_unchecked_overwrite_checked_read() {
last_index::checked_write_unchecked_overwrite_checked_read::<I16>(
DATABASE_LOCATION,
42,
15
);
}

#[test]
#[serial]
fn checked_write_unchecked_overwrite_unchecked_read() {
last_index::checked_write_unchecked_overwrite_unchecked_read::<I16>(
DATABASE_LOCATION,
42,
15
);
}

#[test]
#[serial]
fn unchecked_write_checked_overwrite_unchecked_read() {
last_index::unchecked_write_checked_overwrite_unchecked_read::<I16>(
DATABASE_LOCATION,
42,
15
);
}

#[test]
#[serial]
fn checked_write_checked_overwrite_unchecked_read() {
last_index::checked_write_checked_overwrite_unchecked_read::<I16>(
DATABASE_LOCATION,
42,
15
);
}
Loading

0 comments on commit 929dc9d

Please sign in to comment.