Skip to content

fix: derive Debug for all table row types #361

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/edge_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use crate::{EdgeId, NodeId};
use ll_bindings::{tsk_edge_table_free, tsk_edge_table_init};

/// Row of an [`EdgeTable`]
#[derive(Debug)]
pub struct EdgeTableRow {
pub id: EdgeId,
pub left: Position,
Expand Down
1 change: 1 addition & 0 deletions src/individual_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use crate::{tsk_id_t, tsk_size_t, TskitError};
use ll_bindings::{tsk_individual_table_free, tsk_individual_table_init};

/// Row of a [`IndividualTable`]
#[derive(Debug)]
pub struct IndividualTableRow {
pub id: IndividualId,
pub flags: IndividualFlags,
Expand Down
1 change: 1 addition & 0 deletions src/migration_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use crate::{MigrationId, NodeId, PopulationId};
use ll_bindings::{tsk_migration_table_free, tsk_migration_table_init};

/// Row of a [`MigrationTable`]
#[derive(Debug)]
pub struct MigrationTableRow {
pub id: MigrationId,
pub left: Position,
Expand Down
1 change: 1 addition & 0 deletions src/mutation_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use crate::{MutationId, NodeId, SiteId};
use ll_bindings::{tsk_mutation_table_free, tsk_mutation_table_init};

/// Row of a [`MutationTable`]
#[derive(Debug)]
pub struct MutationTableRow {
pub id: MutationId,
pub site: SiteId,
Expand Down
1 change: 1 addition & 0 deletions src/node_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use crate::{IndividualId, NodeId, PopulationId};
use ll_bindings::{tsk_node_table_free, tsk_node_table_init};

/// Row of a [`NodeTable`]
#[derive(Debug)]
pub struct NodeTableRow {
pub id: NodeId,
pub time: Time,
Expand Down
2 changes: 1 addition & 1 deletion src/population_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use crate::TskitError;
use ll_bindings::{tsk_population_table_free, tsk_population_table_init};

/// Row of a [`PopulationTable`]
#[derive(Eq)]
#[derive(Eq, Debug)]
pub struct PopulationTableRow {
pub id: PopulationId,
pub metadata: Option<Vec<u8>>,
Expand Down
1 change: 1 addition & 0 deletions src/site_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use crate::TskitError;
use ll_bindings::{tsk_site_table_free, tsk_site_table_init};

/// Row of a [`SiteTable`]
#[derive(Debug)]
pub struct SiteTableRow {
pub id: SiteId,
pub position: Position,
Expand Down
18 changes: 16 additions & 2 deletions tests/test_tables.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,22 @@ mod test_adding_rows_without_metadata {
// are held in an Option.
match tables.$table().row(id) {
Some(row) => {
// assert_eq!(row, row);
assert!(row.metadata.is_none())
assert!(row.metadata.is_none());

// A row equals itself
let row2 = tables.$table().row(id).unwrap();
assert_eq!(row, row2);

// create a second row w/identical payload
if let Ok(id2) = tables.$adder($($payload),*) {
if let Some(row2) = tables.$table().row(id2) {
// The rows have different id
assert_ne!(row, row2);
} else {
panic!("Expected Some(row2) from {} table", stringify!(table))
}
}

},
None => panic!("Expected Some(row) from {} table", stringify!(table))
}
Expand Down